在苹果服务器上验证时,SKPaymentTransaction始终获得第二次购买transactionIdentifier失败

时间:2019-04-22 16:59:04

标签: swift in-app-purchase skpaymenttransaction

我们已经订阅了某些产品,第一次是商品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。

0 个答案:

没有答案