flutter 接入 alipay支付宝

Flutter alipay支付集成,尝试了3种插件

(1)插件sy_flutter_alipay ios下编译失败,放弃

(2)插件 flutter_alipay 最终也失败放弃

https://github.com/best-flutter/flutter_alipay

几个点:

1.info.plist

CFBundleURLTypesLSApplicationQueriesSchemes

 

<key>LSApplicationQueriesSchemes</key>

<array>

<string>mqqOpensdkSSoLogin</string>

    <string>mqzone</string>

    <string>sinaweibo</string>

    <string>alipayauth</string>

    <string>alipay</string>

    <string>safepay</string>

    <string>mqq</string>

    <string>mqqapi</string>

    <string>mqqopensdkapiV3</string>

    <string>mqqopensdkapiV2</string>

    <string>mqqapiwallet</string>

    <string>mqqwpa</string>

    <string>mqqbrowser</string>

    <string>wtloginmqq2</string>

    <string>weixin</string>

    <string>wechat</string>

<string>cydia</string>

</array>

<key>CFBundleURLTypes</key>

<array>

<dict>

<key>CFBundleURLName</key>

            <string>alipay</string>

            <key>CFBundleTypeRole</key>

            <string>Editor</string>

            <key>CFBundleURLSchemes</key>

<array>

<string>aimingAlipay</string>

</array>

</dict>

<dict/>

<dict/>

</array>

 

2.Appdelegate.swift增加

 

3.服务端回调

pc的参数

var payResult = await FlutterAlipay.pay(payUrl);

print(payResult);

 

最后测试 能拉起支付,但返回app的时候 payResult的结果没有,看了git issue 也没有人回复,但有的人能成功。查看了官方sdk2个接口

(1.0) mobile.securitypay.pay

(2.0)alipay.trade.app.pay

我用的是1.0 没有reture result,不知道别人成功的是不是2.0

(3)最后用了靠谱的 ibatis,就是这个名字取的不行,怎么都想不到他是alipay插件,但很靠谱和好用,不管怎么样 urlschme是一定要配置的

Map payResult;

try {

print("The pay info is : " + payUrl);

payResult = await aliPay(payUrl);

print("--->$payResult");

} on Exception catch (e) {

payResult = {};

}

if (!mounted) return;

print('payResult:' + payResult.toString());

if (payResult['resultStatus'].toString() == '9000') {

Utils.showToast('支付成功');

Navigator.of(context)

.push(MaterialPageRoute(builder: (_) => FinanceListView()));

} else {

Utils.showCustomAlert(context,

content: Text('支付失败:' + payResult['resultStatus']));

}

 

posted on 2020-04-26 17:19  kobe  阅读(4397)  评论(0编辑  收藏  举报

导航