uni.requestVirtualPayment({
apple: {
productId: this.productId,
appAccountToken: onceStr,
quantity: 1
},
success: function(res) {
//经过开发者server验证成功后请结束该交易
const virtualPaymentManager = uni.getVirtualPaymentManager()
virtualPaymentManager.finishTransaction({
transaction: res.apple,
success: (r) => {
// console.log("关单成功, 该productId= " + res.apple?.productId)
uni.hideLoading()
_this.isShowName = true;
uni.showToast({
icon: "none",
title: "pay success"
})
},
fail: (e) => {
// console.log("关单失败, 该productId= " + res.apple?.productId)
uni.hideLoading()
uni.showToast({
icon: "none",
title: "Payment finish transaction failed,"+e.errMsg+","+e.errSubject
})
}
})
},
fail: function(e) {
uni.hideLoading()
// console.log("购买失败:errSubject= " + e.errSubject + ", errCode= " + e.errCode + ", errMsg= " + e.errMsg)
uni.showToast({
icon: "none",
title: "Payment failed,"+e.errMsg+","+e.errSubject
})
}
}) - 发布:2025-01-22 15:26
- 更新:2026-04-30 16:26
- 阅读:229
产品分类: uniapp/App
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: macOS Monterey 12.7.5
HBuilderX类型: 正式
HBuilderX版本号: 4.45
手机系统: iOS
手机系统版本号: iOS 18
手机厂商: 苹果
手机机型: iPhone iPad
页面类型: nvue
vue版本: vue3
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
uni.requestVirtualPayment({
apple: {
productId: this.productId,
appAccountToken: onceStr,
quantity: 1
},
success: function(res) {
//经过开发者server验证成功后请结束该交易
const virtualPaymentManager = uni.getVirtualPaymentManager()
virtualPaymentManager.finishTransaction({
transaction: res.apple,
success: (r) => {
// console.log("关单成功, 该productId= " + res.apple?.productId)
uni.hideLoading()
_this.isShowName = true;
uni.showToast({
icon: "none",
title: "pay success"
})
},
fail: (e) => {
// console.log("关单失败, 该productId= " + res.apple?.productId)
uni.hideLoading()
uni.showToast({
icon: "none",
title: "Payment finish transaction failed,"+e.errMsg+","+e.errSubject
})
}
})
},
fail: function(e) {
uni.hideLoading()
// console.log("购买失败:errSubject= " + e.errSubject + ", errCode= " + e.errCode + ", errMsg= " + e.errMsg)
uni.showToast({
icon: "none",
title: "Payment failed,"+e.errMsg+","+e.errSubject
})
}
})
uni.requestVirtualPayment({
apple: {
productId: this.productId,
appAccountToken: onceStr,
quantity: 1
},
success: function(res) {
//经过开发者server验证成功后请结束该交易
const virtualPaymentManager = uni.getVirtualPaymentManager()
virtualPaymentManager.finishTransaction({
transaction: res.apple,
success: (r) => {
// console.log("关单成功, 该productId= " + res.apple?.productId)
uni.hideLoading()
_this.isShowName = true;
uni.showToast({
icon: "none",
title: "pay success"
})
},
fail: (e) => {
// console.log("关单失败, 该productId= " + res.apple?.productId)
uni.hideLoading()
uni.showToast({
icon: "none",
title: "Payment finish transaction failed,"+e.errMsg+","+e.errSubject
})
}
})
},
fail: function(e) {
uni.hideLoading()
// console.log("购买失败:errSubject= " + e.errSubject + ", errCode= " + e.errCode + ", errMsg= " + e.errMsg)
uni.showToast({
icon: "none",
title: "Payment failed,"+e.errMsg+","+e.errSubject
})
}
}) 预期结果:
uni.requestVirtualPayment({
apple: {
productId: this.productId,
appAccountToken: onceStr,
quantity: 1
},
success: function(res) {
//经过开发者server验证成功后请结束该交易
const virtualPaymentManager = uni.getVirtualPaymentManager()
virtualPaymentManager.finishTransaction({
transaction: res.apple,
success: (r) => {
// console.log("关单成功, 该productId= " + res.apple?.productId)
uni.hideLoading()
_this.isShowName = true;
uni.showToast({
icon: "none",
title: "pay success"
})
},
fail: (e) => {
// console.log("关单失败, 该productId= " + res.apple?.productId)
uni.hideLoading()
uni.showToast({
icon: "none",
title: "Payment finish transaction failed,"+e.errMsg+","+e.errSubject
})
}
})
},
fail: function(e) {
uni.hideLoading()
// console.log("购买失败:errSubject= " + e.errSubject + ", errCode= " + e.errCode + ", errMsg= " + e.errMsg)
uni.showToast({
icon: "none",
title: "Payment failed,"+e.errMsg+","+e.errSubject
})
}
})
uni.requestVirtualPayment({
apple: {
productId: this.productId,
appAccountToken: onceStr,
quantity: 1
},
success: function(res) {
//经过开发者server验证成功后请结束该交易
const virtualPaymentManager = uni.getVirtualPaymentManager()
virtualPaymentManager.finishTransaction({
transaction: res.apple,
success: (r) => {
// console.log("关单成功, 该productId= " + res.apple?.productId)
uni.hideLoading()
_this.isShowName = true;
uni.showToast({
icon: "none",
title: "pay success"
})
},
fail: (e) => {
// console.log("关单失败, 该productId= " + res.apple?.productId)
uni.hideLoading()
uni.showToast({
icon: "none",
title: "Payment finish transaction failed,"+e.errMsg+","+e.errSubject
})
}
})
},
fail: function(e) {
uni.hideLoading()
// console.log("购买失败:errSubject= " + e.errSubject + ", errCode= " + e.errCode + ", errMsg= " + e.errMsg)
uni.showToast({
icon: "none",
title: "Payment failed,"+e.errMsg+","+e.errSubject
})
}
}) 实际结果:
uni.requestVirtualPayment({
apple: {
productId: this.productId,
appAccountToken: onceStr,
quantity: 1
},
success: function(res) {
//经过开发者server验证成功后请结束该交易
const virtualPaymentManager = uni.getVirtualPaymentManager()
virtualPaymentManager.finishTransaction({
transaction: res.apple,
success: (r) => {
// console.log("关单成功, 该productId= " + res.apple?.productId)
uni.hideLoading()
_this.isShowName = true;
uni.showToast({
icon: "none",
title: "pay success"
})
},
fail: (e) => {
// console.log("关单失败, 该productId= " + res.apple?.productId)
uni.hideLoading()
uni.showToast({
icon: "none",
title: "Payment finish transaction failed,"+e.errMsg+","+e.errSubject
})
}
})
},
fail: function(e) {
uni.hideLoading()
// console.log("购买失败:errSubject= " + e.errSubject + ", errCode= " + e.errCode + ", errMsg= " + e.errMsg)
uni.showToast({
icon: "none",
title: "Payment failed,"+e.errMsg+","+e.errSubject
})
}
})
uni.requestVirtualPayment({
apple: {
productId: this.productId,
appAccountToken: onceStr,
quantity: 1
},
success: function(res) {
//经过开发者server验证成功后请结束该交易
const virtualPaymentManager = uni.getVirtualPaymentManager()
virtualPaymentManager.finishTransaction({
transaction: res.apple,
success: (r) => {
// console.log("关单成功, 该productId= " + res.apple?.productId)
uni.hideLoading()
_this.isShowName = true;
uni.showToast({
icon: "none",
title: "pay success"
})
},
fail: (e) => {
// console.log("关单失败, 该productId= " + res.apple?.productId)
uni.hideLoading()
uni.showToast({
icon: "none",
title: "Payment finish transaction failed,"+e.errMsg+","+e.errSubject
})
}
})
},
fail: function(e) {
uni.hideLoading()
// console.log("购买失败:errSubject= " + e.errSubject + ", errCode= " + e.errCode + ", errMsg= " + e.errMsg)
uni.showToast({
icon: "none",
title: "Payment failed,"+e.errMsg+","+e.errSubject
})
}
}) bug描述:
uni-app x 中,调用 iOS 虚拟支付,美国appstore 审核员总是 Payment failed, 我本地的sandbox 环境可以支付
uni.requestVirtualPayment({
apple: {
productId: this.productId,
appAccountToken: onceStr,
quantity: 1
},
success: function(res) {
//经过开发者server验证成功后请结束该交易
const virtualPaymentManager = uni.getVirtualPaymentManager()
virtualPaymentManager.finishTransaction({
transaction: res.apple,
success: (r) => {
// console.log("关单成功, 该productId= " + res.apple?.productId)
uni.hideLoading()
_this.isShowName = true;
uni.showToast({
icon: "none",
title: "pay success"
})
},
fail: (e) => {
// console.log("关单失败, 该productId= " + res.apple?.productId)
uni.hideLoading()
uni.showToast({
icon: "none",
title: "Payment finish transaction failed,"+e.errMsg+","+e.errSubject
})
}
})
},
fail: function(e) {
uni.hideLoading()
// console.log("购买失败:errSubject= " + e.errSubject + ", errCode= " + e.errCode + ", errMsg= " + e.errMsg)
uni.showToast({
icon: "none",
title: "Payment failed,"+e.errMsg+","+e.errSubject
})
}
})
3 个回复
杨川 (作者) - 小小开发者
只得到了这个错误信息,Payment failed,Other payment errors., uni-RequestVirtualPayment
杨川 (作者) - 小小开发者
地区:美国,appstore审核人员那边的错误信息:Payment failed,Other payment errors., uni-RequestVirtualPayment
Yorry - 酷炫又逗比的程序员
你是不是在支付成功的回调里(uni-pay-co/notify/appleiap.js) 里又校验了一遍支付金额。
比如你道具售价是人民币 CNY 6元(即 total_fee为 600),回调里校验了total_fee>=600,国内支付测试正常。
但对应的美元售价就是 USD 1元(即 total_fee为100),仍然验证 total_fee>=600 的话必然就失败了。
我就是遇到的这个问题,后来把 total_fee 校验删掉就好了