退款接口错误返回

This commit is contained in:
evoxwht 2023-04-11 10:12:41 +08:00
parent 4c42203697
commit f1c80f0552
2 changed files with 14 additions and 8 deletions

View File

@ -14,6 +14,7 @@
namespace crmeb\services\pay\storage;
use app\services\pay\PayServices;
use crmeb\exceptions\AdminException;
use crmeb\exceptions\PayException;
use crmeb\services\pay\BasePay;
use crmeb\services\pay\PayInterface;
@ -115,7 +116,8 @@ class AllinPay extends BasePay implements PayInterface
*/
public function refund(string $outTradeNo, array $options = [])
{
return $this->pay->refund($options['refund_price'], $options['order_id'], $outTradeNo);
$result = $this->pay->refund($options['refund_price'], $options['order_id'], $outTradeNo);
if ($result['retcode'] != 'SUCCESS') throw new AdminException($result['retmsg']);
}
public function queryRefund(string $outTradeNo, string $outRequestNo, array $other = [])

View File

@ -103,18 +103,22 @@ class WechatPay extends BasePay implements PayInterface
$refundNo = $opt['refund_id'] ?? $outTradeNo;
$opUserId = $opt['op_user_id'] ?? null;
$type = $opt['type'] ?? 'out_trade_no';
/*仅针对老资金流商户使用
REFUND_SOURCE_UNSETTLED_FUNDS---未结算资金退款(默认使用未结算资金退款)
REFUND_SOURCE_RECHARGE_FUNDS---可用余额退款
*/
/**
* 仅针对老资金流商户使用
* REFUND_SOURCE_UNSETTLED_FUNDS---未结算资金退款(默认使用未结算资金退款)
* REFUND_SOURCE_RECHARGE_FUNDS---可用余额退款
*/
$refundAccount = $opt['refund_account'] ?? 'REFUND_SOURCE_UNSETTLED_FUNDS';
if (isset($opt['wechat'])) {
return WechatService::refund($outTradeNo, $refundNo, $totalFee, $refundFee, $opUserId, $refundReason, $type, $refundAccount);
$result = WechatService::refund($outTradeNo, $refundNo, $totalFee, $refundFee, $opUserId, $refundReason, $type, $refundAccount);
if ($result['status'] != 'SUCCESS') throw new AdminException($result['status']);
} else {
if ($opt['pay_new_weixin_open']) {
return MiniProgramService::miniRefund($outTradeNo, $totalFee, $refundFee, $opt);
$result = MiniProgramService::miniRefund($outTradeNo, $totalFee, $refundFee, $opt);
if ($result['errcode'] != 0) throw new AdminException($result['errmsg']);
} else {
return MiniProgramService::refund($outTradeNo, $refundNo, $totalFee, $refundFee, $opUserId, $refundReason, $type, $refundAccount);
$result = MiniProgramService::refund($outTradeNo, $refundNo, $totalFee, $refundFee, $opUserId, $refundReason, $type, $refundAccount);
if ($result['status'] != 'SUCCESS') throw new AdminException($result['status']);
}
}
}