gpt4 book ai didi

ios - 在什么情况下 SKPaymentTransaction.transactionIdentifier 与已验证收据的 transaction_id 相同?

转载 作者:行者123 更新时间:2023-11-29 05:12:26 25 4
gpt4 key购买 nike

SKPaymentTransaction.transactionIdentifier 的文档备注:

This value has the same format as the transaction’s transaction_id in the receipt; however, the values may not be the same.

以及 transaction_id 的文档备注:

This value has the same format as the transaction’s transactionIdentifier property; however, the values may not be the same.

You can use this value to:

• Manage subscribers in your account database. Store the transaction_id, original_transaction_id, and product_id for each transaction, as a best practice to store transaction records for each customer. App Store generates a new value for transaction_id every time the subscription automatically renews or is restored on a new device.

• Differentiate a purchase transaction from a restore or a renewal transaction. In a purchase transaction, the transaction_id always matches the original_transaction_id. For subscriptions, it indicates the first subscription purchase. For a restore or renewal, the transaction_id does not match the original_transaction_id. If a user restores or renews the same purchase multiple times, each restore or renewal has a different transaction_id.

还要注意Receipt Validation Programming Guide (来自文档文件)交易标识符下的状态:

This value corresponds to the transaction’s transactionIdentifier property.


考虑到这一点,我的问题是:SKPaymentTransaction.transactionIdentifier 何时与已验证收据的 transaction_id 值相同,或者何时不是?

在我们的应用中,我们仅处理消费品应用内购买,不支持订阅。在这种情况下,这两个值相同吗?我之所以这么问,是因为我需要能够在服务器端记录购买情况以及有关购买它的用户的信息。请参阅下面的过程和它所呈现的问题的解释。

假设用户购买了消费品,并且记录该交易的请求失败,因为我们的服务器已关闭,因此我们不调用 finishTransaction:。现在,假设该人注销并登录到不同的用户帐户并购买了另一种消费品,但我们再次无法记录它。收据中现在有两种消耗品。当他们启动应用程序时,接下来会使用 transactions 数组中的两项来调用 paymentQueue(_:updatedTransactions:) ,以通知我们有已购买交易需要完成。我们需要将收据提交到我们的服务器来记录交易,但我们还需要随每笔交易发送一些附加信息,例如购买它的用户 ID。这意味着我需要将此信息与关联的 transactionIdentifier 一起保存在磁盘上,以便稍后获取该数据。我可以将一组用户 ID 和收据发送到服务器。但是后端如何知道收据中的哪笔交易与数组中的哪个用户 ID 匹配呢?我不相信 in_app 数组保证以任何特定方式排序,并且可能与提供给 paymentQueue(_:更新的交易:)。那么,当需要记录多笔交易时,我们如何正确链接它们,以便将购买应用于正确的用户帐户服务器端?在这种情况下,应用内可用的 transactionIdentifier 是否保证与已验证收据中的 transaction_id 相同?

最佳答案

在测试中,我们确定 transactionIdentifier 与经验证的消耗品购买收据中的交易 transaction_id 值相同。

但是,我们不愿意相信这种情况,因为文档中的注释指出它可能不是相同的值。因此,我们使用 transaction. payment.productIdentifiertransaction.transactionDate 的组合来唯一标识交易,即 documented与收据中的original_purchase_date_ms相对应。这允许后端在应用提交的信息的收据中找到正确的交易。

关于ios - 在什么情况下 SKPaymentTransaction.transactionIdentifier 与已验证收据的 transaction_id 相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59556804/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com