已完成的沙盒交易已添加到付款队列

时间:2019-03-02 00:39:10

标签: ios in-app-purchase storekit

我在沙盒环境中遇到一个非常特殊的问题。

购买订阅时,我会收到更新的SKPaymentTransactionStatePurchasing交易,然后是SKPaymentTransactionStatePurchased。至此,我完成了交易。

但是,在后台运行该应用程序之后,我收到了44 SKPaymentTransactionStatePurchased个交易。我完成了所有这些交易,但是在下一个后台/前景中,我收到的交易完全相同(如交易日期/时间所示)。

// make purchase
[TransactionObserver] Received updated transactions: 1
transaction state: 0
[TransactionObserver] Received updated transactions: 1
transaction state: 1

// background then foreground
[TransactionObserver] Received updated transactions: 44
transaction state: 1
transaction state: 1
transaction state: 1
...
transaction state: 1
transaction state: 1
transaction state: 1

值得注意的是,我的沙盒用户已经有一定年龄了,我过去可能曾经购买过这些产品,但是每次尝试此“实验”时我都完成了这些购买,但它们仍然会出现。

我已将我的付款队列委托方法简化为以下内容:

 - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray<SKPaymentTransaction *> *)transactions {
    NSLog(@"[TransactionObserver] Received updated transactions: %ld", (long)transactions.count);

    for (SKPaymentTransaction *transaction in transactions) {
        NSLog(@"transaction state: %ld", (long)transaction.transactionState);

        if (transaction.transactionState != SKPaymentTransactionStatePurchasing) {
            [queue finishTransaction:transaction];
        }
    }
}

您知道这是怎么回事吗,每次完成新购买后后台/前台运行该应用程序时,让这些完成的交易重新出现在我的付款队列中,这是我做错了什么?

0 个答案:

没有答案