屬性 | 類型 | 默認(rèn)值 | 必填 | 說明 |
---|---|---|---|---|
id | number | 否 | 訂單ID | |
platform | string | 是 | 支付平臺(tái) alipay:支付寶 weixin:微信支付 | |
type | string | 是 | 支付類型 goodsIndent:商品訂單 |
示例代碼:
public function weixinPayment($body,$fee,$openid,$trade_type='JSAPI'){
$number= orderNumber();
$config = config('wechat.payment.default');
$config['notify_url'] = request()->root().'/api/v1/app/paymentNotify';
$app = Factory::payment($config);
$result = $app->order->unify([
'body' => $body,
'out_trade_no' => $number,
'total_fee' => $fee,
'trade_type' => $trade_type,
'openid' => $openid,
]);
$return =[
'result'=>'error',
'msg'=>'支付異常,請(qǐng)聯(lián)系管理員'
];
if ($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS') {
$prepayId = $result['prepay_id'];
$config = $app->jssdk->sdkConfig($prepayId);
$return =[
'result'=>'ok',
'msg'=>$config,
'number'=>$number
];
}
if ($result['return_code'] == 'FAIL' && array_key_exists('return_msg', $result)) {
$return =[
'result'=>'error',
'msg'=>$result['return_msg']
];
}
return $return;
}
屬性 | 類型 | 默認(rèn)值 | 必填 | 說明 |
---|---|---|---|---|
result | string | 是 | 返回狀態(tài),成功:ok 失敗:error | |
code | string | 否 | 錯(cuò)誤碼,當(dāng)result為error時(shí)需填寫 | |
msg | string | 否 | 錯(cuò)誤原因,當(dāng)result為error時(shí)需填寫 | |
number | string | 否 | 訂單號(hào),當(dāng)result為ok時(shí)需填寫 |
App\Models\v1\MiniProgram
?復(fù)制一份?weixinPayment
?方法,將?weixin
?換成上一步設(shè)置的標(biāo)識(shí)
#商品訂單支付生成
#api\app\Observers\PaymentLog\GoodIndentPaymentCreateObserver.php
#商品訂單支付完成
#api\app\Observers\PaymentLog\GoodIndentPaymentSucceedObserver.php
#商品訂單退款
#api\app\Observers\PaymentLog\GoodIndentRefundObserver.php
更多建議: