|
@@ -24,326 +24,200 @@ class Douyin extends Base
|
|
parent::__construct($payService, $platform, $channel);
|
|
parent::__construct($payService, $platform, $channel);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 抖音支付
|
|
|
|
+ * @param array $order
|
|
|
|
+ * @param array $config
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
public function pay($order, $config = [])
|
|
public function pay($order, $config = [])
|
|
{
|
|
{
|
|
$this->init('douyin', $config);
|
|
$this->init('douyin', $config);
|
|
|
|
|
|
- if (isset($this->config['wechat']['default']['mode']) && $this->config['wechat']['default']['mode'] === 2) {
|
|
|
|
- if (in_array($this->platform, ['WechatOfficialAccount', 'WechatMiniProgram'])) {
|
|
|
|
- $order['payer']['sub_openid'] = $order['payer']['openid'] ?? '';
|
|
|
|
- unset($order['payer']['openid']);
|
|
|
|
- }
|
|
|
|
|
|
+ // 按照抖音支付API要求构建订单参数
|
|
|
|
+ $orderData = [
|
|
|
|
+ 'out_order_no' => $order['out_trade_no'],
|
|
|
|
+ 'total_amount' => intval($order['total_amount']), // 抖音支付金额单位为分
|
|
|
|
+ 'subject' => $order['subject'] ?? '商品支付',
|
|
|
|
+ 'body' => $order['body'] ?? '商品支付',
|
|
|
|
+ 'valid_time' => $config['valid_time'] ?? 600, // 默认10分钟
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ // 添加可选参数
|
|
|
|
+ if (isset($order['cp_extra'])) {
|
|
|
|
+ $orderData['cp_extra'] = $order['cp_extra'];
|
|
}
|
|
}
|
|
-
|
|
|
|
- $order['amount']['total'] = intval(bcmul((string)$order['total_amount'], '100')); // 按分 为单位
|
|
|
|
-
|
|
|
|
- if ($this->platform == 'H5') {
|
|
|
|
- $order['_type'] = 'app'; // 使用 配置中的 app_id 字段
|
|
|
|
- $order['scene_info'] = [
|
|
|
|
- 'payer_client_ip' => request()->ip(),
|
|
|
|
- 'h5_info' => [
|
|
|
|
- 'type' => 'Wap',
|
|
|
|
- ]
|
|
|
|
- ];
|
|
|
|
|
|
+
|
|
|
|
+ if (isset($config['disable_msg'])) {
|
|
|
|
+ $orderData['disable_msg'] = $config['disable_msg'];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (isset($config['msg_page'])) {
|
|
|
|
+ $orderData['msg_page'] = $config['msg_page'];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 移除不需要的字段
|
|
unset($order['order_id'], $order['total_amount']);
|
|
unset($order['order_id'], $order['total_amount']);
|
|
- $method = $this->getMethod('wechat');
|
|
|
|
- $result = Pay::wechat()->$method($order);
|
|
|
|
|
|
+
|
|
|
|
+ // 获取支付方法
|
|
|
|
+ $method = $this->getMethod('douyin');
|
|
|
|
+
|
|
|
|
+ // 调用 Yansongda\Pay 进行支付
|
|
|
|
+ $result = Pay::douyin()->$method($orderData);
|
|
|
|
+
|
|
|
|
+ Log::write('抖音支付预下单响应:' . json_encode($result->toArray(), JSON_UNESCAPED_UNICODE));
|
|
|
|
|
|
return $result;
|
|
return $result;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 转账功能(抖音支付暂不支持)
|
|
|
|
+ * @param array $payload
|
|
|
|
+ * @param array $config
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
public function transfer($payload, $config = [])
|
|
public function transfer($payload, $config = [])
|
|
{
|
|
{
|
|
- $this->init('wechat', $config, 'sub_mch');
|
|
|
|
-
|
|
|
|
- $code = 0;
|
|
|
|
- $payload['total_amount'] = intval(bcmul((string)$payload['total_amount'], '100'));
|
|
|
|
-
|
|
|
|
- foreach ($payload['transfer_detail_list'] as $key => &$detail) {
|
|
|
|
- $detail['transfer_amount'] = intval(bcmul((string)$detail['transfer_amount'], '100'));
|
|
|
|
- }
|
|
|
|
- if (isset($this->config['wechat']['default']['_type'])) {
|
|
|
|
- // 为了能正常获取 appid
|
|
|
|
- $payload['_type'] = $this->config['wechat']['default']['_type'];
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // $payload['authorization_type'] = 'INFORMATION_AUTHORIZATION_TYPE';
|
|
|
|
- $payload['authorization_type'] = 'FUND_AUTHORIZATION_TYPE';
|
|
|
|
- // $payload['authorization_type'] = 'INFORMATION_AND_FUND_AUTHORIZATION_TYPE';
|
|
|
|
-
|
|
|
|
- $response = Pay::wechat()->transfer($payload);
|
|
|
|
- if (isset($response['batch_id']) && $response['batch_id']) {
|
|
|
|
- $code = 1;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return [$code, $response];
|
|
|
|
|
|
+ throw new Exception('抖音支付暂不支持转账功能');
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 支付回调处理
|
|
|
|
+ * @param callable $callback
|
|
|
|
+ * @param array $config
|
|
|
|
+ * @return string
|
|
|
|
+ */
|
|
public function notify($callback, $config = [])
|
|
public function notify($callback, $config = [])
|
|
{
|
|
{
|
|
- $this->init('wechat', $config);
|
|
|
|
|
|
+ $this->init('douyin', $config);
|
|
|
|
+
|
|
try {
|
|
try {
|
|
- $originData = Pay::wechat()->callback(); // 是的,验签就这么简单!
|
|
|
|
- // {
|
|
|
|
- // "id": "a5c68a7c-5474-5151-825d-88b4143f8642",
|
|
|
|
- // "create_time": "2022-06-20T16:16:12+08:00",
|
|
|
|
- // "resource_type": "encrypt-resource",
|
|
|
|
- // "event_type": "TRANSACTION.SUCCESS",
|
|
|
|
- // "summary": "支付成功",
|
|
|
|
- // "resource": {
|
|
|
|
- // "original_type": "transaction",
|
|
|
|
- // "algorithm": "AEAD_AES_256_GCM",
|
|
|
|
- // "ciphertext": {
|
|
|
|
- // "mchid": "1623831039",
|
|
|
|
- // "appid": "wx43********d3d0",
|
|
|
|
- // "out_trade_no": "P202204155176122100021000",
|
|
|
|
- // "transaction_id": "4200001433202206201698588194",
|
|
|
|
- // "trade_type": "JSAPI",
|
|
|
|
- // "trade_state": "SUCCESS",
|
|
|
|
- // "trade_state_desc": "支付成功",
|
|
|
|
- // "bank_type": "OTHERS",
|
|
|
|
- // "attach": "",
|
|
|
|
- // "success_time": "2022-06-20T16:16:12+08:00",
|
|
|
|
- // "payer": {
|
|
|
|
- // "openid": "oRj5A44G6lgCVENzVMxZtoMfNeww"
|
|
|
|
- // },
|
|
|
|
- // "amount": {
|
|
|
|
- // "total": 1,
|
|
|
|
- // "payer_total": 1,
|
|
|
|
- // "currency": "CNY",
|
|
|
|
- // "payer_currency": "CNY"
|
|
|
|
- // }
|
|
|
|
- // },
|
|
|
|
- // "associated_data": "transaction",
|
|
|
|
- // "nonce": "qoJzoS9MCNgu"
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- Log::write('pay-notify-origin-data:' . json_encode($originData));
|
|
|
|
- if ($originData['event_type'] == 'TRANSACTION.SUCCESS') {
|
|
|
|
- // 支付成功回调
|
|
|
|
- $data = $originData['resource']['ciphertext'] ?? [];
|
|
|
|
- if (isset($data['trade_state']) && $data['trade_state'] == 'SUCCESS') {
|
|
|
|
- // 交易成功
|
|
|
|
- $data['pay_fee'] = ($data['amount']['total'] / 100);
|
|
|
|
- $data['notify_time'] = date('Y-m-d H:i:s', strtotime((string)$data['success_time']));
|
|
|
|
- $data['buyer_info'] = $data['payer']['openid'] ?? ($data['payer']['sub_openid'] ?? '');
|
|
|
|
|
|
+ // 使用 Yansongda\Pay 处理回调验签
|
|
|
|
+ $data = Pay::douyin()->callback();
|
|
|
|
+
|
|
|
|
+ Log::write('抖音支付回调原始数据:' . json_encode($data, JSON_UNESCAPED_UNICODE));
|
|
|
|
+
|
|
|
|
+ // 处理支付成功回调
|
|
|
|
+ if ($data['type'] === 'payment' && $data['msg'] === 'success') {
|
|
|
|
+ // 格式化数据为统一格式
|
|
|
|
+ $callbackData = [
|
|
|
|
+ 'out_trade_no' => $data['out_order_no'],
|
|
|
|
+ 'transaction_id' => $data['order_id'],
|
|
|
|
+ 'total_amount' => $data['total_amount'],
|
|
|
|
+ 'pay_fee' => $data['total_amount'], // 抖音支付金额单位为分,这里保持原样
|
|
|
|
+ 'notify_time' => date('Y-m-d H:i:s'),
|
|
|
|
+ 'buyer_info' => $data['buyer_info'] ?? '',
|
|
|
|
+ 'cp_extra' => $data['cp_extra'] ?? ''
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ $result = $callback($callbackData, $data);
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
|
|
- $result = $callback($data, $originData);
|
|
|
|
- return $result;
|
|
|
|
- }
|
|
|
|
|
|
+ Log::error('抖音支付回调类型不支持: ' . ($data['type'] ?? 'unknown'));
|
|
|
|
+ return 'fail';
|
|
|
|
|
|
- return 'fail';
|
|
|
|
- } else {
|
|
|
|
- // 微信交易未成功,返回 false,让微信再次通知
|
|
|
|
- Log::error('notify-error:交易未成功:' . $originData['event_type']);
|
|
|
|
- return 'fail';
|
|
|
|
- }
|
|
|
|
} catch (HttpResponseException $e) {
|
|
} catch (HttpResponseException $e) {
|
|
$data = $e->getResponse()->getData();
|
|
$data = $e->getResponse()->getData();
|
|
$message = $data ? ($data['msg'] ?? '') : $e->getMessage();
|
|
$message = $data ? ($data['msg'] ?? '') : $e->getMessage();
|
|
- $this->logPayment('微信支付回调HttpResponseException', ['error' => $message], 'error');
|
|
|
|
|
|
+ $this->logPayment('抖音支付回调HttpResponseException', ['error' => $message], 'error');
|
|
return 'fail';
|
|
return 'fail';
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
- $this->logPayment('微信支付回调异常', ['error' => $e->getMessage()], 'error');
|
|
|
|
|
|
+ $this->logPayment('抖音支付回调异常', ['error' => $e->getMessage()], 'error');
|
|
return 'fail';
|
|
return 'fail';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 退款
|
|
* 退款
|
|
- *
|
|
|
|
* @param array $order_data
|
|
* @param array $order_data
|
|
* @param array $config
|
|
* @param array $config
|
|
* @return array
|
|
* @return array
|
|
*/
|
|
*/
|
|
public function refund($order_data, $config = [])
|
|
public function refund($order_data, $config = [])
|
|
{
|
|
{
|
|
- $config['notify_url'] = $config['notify_url'] ?? request()->domain() . '/addons/shopro/pay/notifyRefund/payment/wechat/platform/' . $this->platform;
|
|
|
|
- $order_data['notify_url'] = $config['notify_url'];
|
|
|
|
|
|
+ $this->init('douyin', $config);
|
|
|
|
|
|
- $this->init('wechat', $config);
|
|
|
|
|
|
+ // 构建退款参数
|
|
|
|
+ $refundData = [
|
|
|
|
+ 'out_order_no' => $order_data['out_trade_no'],
|
|
|
|
+ 'out_refund_no' => $order_data['out_refund_no'],
|
|
|
|
+ 'refund_amount' => intval($order_data['refund_amount']), // 抖音退款金额单位为分
|
|
|
|
+ 'reason' => $order_data['reason'] ?? '用户申请退款',
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ // 如果有回调地址配置
|
|
|
|
+ if (isset($config['notify_url'])) {
|
|
|
|
+ $refundData['notify_url'] = $config['notify_url'];
|
|
|
|
+ }
|
|
|
|
|
|
- $order_data['amount']['total'] = intval(bcmul((string)$order_data['amount']['total'], '100'));
|
|
|
|
- $order_data['amount']['refund'] = intval(bcmul((string)$order_data['amount']['refund'], '100'));
|
|
|
|
|
|
+ // 调用 Yansongda\Pay 进行退款
|
|
|
|
+ $result = Pay::douyin()->refund($refundData);
|
|
|
|
|
|
- $result = Pay::wechat()->refund($order_data);
|
|
|
|
- Log::write('pay-refund-origin-data:' . json_encode($result, JSON_UNESCAPED_UNICODE));
|
|
|
|
- // { 返回数据字段
|
|
|
|
- // "amount": {
|
|
|
|
- // "currency": "CNY",
|
|
|
|
- // "discount_refund": 0,
|
|
|
|
- // "from": [],
|
|
|
|
- // "payer_refund": 1,
|
|
|
|
- // "payer_total": 1,
|
|
|
|
- // "refund": 1,
|
|
|
|
- // "settlement_refund": 1,
|
|
|
|
- // "settlement_total": 1,
|
|
|
|
- // "total": 1
|
|
|
|
- // },
|
|
|
|
- // "channel": "ORIGINAL",
|
|
|
|
- // "create_time": "2022-06-20T19:06:36+08:00",
|
|
|
|
- // "funds_account": "AVAILABLE",
|
|
|
|
- // "out_refund_no": "R202207063668479227002100",
|
|
|
|
- // "out_trade_no": "P202205155977315528002100",
|
|
|
|
- // "promotion_detail": [],
|
|
|
|
- // "refund_id": "50301802252022062021833667769",
|
|
|
|
- // "status": "PROCESSING",
|
|
|
|
- // "transaction_id": "4200001521202206207964248014",
|
|
|
|
- // "user_received_account": "\u652f\u4ed8\u7528\u6237\u96f6\u94b1"
|
|
|
|
- // }
|
|
|
|
|
|
+ Log::write('抖音退款响应:' . json_encode($result->toArray(), JSON_UNESCAPED_UNICODE));
|
|
|
|
|
|
return $result;
|
|
return $result;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
- * 微信退款回调
|
|
|
|
- *
|
|
|
|
- * @param array $callback
|
|
|
|
|
|
+ * 退款回调处理
|
|
|
|
+ * @param callable $callback
|
|
* @param array $config
|
|
* @param array $config
|
|
- * @return array
|
|
|
|
|
|
+ * @return string
|
|
*/
|
|
*/
|
|
public function notifyRefund($callback, $config = [])
|
|
public function notifyRefund($callback, $config = [])
|
|
{
|
|
{
|
|
- $this->init('wechat', $config);
|
|
|
|
|
|
+ $this->init('douyin', $config);
|
|
|
|
+
|
|
try {
|
|
try {
|
|
- $originData = Pay::wechat()->callback(); // 是的,验签就这么简单!
|
|
|
|
- Log::write('pay-notifyrefund-callback-data:' . json_encode($originData));
|
|
|
|
- // {
|
|
|
|
- // "id": "4a553265-1f28-53a3-9395-8d902b902462",
|
|
|
|
- // "create_time": "2022-06-21T11:25:33+08:00",
|
|
|
|
- // "resource_type": "encrypt-resource",
|
|
|
|
- // "event_type": "REFUND.SUCCESS",
|
|
|
|
- // "summary": "\u9000\u6b3e\u6210\u529f",
|
|
|
|
- // "resource": {
|
|
|
|
- // "original_type": "refund",
|
|
|
|
- // "algorithm": "AEAD_AES_256_GCM",
|
|
|
|
- // "ciphertext": {
|
|
|
|
- // "mchid": "1623831039",
|
|
|
|
- // "out_trade_no": "P202211233042122753002100",
|
|
|
|
- // "transaction_id": "4200001417202206214219765470",
|
|
|
|
- // "out_refund_no": "R202211252676008994002100",
|
|
|
|
- // "refund_id": "50300002272022062121864292533",
|
|
|
|
- // "refund_status": "SUCCESS",
|
|
|
|
- // "success_time": "2022-06-21T11:25:33+08:00",
|
|
|
|
- // "amount": {
|
|
|
|
- // "total": 1,
|
|
|
|
- // "refund": 1,
|
|
|
|
- // "payer_total": 1,
|
|
|
|
- // "payer_refund": 1
|
|
|
|
- // },
|
|
|
|
- // "user_received_account": "\u652f\u4ed8\u7528\u6237\u96f6\u94b1"
|
|
|
|
- // },
|
|
|
|
- // "associated_data": "refund",
|
|
|
|
- // "nonce": "8xfQknYyLVop"
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
|
|
+ // 使用 Yansongda\Pay 处理退款回调验签
|
|
|
|
+ $data = Pay::douyin()->callback();
|
|
|
|
+
|
|
|
|
+ Log::write('抖音退款回调原始数据:' . json_encode($data, JSON_UNESCAPED_UNICODE));
|
|
|
|
+
|
|
|
|
+ // 处理退款成功回调
|
|
|
|
+ if ($data['type'] === 'refund' && $data['msg'] === 'success') {
|
|
|
|
+ $result = $callback($data, $data);
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
|
|
- if ($originData['event_type'] == 'REFUND.SUCCESS') {
|
|
|
|
- // 支付成功回调
|
|
|
|
- $data = $originData['resource']['ciphertext'] ?? [];
|
|
|
|
- if (isset($data['refund_status']) && $data['refund_status'] == 'SUCCESS') {
|
|
|
|
- // 退款成功
|
|
|
|
- $result = $callback($data, $originData);
|
|
|
|
- return $result;
|
|
|
|
- }
|
|
|
|
|
|
+ Log::error('抖音退款回调类型不支持: ' . ($data['type'] ?? 'unknown'));
|
|
|
|
+ return 'fail';
|
|
|
|
|
|
- return 'fail';
|
|
|
|
- } else {
|
|
|
|
- // 微信交易未成功,返回 false,让微信再次通知
|
|
|
|
- Log::error('notify-error:退款未成功:' . $originData['event_type']);
|
|
|
|
- return 'fail';
|
|
|
|
- }
|
|
|
|
} catch (HttpResponseException $e) {
|
|
} catch (HttpResponseException $e) {
|
|
$data = $e->getResponse()->getData();
|
|
$data = $e->getResponse()->getData();
|
|
$message = $data ? ($data['msg'] ?? '') : $e->getMessage();
|
|
$message = $data ? ($data['msg'] ?? '') : $e->getMessage();
|
|
- format_log_error($e, 'wechatNotifyRefund.HttpResponseException', $message);
|
|
|
|
|
|
+ $this->logPayment('抖音退款回调HttpResponseException', ['error' => $message], 'error');
|
|
return 'fail';
|
|
return 'fail';
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
- format_log_error($e, 'wechatNotifyRefund');
|
|
|
|
|
|
+ $this->logPayment('抖音退款回调异常', ['error' => $e->getMessage()], 'error');
|
|
return 'fail';
|
|
return 'fail';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 格式化支付参数
|
|
* 格式化支付参数
|
|
- *
|
|
|
|
- * @param [type] $params
|
|
|
|
- * @return void
|
|
|
|
|
|
+ * @param array $config
|
|
|
|
+ * @param array $data
|
|
|
|
+ * @param string $type
|
|
|
|
+ * @return array
|
|
*/
|
|
*/
|
|
protected function formatConfig($config, $data = [], $type = 'normal')
|
|
protected function formatConfig($config, $data = [], $type = 'normal')
|
|
{
|
|
{
|
|
- if ($config['mode'] == 2 && $type == 'sub_mch') {
|
|
|
|
- // 服务商模式,但需要子商户直连 ,重新定义 config(商家转账到零钱)
|
|
|
|
- $config = [
|
|
|
|
- 'mch_id' => $config['sub_mch_id'],
|
|
|
|
- 'mch_secret_key' => $config['sub_mch_secret_key'],
|
|
|
|
- 'mch_secret_cert' => $config['sub_mch_secret_cert'],
|
|
|
|
- 'mch_public_cert_path' => $config['sub_mch_public_cert_path'],
|
|
|
|
- ];
|
|
|
|
- $config['mode'] = 0; // 临时改为普通商户
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ($config['mode'] === 2) {
|
|
|
|
- // 首先将平台配置的 app_id 初始化到配置中
|
|
|
|
- $config['mp_app_id'] = $config['app_id']; // 服务商关联的公众号的 appid
|
|
|
|
- $config['sub_app_id'] = $data['app_id']; // 服务商特约子商户
|
|
|
|
- } else {
|
|
|
|
- $config['app_id'] = $data['app_id'];
|
|
|
|
- }
|
|
|
|
|
|
+ // 设置抖音支付的基本配置
|
|
|
|
+ $config['app_id'] = $data['app_id'] ?? '';
|
|
|
|
+ $config['secret'] = $data['secret'] ?? $data['salt'] ?? '';
|
|
|
|
|
|
- switch ($this->platform) {
|
|
|
|
- case 'WechatMiniProgram':
|
|
|
|
- $config['_type'] = 'mini'; // 小程序提现,需要传 _type = mini 才能正确获取到 appid
|
|
|
|
- if ($config['mode'] === 2) {
|
|
|
|
- $config['sub_mini_app_id'] = $config['sub_app_id'];
|
|
|
|
- unset($config['sub_app_id']);
|
|
|
|
- } else {
|
|
|
|
- $config['mini_app_id'] = $config['app_id'];
|
|
|
|
- unset($config['app_id']);
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 'WechatOfficialAccount':
|
|
|
|
- $config['_type'] = 'mp'; // 小程序提现,需要传 _type = mp 才能正确获取到 appid
|
|
|
|
- if ($config['mode'] === 2) {
|
|
|
|
- $config['sub_mp_app_id'] = $config['sub_app_id'];
|
|
|
|
- unset($config['sub_app_id']);
|
|
|
|
- } else {
|
|
|
|
- $config['mp_app_id'] = $config['app_id'];
|
|
|
|
- unset($config['app_id']);
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 'App':
|
|
|
|
- case 'H5':
|
|
|
|
- default:
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $config['notify_url'] = request()->domain() . '/addons/shopro/pay/notify/payment/wechat/platform/' . $this->platform;
|
|
|
|
- $config['mch_secret_cert'] = ROOT_PATH . 'public' . $config['mch_secret_cert'];
|
|
|
|
- $config['mch_public_cert_path'] = ROOT_PATH . 'public' . $config['mch_public_cert_path'];
|
|
|
|
-
|
|
|
|
- // 可手动配置微信支付公钥证书
|
|
|
|
- $config['wechat_public_cert_id'] = $config['wechat_public_cert_id'] ?? '';
|
|
|
|
- $config['wechat_public_cert'] = $config['wechat_public_cert'] ?? '';
|
|
|
|
- if ($config['wechat_public_cert_id'] && $config['wechat_public_cert']) {
|
|
|
|
- $config['wechat_public_cert_path'] = [
|
|
|
|
- $config['wechat_public_cert_id'] => ROOT_PATH . 'public' . $config['wechat_public_cert']
|
|
|
|
- ];
|
|
|
|
|
|
+ // 设置回调URL
|
|
|
|
+ $platform = $this->platform ?? 'DouyinMiniProgram';
|
|
|
|
+ $config['notify_url'] = request()->domain() . '/api/pay/notify/payment/douyin/platform/' . $platform;
|
|
|
|
+
|
|
|
|
+ // 设置抖音支付网关(沙盒和生产环境)
|
|
|
|
+ if (isset($config['sandbox']) && $config['sandbox']) {
|
|
|
|
+ $config['mode'] = Pay::MODE_SANDBOX;
|
|
|
|
+ } else {
|
|
|
|
+ $config['mode'] = Pay::MODE_NORMAL;
|
|
}
|
|
}
|
|
- unset($config['wechat_public_cert_id'], $config['wechat_public_cert']);
|
|
|
|
|
|
|
|
return $config;
|
|
return $config;
|
|
}
|
|
}
|