一、IAP支付流程
1.应用从服务端获取ProductId
2.应用根据ProductId从App Store获取商品信息并展示
3.用户选中并点击后,应用向App Store发送payment请求,App Store处理该请求并返回transaction
4.应用从transaction中获取receipt,并发送给服务端。
5.服务端记录receipt并发送receipt到App Store校验结果是否合法(status==0)
6.服务器读取返回结果并通知应用
二、receipt,transaction_id
receipt即用户购买的凭证,习惯称为小票,receipt中包含in_app字段,为一个数组,当用户购买一个消费品时,会将in-app purchase receipt添加到receipt中。当当结束这个交易时,将in-app purchase receipt从receipt中移除,移除在下一次触发,即用户再发生一次购买或应用主动调用清除in-app pruchase receipt.
三、苹果的二次校验
客户端问题:越狱插件或者HTTP代理均可让用户做到伪造购买记录,因此通过服务端校验是否正确。
服务端问题:记录订单和商品,防止用A商品receipt来买B商品。