19

We have issues fully understanding the receipt validation flow in iOS.

Here is what we currently do (in development):

In applicationDidFinishLaunching and in applicationWillEnterForeground we validate the receipt on the server side, if there is no receipt or the receipt is invalid, we try to refresh the receipt and revalidate it.

Here are some issues/questions:

  1. What are the cases where there is no receipt available on the device ?

  2. Should we always issue a receipt refresh request when there is no receipt ?

  3. Why is this alert box sometimes shown on startup ? I understand this is shown on a receipt refresh request ?

Sign in required?

  1. When should a receipt verification happen ? We currently do it whenever a purchase is made to verify the purchase, is this correct usage ?
4

4 回答 4

13
  1. 在生产中,收据始终在设备上可用。在第一次安装后的测试中没有。因此,如果您想进行正确的测试,您必须恢复购买,即使该用户在测试环境中不存在购买。这是为什么?从应用商店下载的应用总是带有收据,即使它们是免费的。
  2. 取决于您要应用的业务逻辑。如果您每次使用启动应用程序时都要针对服务器验证收据,那么您当然需要收据。如果它不存在(但在生产中始终存在)或无效,您可以要求刷新或恢复,但据我记得,您应该始终先询问用户是否要这样做(可以是拒绝的原因)。恢复和刷新不是一回事。
  3. 这通常出现在购买/恢复/刷新中。但是,如果由于应用程序崩溃或您以某种方式在请求结束之前中断了调试而导致帐户有一些待处理的请求,您会对此感到厌烦。无法以编程方式刷新它们,只需登录直到它们停止。当然,这不会是一个有效的测试。
  4. 这取决于您和购买的类型。如果它是自动续订订阅,您可以根据服务器验证收据,然后将“结束日期”存储在客户端上,并在日期到期后再次检查。请注意,收据可能会很大,因为它也具有所有历史值。
于 2015-12-08T16:53:23.443 回答
2
  1. 正如张所说,如果没有购买或恢复,商店将没有收据
  2. 找到收据。如果未找到收据,则验证失败,您不应再次请求收据刷新。只有当您自己恢复过程时,您才应该重新索取收据。
  3. 当您尝试刷新收据时,这将始终显示(或者您将从不希望在 15 分钟内询问密码的设置中进行选择)。
  4. 是的。

有关更多信息,请查看此处: https ://www.objc.io/issues/17-security/receipt-validation/#about-validation

于 2015-12-08T16:36:15.907 回答
1

如果用户从 App Store 下载了应用程序——是的,收据始终存在。

但是,在沙盒中,如果您的应用是通过 Xcode 或 Testflight 安装的,那么在您进行购买或恢复之前不会有收据。

在我们的博客中查看有关收据验证的完整常见问题解答:

https://blog.apphud.com/receipt-validation/

于 2019-10-20T09:30:32.873 回答
0

1.没有购买/恢复发生。
2.Nope.See 1
4.Sure.对于消耗品,请记住在您的服务器上保存哈希,以抵御重放攻击。

于 2015-12-08T16:26:54.807 回答