苹果支付,1.0

This commit is contained in:
@fawn-nine
2023-04-19 14:53:52 +08:00
parent 14ea3db691
commit ee74da48cc

View File

@@ -89,6 +89,9 @@
setPay, setPay,
setPayAssign setPayAssign
} from '@/config/utils'; } from '@/config/utils';
const IAPOrders = [
'add69'
] // 根据这些ids获取到苹果app内商品信息这些ids就是你上面设置的产品id
export default { export default {
data() { data() {
return { return {
@@ -174,6 +177,7 @@
mask: true mask: true
}) })
plus.payment.getChannels((channels) => { plus.payment.getChannels((channels) => {
console.log(channels,'channels')
for (var i in channels) { for (var i in channels) {
// 判断是否苹果支付 // 判断是否苹果支付
if (channels[i].id === 'appleiap') { if (channels[i].id === 'appleiap') {
@@ -193,12 +197,13 @@
const that = this const that = this
console.log(that.stepsCj.priceTypeId,88888888) console.log(that.stepsCj.priceTypeId,88888888)
// ['xxxxx'] 是平台申请拿到的内购商品的id // ['xxxxx'] 是平台申请拿到的内购商品的id
that.iapChannel.requestOrder(that.stepsCj.priceTypeId, function(event) { console.log(IAPOrders,'IAPOrders')
that.iapChannel.requestOrder(IAPOrders, function(event) {
// uni.hideLoading() // uni.hideLoading()
console.log(event) console.log(event,'event')
for (var index in event) { for (var index in event) {
var OrderItem = event[index] var OrderItem = event[index]
console.log(OrderItem) console.log(OrderItem, 'OrderItem')
that.topay(OrderItem.productid) that.topay(OrderItem.productid)
} }
}, function(erroemsg) { }, function(erroemsg) {
@@ -207,7 +212,7 @@
// }) // })
uni.showToast({ uni.showToast({
title: "获取支付通道失败", title: "获取订单失败,请重试",
icon: 'none' icon: 'none'
}) })
}) })
@@ -223,9 +228,10 @@
orderInfo: { orderInfo: {
productid: id, productid: id,
username: 'ordersn', // 用户标识 username: 'ordersn', // 用户标识
optimize: true // 设置 optimize: true 解决丢单问题 optimize: false // 设置 optimize: true 解决丢单问题
}, },
success: (res => { success: (res => {
console.log(res,'成功的返回值1') // 成功的返回值
uni.hideLoading() uni.hideLoading()
let data= { let data= {
receipt:res.transactionReceipt, // 校验体 receipt:res.transactionReceipt, // 校验体