消耗品在应用程序购买验证

Consumable in app purchases validation

我们最近推出了只有消耗品的应用内购买的应用程序。我们注意到很多虚假购买 - 带有无效收据的购买以及 'valid' 收据,但来自苹果的验证响应中的 "in_app" 数组是空数组。我需要知道用户如何形成这样的 'valid' 收据?是应用程序下载的收据而不是应用程序内购买的收据还是什么?我现在进行以下检查以进行验证。提取来自 Apple 的 json 响应中的 "in_app" 字段,如果它不为空,则检查 product_id 是否匹配。我需要知道这个检查是否足够或者他们是一个更好的傻瓜检查。

所有应用都有收据。那些购买了 IAP 的应用程序在其收据中有一个 in_app 字段。您的用户将虚假呼叫推送到他们的 updatedTransaction 方法中,您正在获取他们的收据(没有 IAP,因为他们没有购买)并将其发送到您的服务器。其他用户可能会从某个地方交换一些收据(例如,30 个小偷中的一个进行购买并提取有效收据并将其发送给他们的 29 个小偷)。如果他们将该收据粘贴到他们的设备中,然后将调用推送到 updatedTransactions,那么您的服务器将获得他们现在有效但重复的收据。您的服务器需要检查 *** 收据日期并发现它比最近的日期旧,或者甚至比您需要共同发送到您的服务器的 paymentRequest 更旧。 (最好在设备上解码 - 更安全)

*** 您曾经能够检查 transaction_id 是否有重复项 transaction_id。不幸的是,您不能再这样做了,因为 restoreCompletedTransaction returns 与原始购买相同 transaction_id。我已经把这件事告诉苹果了,他们不理我。

请参阅此应用内购买常见问题解答My app validates its receipt with the App Store via paymentQueue:updatedTransactions: after a successful purchase. However, the returned receipt contains an empty in_app array rather than the expected products.

An empty in_app array indicates that the App Store has not recorded any transactions for the user yet. It may be that the application receipt has not yet been updated. When this happens, your app can inform the user that the receipt does not appear current and ask whether to refresh it.

Information about consumable products is added to the receipt when they are paid for and remains in the receipt until you finish the transaction. After you finish the transaction, this information is removed the next time the receipt is updated. Thus resulting into an empty in_app array if your app only sells consumable products.