赞
踩
需求:支付宝支付
使用tobias:https://github.com/OpenFlutter/tobias/blob/master/README_CN.md
tobias:
url_scheme: tobiasexample
ios:
ignore_security: true
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>alipay</string>
<key>CFBundleURLSchemes</key>
<array>
<string>tobiasexample</string>
</array>
</dict>
</array>
设置好,要和2上面的参数一一对应
class PayRequest{ // 支付宝支付,返回一个对象 static Future<AliPayEntity> aliPay(String itemName) async{ final url = "alipay-app-pay/"; final res = await HttpRequest.request(url,method: "post", params: {"item_name":itemName}); // 解决'_Map<String, dynamic>' is not a subtype of type 'FutureOr<LoginEntity>'的报错 final Map<String,dynamic> jsonData = res; final AliPayEntity aliPayEntity = AliPayEntity.fromJson(jsonData); return aliPayEntity; } } Tobias tobias = Tobias(); // 支付宝支付 Future<void> aliPay() async{ // 先写死 String itemName = "600钻石"; AliPayEntity aliPayEntity = await PayRequest.aliPay(itemName); print("支付宝支付,后端返回的${aliPayEntity.orderStr}"); tobias.pay(aliPayEntity.orderStr); }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。