微信支付完成
This commit is contained in:
@@ -89,7 +89,7 @@
|
||||
} from 'vuex';
|
||||
import {
|
||||
setPay,
|
||||
setPayAssign
|
||||
setPayAssign,setWXPay
|
||||
} from '@/config/utils';
|
||||
// const IAPOrders = [ // 根据这些ids获取到苹果app内商品信息,这些ids就是你上面设置的产品id
|
||||
// 'add69'
|
||||
@@ -163,6 +163,7 @@
|
||||
finishTransaction(trans){
|
||||
this.iapChannel.finishTransaction(trans, (success) => {
|
||||
console.log('关闭订单成功');
|
||||
this.setUserInfo({restoreFlag:false});
|
||||
}, (fail) => {
|
||||
console.log('关闭订单失败');
|
||||
});
|
||||
@@ -189,6 +190,7 @@
|
||||
},
|
||||
iphonepay() {
|
||||
const that = this
|
||||
// 如果ios已经绑定支付信息,就直接支付,如果没有绑定,就需要先绑定
|
||||
console.log('检测支付环境...')
|
||||
plus.payment.getChannels((channels) => {
|
||||
console.log(channels, 'channels')
|
||||
@@ -250,16 +252,18 @@
|
||||
// restoreFlag = false; // 支付成功清除标记 restoreFlag = false
|
||||
that.transaction = result
|
||||
// 支付成功,result 为 IAP商品交易信息对象 IAPTransaction 需将返回的支付凭证传给后端进行二次认证
|
||||
uni.hideLoading()
|
||||
that.iapCheck(result)
|
||||
}, function(e) {
|
||||
// restoreFlag = false; // 支付失败清楚标记
|
||||
that.setUserInfo({restoreFlag:false});
|
||||
that.finishTransaction(result);
|
||||
//console.log('订单关闭后的用户信息', that.userInfo);
|
||||
console.log(e)
|
||||
//console.log(e.message)
|
||||
uni.hideLoading()
|
||||
if(e.errCode == 2){
|
||||
// 用户未绑定支付方式,app内支付流程结束,系统弹出框引导用户绑定支付方式,此过程将跳转到系统应用 AppStore 进行绑定支付方式,绑定成功同步支付成功,用户成功付款
|
||||
plus.runtime.openURL("https://apps.apple.com/account/billing");
|
||||
}else{
|
||||
// restoreFlag = false; // 支付失败清楚标记
|
||||
that.finishTransaction(result);
|
||||
//console.log('订单关闭后的用户信息', that.userInfo);
|
||||
console.log(e)
|
||||
//console.log(e.message)
|
||||
}
|
||||
});
|
||||
},
|
||||
iapCheck(result) {
|
||||
@@ -291,12 +295,19 @@
|
||||
// 服务器验证票据有效后在客户端关闭订单 (iapChannel.finishTransaction)
|
||||
that.finishTransaction(result);
|
||||
}
|
||||
}).catch(e => {
|
||||
uni.showToast({
|
||||
title:'支付验证失败,请稍后重启app,如不能解决您的问题,可联系官方客服',
|
||||
icon: 'none',
|
||||
duration:5000
|
||||
})
|
||||
}).catch(e => {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
showCancel:false,
|
||||
content: '支付验证失败,请稍后重启app,如不能解决您的问题,可联系官方客服',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
console.log('用户点击确定');
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消');
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
getDevName() {
|
||||
@@ -401,7 +412,7 @@
|
||||
uni.showToast({
|
||||
title: "支付成功"
|
||||
});
|
||||
} else {
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "支付失败",
|
||||
icon: "none",
|
||||
@@ -410,11 +421,42 @@
|
||||
}
|
||||
})
|
||||
} else if (that.payType == 1) {
|
||||
// 微信支付
|
||||
uni.showToast({
|
||||
title: '微信支付',
|
||||
none: 'none'
|
||||
})
|
||||
// 微信支付
|
||||
that.orderSn = res.orderSn
|
||||
let data1={
|
||||
orderSn:that.orderSn,
|
||||
// orderId:that.orderSn,
|
||||
}
|
||||
console.log(data1,'data1')
|
||||
// console.log(this.userInfo.channelList,'channelList')
|
||||
// this.userInfo.channelList.map(item => {
|
||||
// if(item.id == "wxpay"){
|
||||
// console.log('支持微信支付')
|
||||
setWXPay(data1,res => {
|
||||
if (res.success) {
|
||||
uni.showToast({
|
||||
title: "支付成功"
|
||||
});
|
||||
} else {
|
||||
console.log(res)
|
||||
if(res.data.errMsg.indexOf('User canceled') != -1){
|
||||
uni.showToast({
|
||||
title: "用户取消支付",
|
||||
icon: "none",
|
||||
image: '../../static/icon/ic_close.png'
|
||||
});
|
||||
}else{
|
||||
uni.showToast({
|
||||
title: "支付失败",
|
||||
icon: "none",
|
||||
image: '../../static/icon/ic_close.png'
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
// }
|
||||
// })
|
||||
|
||||
} else if (that.payType == 3) {
|
||||
console.log('苹果支付', )
|
||||
that.iosPay()
|
||||
|
||||
Reference in New Issue
Block a user