iOS内购三:Receipt
可参考:
- Validating Receipts Locally
需验证receipt,可以在本地验证,也可以在服务端验证
- 本地验证,涉及到security和加密,比较复杂
而服务端验证相对而言简单些

讯享网
- 收到transaction后,将receipt发送到自己的服务器
- 自己的服务器连接apple的服务器,做解密和验证
- apple将结果发送给服务器,服务器再发给你
参考:Choosing a Receipt Validation Technique
- Local - 本地设备上的收据验证,推荐使用收据的签名
- Server-side - 建议通过App Store进行服务器端收据验证,以持久保存应用内购买,以维护和管理购买记录。
Consumable in-app purchases remain in the receipt until you call
finishTransaction(_:). Maintain and manage records of consumables on a server if needed. Non-consumables, auto-renewing subscription items, and non-renewing subscription items remain in the receipt indefinitely. For auto-renewable subscription management, server-side receipt validation gives key advantages over on-device receipt validation.
消耗性应用IAP将保留在收据中,直到您调用finishTransaction(_ :)。 如果需要,在服务器上上维护和管理消耗品的记录。 非消耗品,自动续订的订阅项目和非续订的订阅项目会无限期保留在收据中。 对于自动续订订阅管理,服务器端收据验证比设备上的收据验证具有关键优势。
自动续期订阅在On-device vs server-side验证的比较

Local验证
参考:
- Validating Receipts Locally
When an application is installed from the App Store, it contains an application receipt that is cryptographically signed, ensuring that only Apple can create valid receipts. The receipt is stored inside the application bundle. Call the
appStoreReceiptURLmethod of theNSBundleclass to locate the receipt.
从App Store安装应用程序时,该应用程序包含经过加密签名的应用程序收据,以确保只有Apple可以创建有效的收据。 收据存储在应用程序包中。 调用NSBundle类的appStoreReceiptURL方法找到收据。
receipt是一个二进制文件,结构如下:

App Store验证
参考:
- Validating Receipts with the App Store
- App Store Receipts
- verifyReceipt
URL地址
POST https://buy.itunes.apple.com/verifyReceipt
讯享网
沙盒测试地址
讯享网POST https://sandbox.itunes.apple.com/verifyReceipt
异常处理
可参考的处理:
- 贝聊 IAP 实战之满地是坑
- 贝聊 IAP 实战之见坑填坑
- 贝聊 IAP 实战之订单绑定

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/78585.html