ios 应用内购买:SKPaymentTransactionStateRestored 何时以及为何作为交易状态发回?

发布于 2024-12-02 23:41:29 字数 100 浏览 1 评论 0原文

iOS 应用内购买:SKPaymentTransactionStateRestored 何时以及为何作为交易状态发回?

这与定期订阅计划有关吗?

iOS In-App purchases: When and why does SKPaymentTransactionStateRestored get sent back as status of a transaction?

Does it related to having a recurring subscription plan?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

转角预定愛 2024-12-09 23:41:29

当您通过向 SKPaymentQueue 发送 restoreCompletedTransactions 消息来恢复用户的购买时,您会收到 SKPaymentTransactionStateRestored 交易,而不是 SKPaymentTransactionStatePurchased 交易>。

You get SKPaymentTransactionStateRestored transactions instead of SKPaymentTransactionStatePurchased transactions when you are restoring the user's purchases by sending a restoreCompletedTransactions message to the SKPaymentQueue.

触ぅ动初心 2024-12-09 23:41:29

一般规则是处理两个回调:购买和恢复购买。

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction *transaction in transactions)
    {
    switch (transaction.transactionState)
        {
        case SKPaymentTransactionStatePurchased:
            [self completeTransaction:transaction];
            break;

        case SKPaymentTransactionStateFailed:
            [self failedTransaction:transaction];
            break;

        case SKPaymentTransactionStateRestored:
            [self restoreTransaction:transaction];

        default:
            break;
        }
    }
}

- (void) completeTransaction: (SKPaymentTransaction *)transaction
{
[self recordTransaction: transaction content:transaction.payment.productIdentifier];

[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}

- (void) restoreTransaction: (SKPaymentTransaction *)transaction
{
[self recordTransaction: transaction content:transaction.originalTransaction.payment.productIdentifier];

[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}

General rule is to process both callbacks: for purchase and restore purchase.

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction *transaction in transactions)
    {
    switch (transaction.transactionState)
        {
        case SKPaymentTransactionStatePurchased:
            [self completeTransaction:transaction];
            break;

        case SKPaymentTransactionStateFailed:
            [self failedTransaction:transaction];
            break;

        case SKPaymentTransactionStateRestored:
            [self restoreTransaction:transaction];

        default:
            break;
        }
    }
}

- (void) completeTransaction: (SKPaymentTransaction *)transaction
{
[self recordTransaction: transaction content:transaction.payment.productIdentifier];

[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}

- (void) restoreTransaction: (SKPaymentTransaction *)transaction
{
[self recordTransaction: transaction content:transaction.originalTransaction.payment.productIdentifier];

[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文