DevsDawn
DevsDawn

easywechat小程序支付

$this->pay = Factory::payment(Config::get('pay'));

$pay_params = [
    'out_trade_no' => $order->out_trade_no,
    'total_fee' => $order->pay_amount*100,
    'body' => $order->name,
    'trade_type' => 'JSAPI',
    'openid' => $user->openid
];

$res = $this->pay->order->unify($pay_params);

if ($res['return_code'] != 'SUCCESS') {
    throw new DisplayException("[{$res['return_code']}] {$res['return_msg']}");
} elseif ($res['result_code'] != 'SUCCESS') {
    throw new DisplayException("[{$res['err_code']}] {$res['err_code_des']}");
}

// 小程序需要使用jssdk处理参数
$res = $this->pay->jssdk->sdkConfig($res['prepay_id']);

return $res;
若无特别说明,本文采用 CC BY-SA 4.0 协议进行许可。如需转载,请附上本文链接和本声明。
本文链接:https://devsdawn.com/2021/08/easywechat-pay-in-miniprogram/
DigitalOcean云服务,NYSE上市公司,注册即送200USD体验金
Vultr云服务,全球25+地域,注册即送100USD体验金

发表回复

textsms
account_circle
email

DevsDawn

easywechat小程序支付
$this->pay = Factory::payment(Config::get('pay')); $pay_params = [ 'out_trade_no' => $order->out_trade_no, 'total_fee' => $order->pay_amount*100, …
扫描二维码继续阅读
2021-08-02