When CMB recently deployed Flutter to deploy payment, I ☺ the friend I need to write a plug-in for FLUTTER because CMB doesn’t have the flutter plug-in

CmbpbFlutter

Flutter Merchants payment SDK.

The related documents

  • China Merchants Ynetcom payment access document
  • Universal Links

Add the dependent

inpubspec.yamlAdd to filecmbpbflutterRely on:

dependencies:
  cmbpbflutter: ^${latestVersion}
Copy the code

The related configuration

Android

It is necessary to configure the callback entry under Android project Androidmanifest.xml, and configure the “URL scheme” that CMB allocates to merchants.

<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 The android: name = "android. Intent. The category, the DEFAULT" / > < data android: scheme = "${action travel to callback url scheme}" / > < / intent - filter > </activity>Copy the code

In the root directory of the Android projectbuild.gradleIn the fileallprojectsAdd AAR Libs that cmBPBFLUTTER depends on

allprojects {
    repositories{...flatDir {
            dirs 'libs'.project(':cmbpbflutter').file('libs')}}}Copy the code

IOS

Configuration in the Xcode

  • In the info. Add LSApplicationQueriesSchemes plist white list configuration, value of cmbmobilebank.
  • Add URL Types and set the value of URL Schemes allocated to merchants (it should be the same as the scheme set by Android). If the scheme allocated is ABCdefg, the configuration is shown in the following figure.

The basic use

  • The sample code
/ / registered appId CmbPbPay. Instance. RegisterApp (appId: "12306"); / / set the callback CmbPbPay. Instance. RespStream (), listen ((event) {print (" payment result callback "); 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: / / http://121.15.180.66:801/netpayment/BaseHttp.dll? H5PayJsonSDK"; CmbPbPay.instance.pay(requestData: requestData, appUrl: appUrl, h5Url: h5Url, method: "pay"); }Copy the code

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.
Copy the code