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
- 更新:2025-01-22 20:15
- 阅读:68
产品分类: 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
})
}
})
2 个回复
杨川 (作者) - 小小开发者
只得到了这个错误信息,Payment failed,Other payment errors., uni-RequestVirtualPayment
杨川 (作者) - 小小开发者
地区:美国,appstore审核人员那边的错误信息:Payment failed,Other payment errors., uni-RequestVirtualPayment