是否有办法从内容服务器检查 Apple Inapp 购买产品标识符是否有效?
我正在为一个 iOS 应用程序创建后端,其中包含应用内购买产品。 后端负责内容服务和收据验证等等。
令我困扰的是,无法确保后端输入的产品标识符是有效的。
我知道有一个 API 可以从 iOS 调用来获取特定应用程序的产品标识符列表(是公司吗?),是否有办法从后端获取此信息,以便对输入的标识符进行真正的验证完毕?
提前致谢。
I am creating the backend for an iOSapp that has inapp purchase products in them.
The backend does the content serving stuff and validations of receipts and what not.
What bothers me is that there is no way to be sure that the product identifier entered in the backend is a valid one.
I know there is an API that can be called from the iOS to get a list of product identifiers for a specific app(was it company?), is there anyway to obtain this information from the backend so true validation of the entered identifier can be done?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
用户进行有效购买后,您会收到编码的购买收据。要检查购买是否有效,您需要将此收据发送到 Apple 的验证服务器。您将收到一条回复,指示购买是否有效,以及是否有效 - 有关购买的详细信息(购买时间、产品 ID、交易 ID 等)。
我使用了示例代码此处,它非常简单直接。在测试(包括使用 TestFlight)时使用沙箱 URL 作为端点,并在应用程序进入应用商店后使用生产 URL。
顺便说一句,我建议为您的 IAP 生成一个共享密钥(您可以在 iTunes Connect 中执行此操作),并将其包含在名为
password
的字段下的验证请求中:Once a user makes a valid purchase, you receive an encoded purchase receipt. To check if the purchase is valid, you need to send this receipt to Apple's validation servers. You'll receive a response indicating if the purchase was valid, and if it's valid - details about the purchase (purchase time, product ID, transaction ID, etc...).
I used the example code here and it was pretty easy and straight forward. Use the sandbox url as an endpoint while testing (including with TestFlight), and the production URL once the app is in the app store.
BTW, I would recommend generating a shared secret for your IAP (you can do it in iTunes Connect), and including it in your validation requests under a field called
password
: