wftpay 0.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 43

wftpay #

A new flutter plugin project.

Getting Started #

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

TODO #

  • [ ] 优能配置 使用优能提供的参数(appId、mch_id和key),无法成功吊起支付,提示支付类型未开通;使用威富通提供的参数,可以支付一次,再一次支付必须重装微信

  • [ ] 回调未测试

使用前准备 #

1.Android需要用商户自己的包名和签名,并用自己的签名文件打包

应用包名:是在APP项目配置文件AndroidManifest.xml中声明的package值,例如DEMO中的package="net.sourceforge.simcpux"

应用签名:根据项目的应用包名和编译使用的keystore,可由签名工具生成一个32位的md5串,在调试的手机上安装签名工具后,运行可生成应用签名串

具体参照微信文档-APP端开发步骤-Android开发要点说明 https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_5

2.IOS项目设置APPID

商户在微信开放平台申请开发APP应用后,微信开放平台会生成APP的唯一标识APPID。在Xcode中打开项目,设置项目属性中的URL Schemes为您的APPID

具体参照微信文档-APP端开发步骤-IOS开发要点说明 https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_5

3.IOS项目设置plist

文本编辑Info.plist,在dict中添加下面key

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>weixin</string>
    <string>wechat</string>
    <string>mqq</string>
    <string>mqqapi</string>
    <string>alipay</string>
    <string>alipayqr</string>
    <string>alipays</string>
</array>

使用 #

// 获取当前设备版本号(dome原方法)
result = await Wftpay.platformVersion;

// 以下两个函数
// 返回0为支付成功,其它为失败
// -1 原因:支付错误,可能的原因:签名错误、未注册APPID、项目设置APPID不正确、注册的APPID与设置的不匹配、其他异常等
// -2 原因 用户取消,无需处理。发生场景:用户不支付了,点击取消,返回APP(ios没有这个判断)

// 支付
result = await Wftpay.wxPay({
    'appId': '', // 微信应用appId
    'token_id': '', // 通过请求服务器统一下单接口返回的参数,在小程序和H5中是一个Object,其中包含sign,nonce_str等参数,而在app中只需要用到其中的token_id即可
    'amount': '1', // ios需要此参数,只用于扫码支付和付款码支付类型时客户端显示金额。不会参与交易计算,具体的交易金额以下单时候传入的金额为准。
});
// 支付测试,以下参数由威富通提供
// 与支付不同的是,测试支付不需要通过请求服务器统一下单接口返回的参数,而是在app中自己调用微信统一下单接口拿取数据
// 因此只提供测试使用,真实场景一定不能用这种方法,有泄漏密钥的风险,记得删除
result = await Wftpay.wxPayTest(
    appId: 'wx2a5538052969956e', // 微信应用appId
    mch_id: '755437000006', // 商户号
    key: '7daa4babae15ae17eee90c9e', // 密钥
);

ios开发遇坑 #

1.如果遇到plist的报错,如下,在xcode-file-workspace setting中将build system设置为Legacy Build System(第二个)

我也不知道为什么

Multiple commands produce '/Users/mac/Library/Developer/Xcode/DerivedData/Runner-ahdzorlajnxaikghzbfwnbmlhtci/Build/Products/Debug-iphonesimulator/wftpay/Info.plist'

Multiple commands produce '/Users/mac/Library/Developer/Xcode/DerivedData/Runner-ahdzorlajnxaikghzbfwnbmlhtci/Build/Products/Debug-iphonesimulator/wftpay/Info-8.0+.plist'

参考文档 #

1.威富通移动支付开发文档 https://open.swiftpass.cn/openapi/doc?index_1=4&index_2=1&chapter_1=102&chapter_2=103

sdk和domo在这里下载

2.微信支付文档 https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_5

介绍了一些重要的应用配置

3.flutter微信支付插件 https://github.com/lishuhao/sy_flutter_wechat

参考了一些写法

4.flutter插件开发官方文档 https://flutterchina.club/developing-packages/

5.插件发布翻墙 https://www.kikt.top/posts/flutter/package/publish-fail/

0.0.1 #

  • TODO: Describe initial release.

example/README.md

wftpay_example #

Demonstrates how to use the wftpay plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  wftpay: ^0.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:wftpay/wftpay.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
3
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
60
Overall:
Weighted score of the above. [more]
43
Learn more about scoring.

We analyzed this package on Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

6 out of 6 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/wftpay.dart. (-0.50 points)

Analysis of lib/wftpay.dart reported 1 hint:

line 19 col 49: Name non-constant identifiers using lowerCamelCase.

Maintenance issues and suggestions

Homepage URL isn't helpful. (-10 points)

Update the homepage field from pubspec.yaml: link to a website about the package or use the source repository URL.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test