我们已经订阅了某些产品,第一次是商品transactionIdentifier成功,在尝试第二次购买后,我们仅收到了无效的收据错误。
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions
transactions: [SKPaymentTransaction]) {
for transaction:AnyObject in transactions {
if let trans = transaction as? SKPaymentTransaction {
switch trans.transactionState {
case .purchased:
print("purchased")
print(transaction.transactionIdentifier)
self.deliverProduct(product: transaction.payment.productIdentifier, transactionID: transaction.transactionIdentifier ?? "")
SKPaymentQueue.default().finishTransaction(transaction as! SKPaymentTransaction)
purchaseStatusBlock?(.purchased)
break
case .failed:
print("failed")
SKPaymentQueue.default().finishTransaction(transaction as! SKPaymentTransaction)
break
case .restored:
print(transaction.transactionIdentifier)
self.deliverProduct(product: transaction.payment.productIdentifier, transactionID: transaction.transactionIdentifier ?? "")
SKPaymentQueue.default().finishTransaction(transaction as! SKPaymentTransaction)
break
default:
break
}}}
}
此处transactionID首次正确返回。但第二次transactionID仅返回false。