mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-26 11:26:35 +08:00
Update AlipayPaymentService.php
This commit is contained in:
parent
c4943b28ce
commit
7982aef6bd
@ -16,7 +16,7 @@ class AlipayPaymentService extends PaymentService
|
|||||||
* 支付参数配置
|
* 支付参数配置
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $params = [];
|
protected $config = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付服务初始化
|
* 支付服务初始化
|
||||||
@ -24,7 +24,7 @@ class AlipayPaymentService extends PaymentService
|
|||||||
*/
|
*/
|
||||||
protected function initialize(): AlipayPaymentService
|
protected function initialize(): AlipayPaymentService
|
||||||
{
|
{
|
||||||
$this->params = [
|
$this->config = [
|
||||||
// 沙箱模式
|
// 沙箱模式
|
||||||
'debug' => false,
|
'debug' => false,
|
||||||
// 签名类型(RSA|RSA2)
|
// 签名类型(RSA|RSA2)
|
||||||
@ -68,7 +68,7 @@ class AlipayPaymentService extends PaymentService
|
|||||||
*/
|
*/
|
||||||
public function notify(string $param = ''): string
|
public function notify(string $param = ''): string
|
||||||
{
|
{
|
||||||
$notify = \AliPay\App::instance($this->params)->notify();
|
$notify = \AliPay\App::instance($this->config)->notify();
|
||||||
if (in_array($notify['trade_status'], ['TRADE_SUCCESS', 'TRADE_FINISHED'])) {
|
if (in_array($notify['trade_status'], ['TRADE_SUCCESS', 'TRADE_FINISHED'])) {
|
||||||
if ($this->updatePaymentAction($param, $notify['out_trade_no'], $notify['trade_no'], $notify['total_amount'])) {
|
if ($this->updatePaymentAction($param, $notify['out_trade_no'], $notify['trade_no'], $notify['total_amount'])) {
|
||||||
return 'success';
|
return 'success';
|
||||||
@ -89,7 +89,7 @@ class AlipayPaymentService extends PaymentService
|
|||||||
*/
|
*/
|
||||||
public function query(string $orderNo): array
|
public function query(string $orderNo): array
|
||||||
{
|
{
|
||||||
return \AliPay\App::instance($this->params)->query($orderNo);
|
return \AliPay\App::instance($this->config)->query($orderNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,20 +112,20 @@ class AlipayPaymentService extends PaymentService
|
|||||||
} else {
|
} else {
|
||||||
throw new \think\Exception('支付类型[' . static::$type . ']未配置定义!');
|
throw new \think\Exception('支付类型[' . static::$type . ']未配置定义!');
|
||||||
}
|
}
|
||||||
$this->params['notify_url'] = sysuri("@data/api.notify/alipay/scene/order/param/{$tradeParam}", [], false, true);
|
$this->config['notify_url'] = sysuri("@data/api.notify/alipay/scene/order/param/{$tradeParam}", [], false, true);
|
||||||
if (in_array($tradeType, [static::PAYMENT_ALIPAY_WAP, static::PAYMENT_ALIPAY_WEB])) {
|
if (in_array($tradeType, [static::PAYMENT_ALIPAY_WAP, static::PAYMENT_ALIPAY_WEB])) {
|
||||||
if (empty($paymentReturn)) {
|
if (empty($paymentReturn)) {
|
||||||
throw new \think\Exception('支付回跳地址不能为空!');
|
throw new \think\Exception('支付回跳地址不能为空!');
|
||||||
} else {
|
} else {
|
||||||
$this->params['return_url'] = $paymentReturn;
|
$this->config['return_url'] = $paymentReturn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($tradeType === static::PAYMENT_WECHAT_APP) {
|
if ($tradeType === static::PAYMENT_WECHAT_APP) {
|
||||||
$payment = \AliPay\App::instance($this->params);
|
$payment = \AliPay\App::instance($this->config);
|
||||||
} elseif ($tradeType === static::PAYMENT_ALIPAY_WAP) {
|
} elseif ($tradeType === static::PAYMENT_ALIPAY_WAP) {
|
||||||
$payment = \AliPay\Wap::instance($this->params);
|
$payment = \AliPay\Wap::instance($this->config);
|
||||||
} elseif ($tradeType === static::PAYMENT_ALIPAY_WEB) {
|
} elseif ($tradeType === static::PAYMENT_ALIPAY_WEB) {
|
||||||
$payment = \AliPay\Web::instance($this->params);
|
$payment = \AliPay\Web::instance($this->config);
|
||||||
} else {
|
} else {
|
||||||
throw new \think\Exception("支付类型[{$tradeType}]暂时不支持!");
|
throw new \think\Exception("支付类型[{$tradeType}]暂时不支持!");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user