iOS StoreKit 交易标识符与收据不匹配

标签 ios storekit receipt-validation

我在收到 SKPaymentTransactionStatePurchased 后使用收据来验证购买通知,除其他外,获取用户刚刚购买的订阅的到期日期。

为了正确识别收据中刚刚发生的交易,我通过 transaction.transactionIdentifier 匹配它。和 transaction_id .我遇到的问题是事务标识符永远不会匹配。

通过手动检查 purchase_date,我已经能够识别收据中的正确交易。和 product_id ,但 transaction_id与交易完全不同。

我也看过 transaction.originalTransaction.transactionIdentifieroriginal_transaction_id ,但这四个值似乎在任何时候都不匹配。

这里发生了什么?在沙盒中测试时有人遇到过类似的问题吗?该文档明确指出 transaction_id应该匹配 transactionIdentifier交易的属性(property)。这可能是一个错误吗?

编辑 1:
这是单次购买订阅(之前已过期)的不同交易标识符

transaction.transactionIdentifier = 1000000325087359
transaction.originalTransaction.transactionIdentifier = 1000000297785006
transaction_id = 1000000325087377
original_transaction_id = 1000000297785006

似乎原始交易标识符匹配(为什么他们会,这是一个新购买?),但其他两个不匹配。它们来自哪里,它们匹配什么?我不明白两者之间的关系及其重要性。

最佳答案

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.



除了记录的场景外,我不清楚这两个字段在哪些场景中相同或不同。

关于iOS StoreKit 交易标识符与收据不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45705069/

相关文章:

ios - 为什么 Google 在实现 (.m) 文件中进行 @class 前向声明?

ios - 将表格的刷新控制置于底部

ios - Swift IOS 13,IAP - "Cannot connect to Itunes Connect"

ios - 如何在iOS中使用RMStore获取自动续订订阅的通知

ios - 如何为 iOS 应用程序实现 iOS 自动续订订阅收据验证

ios - 自动布局错误 Unable to simultaneously satisfy constraints with UIScrollView

ios - Storyboard和 SVN 冲突

iphone - 是否可以在静态库中使用 StoreKit(应用内购买)?

IOS storekit 订阅免费试用无效

macos - 提交到 Mac 应用商店时出现收据验证错误