通知取消应用内购买的自动续订 [英] Notification of cancellation of auto-renewal for an in-app purchase
问题描述
我正在开发一个iPhone应用程序,我想实现应用程序内购买的自动更新的新模式。我能够成功地实现交易,甚至可以订阅该应用程序,但如果用户取消自动续订订阅如果怎么办?
I am working on an iPhone app and I want to implement the new model of auto-renewal for in-app purchases. I am able to successfully implement transactions and can even get subscribed to the app, but what if the user cancels the auto renewal subscription?
我如何知道它已被取消,因此无法继续允许访问(一旦过期)?
How will I be able to know that it has been cancelled, and so not continue to allow access (once expired)?
推荐答案
您可以通过向Apple的服务器发送收据验证来查找用户订阅的到期日期。请查看 In-App Purchase Programming Guide 。
You can find the expiration date of a user's subscription by sending a receipt verification to Apple's servers. Check out figure 1-3 on the In-App Purchase Programming Guide.
基本上步骤是:
- 在设备上,获取应用内购买的交易收据。您在交易过程中保存的或通过调用
[SKPaymentQueue restoreCompletedTransactions]
。 - 将该收据发送到您的服务器。 (这比尝试直接从应用程序对苹果服务器进行收据验证更为可取,因为这将要求您在设备上存储共享密钥。)
- 将收据发送到Apple的服务器,并在响应中查找名为
expires_date
的密钥(表示为自1970年1月1日以来的毫秒秒)。 -
- On the device, get a transaction receipt for an in-app-purchase. Either one you've saved during a transaction or by calling
[SKPaymentQueue restoreCompletedTransactions]
. - Send that receipt to your server. (This is preferred over trying to do a receipt verification with Apple's servers directly from the app, since that would require you to store your shared secret on the device.)
- Send the receipt to Apple's servers from your server, and in the response look for a key named
expires_date
(expressed in milli seconds since Jan 1, 1970 GMT).
我使用本指南帮助我在服务器端:使用PHP和cURL验证App App Purchase的Apple App Store收据。
I used this guide to help me on the server side: Verifying Apple App Store Receipts For In App Purchases With PHP and cURL.
无法确定用户是否已启用或关闭自动续订。 Apple不允许您访问此信息。唯一的方法是等到有效日期过期而没有续订。
There is no way to determine if the user has auto-renewal turned on or off. Apple doesn't give you access to this information. The only way is to wait until the expiration date passes without a renewal.
这篇关于通知取消应用内购买的自动续订的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!