1:苹果支付是苹果生态中的小闭环,但是感觉有点坑,测试网速超级慢
2:因为我们app是使用flutter 继续开发,而且属于教育类产品,废话不多说,
3:参照的第三方flutter_inapp_purchase
4:这个集成起来不复制,复杂在苹果搞的这套流程,如果不好好集成还是真不让你审核通过
首先:参照appStore 后台把全部的信息配置完全,请参照:
https://www.jianshu.com/p/134b506a27e9
账户配置好:
最主要的是订单ID和 你在苹果后台配置的一样,
Future _getProduct() async {
List<IAPItem> items =
await FlutterInappPurchase.instance.getProducts(_productLists);
for (var item in items) {
print('${item.toString()}');
this._items.add(item);
}
setState(() {
this._items = items;
this._purchases = [];
});
}
根据产品id 列表获取产品信息(
final List<String> _productLists = Platform.isAndroid
? [
'android.test.purchased',
'point_1000',
'5000_point',
'android.test.canceled',
]
: ['1', '2'];)
- IAP 第一步下单
下单直接用:FlutterInappPurchase.instance.requestPurchase(item.productId);
IAP 第二步通过订单号获取支付参数 (商品ID:发起支付和OrderId:服务端校验)
IAP第三步 发起IAP支付,拿到交易成功的Receipt
IAP第四步: 发送给服务端验证数据有效性
错误日志上报,丢包处理
特别感谢:Flutter iOS 苹果IAP(内购)实现步骤及问题总结(全网最全)https://www.jianshu.com/p/134b506a27e9