iOS应用内购买收据验证-如果服务器关闭,该怎么办? [英] iOS in-app purchase receipt validation - What happens if server is down?

查看:41
本文介绍了iOS应用内购买收据验证-如果服务器关闭,该怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设可以将一个简单的待办事项列表应用程序连接到Web服务帐户.该Web服务允许用户在线编辑他的待办事项列表,并在不同设备上同步数据.

Assume a simple ToDo-List app can be connected to a web service account. The web services allows the user to edit his ToDo lists online and to sync the data accross different devices.

现在,我想在iOS上使用消耗品的应用内购买商品,以便用户购买不同的按使用付费功能.例如,"100条提醒推送通知"可能是一个IAP项目...

Now I would like consumable in-app purchase items to the iOS that allows the user to buy different pay-per-use features. For example "100 reminder push notifications" could be an IAP item...

让Apple文档流通时,购买将遵循以下步骤:

Flowing the Apple docs the purchase would follow these steps:

  • 用户开始在应用内购买
  • 用户向App Store进行身份验证并授权购买
  • App Store完成购买(用户付费)<-从App Store的角度来看购买完成
  • 有关购买的通知应用程序(StoreKit,PaymentQueue,交易等)
  • 应用程序将收据发送到服务器以进行验证.
  • 服务器验证收据并向用户Web帐户添加"100条提醒推送通知".<-从应用程序的角度来看完成购买

问题:如果服务器关闭,购买会发生什么?

即使实际的购买结果(向用户帐户添加提醒)不会存储在服务器上,也不会存储在设备上,即使服务器关闭或没有Internet连接,收据验证和购买完成也将失败.

Even if the actual purchase result (add reminders to user account) would not be stored on the server but locally on the device, the receipt validation and purchase completion would fail if the server is down or if there is no internet connection.

但是,从App Store的角度来看,一旦用户授权付款,购买就完成了.该应用程序确实能够完成购买并为用户带来任何收益,而不会打扰App Store.

However, from the point of view of the App Store the purchase is complete once the user authorized the payment. Wether the app really completed the purchase and delivers any benefit to the users, does not bother the App Store.

当然,用户可能会抱怨缺少购买的福利,但是如何处理?

Of course the user could complain about the missing delivery of the purchased benefit, but how could this be handled?

使用非消耗性IAP 时,用户可以简单地恢复以前的购买,但是使用消耗性IAP 是不可能的,是吗?

When working with non-consumable IAPs the user could simple restore the previous purchase, but this is not possible with consumable IAPs, is it?

在无法恢复购买表单的情况下,App Store唯一的解决方案是将收据存储在本地,并为用户提供以后进行验证的选项.这是正确"的解决方案,还是还有其他方法可以解决?

Without being able to restore the purchase form the App Store the only solution would be to store the receipt locally and offer the users the option to validate it later. Is this the "correct" solution or is there another way to handle this?

推荐答案

您的序列在第3点不正确.

Your sequence is incorrect at point 3.

您的应用收到更新后的交易,然后启动验证和持久购买所需的任何逻辑.您的应用完成此操作后,它将完成付款队列上的交易.届时,从tye App Store的角度看,购买已完成.

Your app receives the updated transaction and then initiates whatever logic is required to validate and persist the purchase. Once your app has done this, it completes the transaction on the payment queue. At that point the purchase is complete from tye App Store point of view.

如果服务器已关闭并且无法验证收据,则应向用户提供某种形式的错误,并可能重试验证.

If your server is down and you are unable to validate the receipt, you should provide some form of error to the user and perhaps re-try the validation.

该交易将保持待处理状态,并在下次启动您的应用程序时重新呈现给您的支付队列观察者.这就是为什么您的应用在启动时首先要做的就是注册付款队列观察器对象.

The transaction will be held in a pending state and will be re-presented to your payment queue observer when your app is next launched. This is why on of the first things your app should do on launch is register a payment queue observer object.

当您最终能够完成收据验证并继续购买时,您就可以在付款队列上完成交易了.

When you are finally able to complete the receipt validation and persist the purchase you complete the transaction on the payment queue.

这篇关于iOS应用内购买收据验证-如果服务器关闭,该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆