用户向苹果服务器发起购买请求,收到购买完成的回调(购买完成后会把钱打给申请内购的银行卡内)
购买成功流程结束后, 向服务器发起验证凭证(app端自己也可以不依靠服务器自行验证)
自己的服务器工作分 4 步:
* 1、接收 iOS 端发过来的购买凭证。
* 2、判断凭证是否已经存在或验证过,然后存储该凭证。
* 3、将该凭证发送到苹果的服务器(区分沙盒环境还是正式环境)验证,并将验证结果返回给客户端。
sandbox 开发环境:https://sandbox.itunes.apple.com/verifyReceipt
prod 生产环境:https://buy.itunes.apple.com/verifyReceipt
* 4、修改用户相应的会员权限或发放虚拟物品。
简单来说就是将该购买凭证用 Base64 编码,然后 POST 给苹果的验证服务器,苹果将验证结果以 JSON 形式返回。
对于自动续订订阅,我们自己的服务器完全可以与apple server的交互应对用户的订阅状态,只需要确定客户端传来的用户第一次购买, user id 对应 original-transaction-id的关系。后面的续订,取消,变更套餐,完全不依赖于客户端传来的信息。
For auto-renewable subscriptions, the App Store can also notify your server of key subscription events.
Understand Product Types
There are four In-App Purchase types you can offer:
* Consumables are a type that are depleted after one use. Customers can purchase them multiple times.
* Non-consumables are a type that customers purchase once. They don't expire.
* Auto-renewable subscriptions to services or content are a type that customers purchase once and that renew automatically on a recurring basis until customers decide to cancel.
* Non-renewing subscriptions to services or content provide access over a limited duration and don't renew automatically. Customers can purchase them again.
消耗型、非消耗型、自动续期订阅和非续期订阅。