demand
Fluwx is used to transfer wechat payment when Flutter is used. Fluwx package is not much code, but various configurations of Android and ios are complicated.
The environment
flutter 1.91.
fluwx 1.21.+1
Copy the code
Method of use
Import FluwX and register wechat API
fluwx.registerWxApi(
appId:"wx0axxxxxxxxxx3edb".universalLink:"https://www.baidu.com/"
);
Copy the code
Call payment, parameters from the backend write interface request
fluwx.pay(
appId: wechatParams["appid"].partnerId: wechatParams["partnerid"].prepayId: wechatParams["prepayid"].packageValue: wechatParams["package"].nonceStr: wechatParams["noncestr"].timeStamp: wechatParams["timestamp"].sign: wechatParams["sign"].extData: 'test'
);
Copy the code
Listen for callbacks to payments
fluwx.responseFromPayment.listen((data) {
print('Payment callback notification... '); if(data.errCode == 0){ print('Pay for success'); }else{ print('Pay for failure'); }Copy the code
See the code above, and other Android and ios configurations below
IOS configuration
IOS wechat pay’s official configuration documents are introduced in detail. It is recommended to have a look at the official documents first. Here are a few steps I summarize:
- Configure the Universal Links of the project, and keep consistent with the configuration of wechat public platform
- Xcode turns on the Associated Domains switch and adds the Universal Links domain name to the configuration
- Check WechatOpenSDK. If not, integrate with CocoaPods
- In Xcode, select your project Settings, click the TARGETS column, and add “URL Scheme” as the ID of your registered application under “URL Type” under “Info” TAB
- In Xcode, the choice of your project Settings, select the “TARGETS” column, in the “info” TAB “LSApplicationQueriesSchemes” add weixin and weixinULAPI (important)
- Ios configuration is complete, you can package out to see the effect
Android Configuration
Android wechat Pay official configuration documents are introduced in detail, and it is recommended to have a look at the official document first. Here are a few steps I summarize:
- In the build.gradle file, add the following dependencies
dependencies {
api 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+'
}
Copy the code
- Add the exported attribute to the androidmanifest.xml file and set it to true
<activity
android:exported="True" > < / activity >Copy the code
-
Obtain the signature of the APP and update it to the wechat open platform at the same time. Make sure that the signature on both sides is consistent with the APP ID
-
Android configuration is successful, you can package out to see the effect
The resources
- [FluwX official documentation](github.com/OpenFlutter…
)
- IOS wechat Pay official profile
- Android’s official wechat Pay profile
- Android get APP signature tool