h5pay 0.2.0 copy "h5pay: ^0.2.0" to clipboard
h5pay: ^0.2.0 copied to clipboard

outdated

An H5/HTML5 payment (such as Alipay, WeChat Pay) plugin for flutter.

h5pay #

build status pub package

An H5 payment (such as Alipay, WeChat Pay) plugin for flutter.

Usage #

You can use the showH5PayDialog method to show a loading dialog and jump to payment app. When user switches from payment app to your app, the dialog will auto check the payment result.

import 'package:h5pay/h5pay.dart';

final PaymentStatus status = await showH5PayDialog(
  context: context,
  paymentSchemes: const ['alipay', 'alipays', 'weixin', 'wechat'], 
  getSchemeUrlTimeout: const Duration(seconds: 5),
  jumpTimeout: const Duration(seconds: 3),
  getH5Url: () async => 'xxx', // get the http or app scheme payment url from your server
  verifyResult: () async => true, // check order result from your server
);
if (status == PaymentStatus.success) {
  // Do something
}

Values of PaymentStatus:

enum PaymentStatus {
  idle,
  gettingSchemeUrl,
  getSchemeUrlTimeout,
  jumping,
  cantJump, // Maybe target payment app is not installed
  jumpTimeout,
  verifying,
  success,
  fail,
}

Notes #

  • In iOS, to jump to the payment app, you must add target schemes into the Info.plist file. Just like:
<key>LSApplicationQueriesSchemes</key>
<array>
	<string>wechat</string>
	<string>weixin</string>
	<string>alipay</string>
	<string>alipays</string>
</array>

Advanced #

If you have more complex requirements, you can use the H5PayWidget. Check the example for more detail.

7
likes
0
pub points
3%
popularity

Publisher

unverified uploader

An H5/HTML5 payment (such as Alipay, WeChat Pay) plugin for flutter.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on h5pay