<SKPaymentQueue: 0x281194d90>: Payment completed with error: Error Domain=ASDErrorDomain Code=500 "Unhandled exception"
<SKPaymentQueue: 0x281194d90>: Payment completed with error: Error Domain=ASDErrorDomain Code=500 "Unhandled exception"
我正在尝试在我的应用程序中进行应用程序内购买,但出于某种原因,当我输入我的 Apple ID 和密码时,我在日志中收到错误消息,并且 UI 上没有任何反应。我需要在试飞或类似的情况下上传我的应用程序以便能够从我的应用程序购买商品吗?我已经添加了付款方式和税务信息。
我只是从我的角度调用购买产品方法。
错误:
2021-09-14 19:06:01.857244+0300 iGrow Goals[697:72415] <SKPaymentQueue: 0x2802709f0>: Payment completed with error: Error Domain=ASDErrorDomain Code=500 "Unhandled exception" UserInfo={NSUnderlyingError=0x280ec2610 {Error Domain=AMSErrorDomain Code=100 "Authentication Failed" UserInfo={NSLocalizedFailureReason=The verify credentials call failed., NSLocalizedDescription=Authentication Failed, NSUnderlyingError=0x280ec2700 {Error Domain=AMSServerErrorDomain Code=-5000 "The operation couldn’t be completed. (AMSServerErrorDomain error -5000.)" UserInfo={NSLocalizedDescription=The operation couldn’t be completed. (AMSServerErrorDomain error -5000.)}}}}, NSLocalizedFailureReason=An unknown error occurred, NSLocalizedDescription=Unhandled exception}
StoreManager.swift:
//
// StoreManager.swift
// iGrow Goals
//
// Created by George Sepetadelis on 30/8/21.
//
import Foundation
import StoreKit
class StoreManager: NSObject, ObservableObject, SKProductsRequestDelegate {
@Published var myProducts = [SKProduct]()
var request: SKProductsRequest!
@Published var transactionState: SKPaymentTransactionState?
func enablePremiumPlan() {
}
func purchaseProduct(product: SKProduct) {
if SKPaymentQueue.canMakePayments() {
let payment = SKPayment(product: product)
SKPaymentQueue.default().add(payment)
} else {
print("User can't make payment.")
}
}
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
for transaction in transactions {
switch transaction.transactionState {
case .purchasing:
transactionState = .purchasing
case .purchased:
UserDefaults.standard.setValue(true, forKey: transaction.payment.productIdentifier)
queue.finishTransaction(transaction)
print("payment success")
transactionState = .purchased
enablePremiumPlan()
case .restored:
UserDefaults.standard.setValue(true, forKey: transaction.payment.productIdentifier)
queue.finishTransaction(transaction)
transactionState = .restored
enablePremiumPlan()
case .failed, .deferred:
queue.finishTransaction(transaction)
transactionState = .failed
print("payment failed")
default:
queue.finishTransaction(transaction)
print("default")
}
}
}
func getProducts(productIDs: [String]) {
print("Start requesting products ...")
let request = SKProductsRequest(productIdentifiers: Set(productIDs))
request.delegate = self
request.start()
}
func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
print("Did receive response")
if !response.products.isEmpty {
for fetchedProduct in response.products {
DispatchQueue.main.async {
self.myProducts.append(fetchedProduct)
}
}
}
for invalidIdentifier in response.invalidProductIdentifiers {
print("Invalid identifiers found: \(invalidIdentifier)")
}
}
func request(_ request: SKRequest, didFailWithError error: Error) {
print("Request did fail: \(error)")
}
}
直接从 Xcode 进行应用内购买测试时,请尝试使用沙盒帐户。
您的常规帐户将在 Test Flight 和 App Store 中使用。
我正在尝试在我的应用程序中进行应用程序内购买,但出于某种原因,当我输入我的 Apple ID 和密码时,我在日志中收到错误消息,并且 UI 上没有任何反应。我需要在试飞或类似的情况下上传我的应用程序以便能够从我的应用程序购买商品吗?我已经添加了付款方式和税务信息。
我只是从我的角度调用购买产品方法。
错误:
2021-09-14 19:06:01.857244+0300 iGrow Goals[697:72415] <SKPaymentQueue: 0x2802709f0>: Payment completed with error: Error Domain=ASDErrorDomain Code=500 "Unhandled exception" UserInfo={NSUnderlyingError=0x280ec2610 {Error Domain=AMSErrorDomain Code=100 "Authentication Failed" UserInfo={NSLocalizedFailureReason=The verify credentials call failed., NSLocalizedDescription=Authentication Failed, NSUnderlyingError=0x280ec2700 {Error Domain=AMSServerErrorDomain Code=-5000 "The operation couldn’t be completed. (AMSServerErrorDomain error -5000.)" UserInfo={NSLocalizedDescription=The operation couldn’t be completed. (AMSServerErrorDomain error -5000.)}}}}, NSLocalizedFailureReason=An unknown error occurred, NSLocalizedDescription=Unhandled exception}
StoreManager.swift:
//
// StoreManager.swift
// iGrow Goals
//
// Created by George Sepetadelis on 30/8/21.
//
import Foundation
import StoreKit
class StoreManager: NSObject, ObservableObject, SKProductsRequestDelegate {
@Published var myProducts = [SKProduct]()
var request: SKProductsRequest!
@Published var transactionState: SKPaymentTransactionState?
func enablePremiumPlan() {
}
func purchaseProduct(product: SKProduct) {
if SKPaymentQueue.canMakePayments() {
let payment = SKPayment(product: product)
SKPaymentQueue.default().add(payment)
} else {
print("User can't make payment.")
}
}
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
for transaction in transactions {
switch transaction.transactionState {
case .purchasing:
transactionState = .purchasing
case .purchased:
UserDefaults.standard.setValue(true, forKey: transaction.payment.productIdentifier)
queue.finishTransaction(transaction)
print("payment success")
transactionState = .purchased
enablePremiumPlan()
case .restored:
UserDefaults.standard.setValue(true, forKey: transaction.payment.productIdentifier)
queue.finishTransaction(transaction)
transactionState = .restored
enablePremiumPlan()
case .failed, .deferred:
queue.finishTransaction(transaction)
transactionState = .failed
print("payment failed")
default:
queue.finishTransaction(transaction)
print("default")
}
}
}
func getProducts(productIDs: [String]) {
print("Start requesting products ...")
let request = SKProductsRequest(productIdentifiers: Set(productIDs))
request.delegate = self
request.start()
}
func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
print("Did receive response")
if !response.products.isEmpty {
for fetchedProduct in response.products {
DispatchQueue.main.async {
self.myProducts.append(fetchedProduct)
}
}
}
for invalidIdentifier in response.invalidProductIdentifiers {
print("Invalid identifiers found: \(invalidIdentifier)")
}
}
func request(_ request: SKRequest, didFailWithError error: Error) {
print("Request did fail: \(error)")
}
}
直接从 Xcode 进行应用内购买测试时,请尝试使用沙盒帐户。
您的常规帐户将在 Test Flight 和 App Store 中使用。