use YansongdaPayPay;
use YansongdaPayLog;
$order = [
'out_trade_no' => $out_trade_no,
'body' => '代理开通',
'total_fee' => $price,
'openid' => $this->auth->getUser()->openid,
];
$result = Pay::wechat(Config::get('wechat.pay'))->mp($order);
function onBridgeReady() {
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
"appId": "{$data.appId}", //公众号名称,由商户传入
"timeStamp": "{$data.timeStamp}", //时间戳,自1970年以来的秒数
"nonceStr": "{$data.nonceStr}", //随机串
"package": "{$data.package}",
"signType": "{$data.signType}", //微信签名方式:
"paySign": "{$data.paySign}" //微信签名
},
function (res) {
//alert(JSON.stringify(res));
console.log(res)
if (res.err_msg == "get_brand_wcpay_request:ok") {
alert("支付成功!");
location.href = successurl;
} else if (res.err_msg == "get_brand_wcpay_request:cancel") {
alert("用户取消支付!");
location.href = '{:url("paycancel")}';
} else {
alert("支付失败!");
location.href = '{:url("payerror")}';
}
});
}
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
}
} else {
onBridgeReady();
}
$pay = Pay::wechat(Config::get('wechat.pay'));
try {
$data = $pay->verify(); // 是的,验签就这么简单!
$return_data = $data->all();
$pay_order_model = new appapimodelpayOrder;
$order_mes = $pay_order_model->getOrderByPackage($return_data['out_trade_no']);
} catch (Exception $e) {
// $e->getMessage();
}
return $pay->success()->send();// laravel 框架中请直接 `return $pay->success()`
https://gitee.com/yansongda/pay