PHP code example of xin / payment
1. Go to this page and download the library: Download xin/payment library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
xin / payment example snippets
// 配置示例
[
'defaults' => [
'wechat' => 'default',
'alipay' => 'default',
'unipay' => 'default',
'douyin' => 'default'
],
'wechat' => [
'default' => [
// 微信支付配置
]
],
'alipay' => [
'default' => [
// 支付宝配置
]
],
'unipay' => [
'default' => [
// 银联支付配置
]
],
'douyin' => [
'default' => [
// 抖音支付配置
]
],
'logger' => [
// 日志配置
],
'http' => [
// HTTP 配置
]
]
// 获取支付实例
$wechat = $payment->wechat('default');
$alipay = $payment->alipay('default');
$unipay = $payment->unipay('default');
$douyin = $payment->douyin('default');
// 检查是否配置了支付方式
if ($payment->hasWechat('default')) {
// 微信支付已配置
}
// 使用不同配置名称
$wechat1 = $payment->wechat('shop1');
$wechat2 = $payment->wechat('shop2');
// 传递额外选项
$wechat = $payment->wechat('default', [
'cert' => true // 启用证书功能
]);
src/
├── Contracts/ # 接口定义
├── Exceptions/ # 异常类
├── Laravel/ # Laravel 集成
├── ThinkPHP/ # ThinkPHP 集成
├── HasAlipay.php # 支付宝实现
├── HasDouyin.php # 抖音支付实现
├── HasUnipay.php # 银联支付实现
├── HasWechat.php # 微信支付实现
├── PaymentManager.php # 支付管理器
└── PaymentType.php # 支付类型常量