简体   繁体   English

自动续订,确定初始购买

[英]Auto-renewable subscription, determine initial purchase

In the updatedtransactions method when the transactionState reflects the purchased state, I'd like to determine whether it's a new purchase or a renewal. 在transactionState反映已购买状态时,在updatedtransactions方法中,我想确定它是新购买还是续签。 Is this possible from the data? 这可能来自数据吗? I couldn't find anything. 我什么都找不到。 I did see the originalTransaction but it says this is only defined for a restore, not a purchase. 我确实看到了originalTransaction,但是它说这仅是为还原而不是购买而定义的。 I could of course keep a flag in the app, but unfortunately I don't get information about when a subscription is cancelled. 我当然可以在应用程序中保留一个标志,但是不幸的是,我没有获得有关取消订阅的信息。 I could keep checking after each period whether it's renewed but there might be a slight gap there and this will get messy. 我可以在每个周期后继续检查是否已更新,但是那里可能会有细微的差距,这会变得混乱。

Thanks! 谢谢!

Verify the receipt as in http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/RenewableSubscriptions/RenewableSubscriptions.html . 按照http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/RenewableSubscriptions/RenewableSubscriptions.html中的方法验证收据。 You get the original_purcahse_date_ms. 您将获得original_purcahse_date_ms。 Compare it to the purchase_date_ms... voila! 比较它与purchase_date_ms ...瞧!

After your transactionState becomes purchasedState, you will want to verify the receipt as laid out in " Verifying an Auto-Renewable Subscription Receipt ". 当您的transactionState变为purchaseState之后,您将要按照“ 验证自动续订订阅收据 ”中的说明来验证收据

You'll query the store and get a JSON response, which includes a receipt field - in this receipt is original_purchase_date. 您将查询商店并获得JSON响应,其中包括一个收据字段-该收据中的内容为original_purchase_date。 From what I understand, this is not the same as the transactionDate of the originalTransaction you found in your SKPaymentTransaction. 据我了解,这与您在SKPaymentTransaction中找到的originalTransaction的transactionDate不同。 The documentation says: 该文件说:

This holds the purchase date for the initial purchase; 这保留了首次购买的购买日期; it represents the start date for the subscription. 它代表订阅的开始日期。

If that query is also returning the very first subscription date, another approach would be to store this information on your own server, and validate the receipts there (mentioned at the very end of the section linked above). 如果该查询还返回了第一个订阅日期,则另一种方法是将该信息存储在您自己的服务器上,并在该服务器上验证收据(在以上链接的最后部分提到)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM