使用 IOS 应用内购买事件通知服务器(更新、取消等)

Notify server with IOS in-app purchase events (renewed,cancelled..etc)

我在我的应用程序中使用自动循环订阅,如果从 iOS 开始循环失败,我需要更改订阅状态。

我正在关注这个documentation,但是有几件事我还是不清楚:

以下是我带用户订阅的步骤:

  1. 请用户登录。如果他们不登录,则无法订阅。
  2. 将应用收据发送到我的服务器并将其存储在那里。如果失败,他们将无法订阅。这需要它来验证随时从服务器获取 latest_receipt 信息。
  3. 用户通过 iTunes 订阅。
  4. 通过应用商店验证他们的收据并检查 latest_receipt 以确保他们已订阅。 (这是在服务器端完成的)
  5. 定期重复第 4 步以确保他们仍处于订阅状态

所以回答你的问题:

What if my server missed the post data from iOS?

因为我在用户订阅之前就收到了应用收据,所以我可以随时直接从我的服务器上使用 iTunes 检查他们的订阅状态。

How do I know if the subscription got renewed?

由于您的服务器上有用户收据,您可以使用它从苹果获取最新的收据并检查订阅的当前状态。这是你如何做的 Validating Receipts With the App Store

How do I link my app user memberId (unique id) to the transaction?

您可以使用收据中的 "Original Transaction Identifier" 作为唯一 ID。对于为特定订阅生成的所有收据,此值相同

What is the difference between latest_receipt form iOS post data(server to server notification) and bundle receipt url after purchase?

当您将收据发送到应用商店进行验证时,它将 return 已发送收据的 JSON 表示,可以在 "receipt" 中找到场地。如果您的收据包含订阅,您将获得 "latest_receipt" 和 "latest_receipt_info" 字段。这些字段在检查 auto-renewable 订阅当前是否处于活动状态时很有用。如果捆绑收据是最新的,那么 "receipt" 和 "latest_receipt" 将是相同的。