Error message here!

Hide Error message here!

忘记密码?

Error message here!

请输入正确邮箱

Hide Error message here!

密码丢失?请输入您的电子邮件地址。您将收到一个重设密码链接。

Error message here!

返回登录

Close

Laravel 5.5 easywechat applet payment

wx5bffdbaf11b62 2021-07-26 11:17:10 阅读数:2 评论数:0 点赞数:0 收藏数:0

 public function mpPay()
{
$options = [
'app_id' => '',
'mch_id' => '',
'key' => '',
'notify_url' => '',
'sandbox' => true,
];
$payment = Factory::payment($options);
$jssdk = $payment->jssdk;
$attributes = [
'trade_type' => 'JSAPI',
'body' => 'ceshi',
'out_trade_no' => 'ceshi074392473921',
'total_fee' => 1.01*100,
'openid' => ''
];
$result = $payment->order->unify($attributes);
if ($result['return_code'] == 'FAIL') {
return apiBack(400, $result['return_msg']);
}
if ($result['return_code'] == 'SUCCESS') {
$prepayId = $result['prepay_id'];
$config = $jssdk->sdkConfig($prepayId);
return apiBack(200, 'success', [
'wx_res' => $config
]);
}
if ($result['return_code'] == 'FAIL' && array_key_exists('return_msg', $result)) {
return apiBack(400, $result['return_msg']);
}
}

 

Copyright statement
In this paper,the author:[wx5bffdbaf11b62],Reprint please bring the original link, thank you

编程之旅,人生之路,不止于编程,还有诗和远方。
阅代码原理,看框架知识,学企业实践;
赏诗词,读日记,踏人生之路,观世界之行;