支付回调问题
采用方式,用微擎js函数库调用微信和支付宝支付
util.pay({
orderFee : 0.01,
payMethod : 'alipay', //微信支付(wechat)、百度钱包(baifubao)、支付宝(alipay)、银联支付(unionpay)
orderTitle : '充值10元',
orderTid : 1234567104,
module : 'recharge',
success : function(res) {
alert('支付成功'); },
fail : function(result) {
alert('fail : ' + result.message);
}, complete : function(result) {
alert('complete : ' + result.message);
}
});
支付完成后会走微擎payResult( $ params){}方法。问题就出在参数 $ params中,他有两种参数返回。
- .
{"weid":null,"uniacid":"2","acid":"2","result":"success","type":"wechat","from":"notify","tid":"SN20091152009115","uniontid":"202009112020200911202020091120","transaction_id":null,"trade_type":"JSAPI","follow":0,"user":"oRkO-533Prc4A533Prc4A","fee":"66.00","tag":{"acid":2,"uid":"2406","transaction_id":"4200000420000042000004200000"},"is_usecard":"0","card_type":"0","card_fee":"66.00","card_id":"","paytime":1599827016}
详细的支付数据返回。 - .
{"tid":"SN20091152009115","result":"success","from":"return"}
简单数据返回
注意:
- 通常判断result返回值两者都是success成功,但是from返回值两者是不同的,1. return ,2. notify。
- 同时进行兼容