CmbpbFlutter

pub package

Flutter 招商一网通支付 SDK。

相关文档

添加依赖

pubspec.yaml 文件中添加cmbpbflutter依赖: pub package

dependencies:
  cmbpbflutter: ^${latestVersion}

相关配置

Android

需要在Android工程AndroidManifest.xml下配置回调入口, 并配置招行分配给商户的「URL scheme」

       <activity
           android:name="cmb.pb.flutter.cmbpbflutter.CmbPbPayCallbackActivity"
           android:label="@string/app_name"
           android:exported="true"
           android:theme="@style/CmbPbPay.Theme.Transparent"
           android:taskAffinity="${applicationId}"
           android:launchMode="singleTop">

           <intent-filter>
               <action android:name="android.intent.action.VIEW"/>
               <category android:name="android.intent.category.DEFAULT"/>
               <data android:scheme="${招行给的回调url scheme}"/>
           </intent-filter>
       </activity>

IOS

配置Xcode中

  • 在info.plist中增加LSApplicationQueriesSchemes白名单配置,值为cmbmobilebank。
  • 在URL Types中新增URL Schemes,值设置为招行分配给商户的scheme(需与安卓设置的scheme保持一致),如分配到的scheme为abcdefg则配置如下图所示。

基本使用


// 注册appId
CmbPbPay.instance.registerApp(appId: "12306");

//设置支付回调
CmbPbPay.instance.respStream().listen((event) {
      print("支付结果回调了");
      setState(() {
        _payResultDesc = "${event.code} ===${event.msg}";
      });
    });

//发起支付
void _startPay() {
    final requestData = "xxx";
    final appUrl = "cmbmobilebank://CMBLS/FunctionJump?action=gofuncid&funcid=200013&serverid=CMBEUserPay&requesttype=post&cmb_app_trans_parms_start=here";
    final h5Url = "http://121.15.180.66:801/netpayment/BaseHttp.dll?H5PayJsonSDK";
    CmbPbPay.instance.pay(requestData: requestData, appUrl: appUrl, h5Url: h5Url, method: "pay");
}

捐助

开源不易,请作者喝杯咖啡。

LICENSE

Copyright 2021 Leon2017 CmbpbFlutter Project

Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements.  See the NOTICE file distributed with this work for
additional information regarding copyright ownership.  The ASF licenses this
file to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License.  You may obtain a copy of
the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
License for the specific language governing permissions and limitations under
the License.

Libraries

cmbpbflutter