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

PlatformAndroidiOS
outdated

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

h5pay #

build status pub package

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

Usage #

Use the showH5PayDialog method to show a loading dialog and jump to payment app. When user switches from payment app back to your app, you can check payment result with your server in the verifyResult callback (Optional).

import 'package:h5pay/h5pay.dart';

final PaymentStatus status = await showH5PayDialog(
  context: context,
  // You can get payment url (normally is http or payment app scheme) from server in the getPaymentArguments callback
  getPaymentArguments: () async => PaymentArguments(
    url: 'https://is.gd/4cLE6j',
    redirectSchemes: ['alipay', 'alipays', 'weixin', 'wechat'],
    httpHeaders: {
      'referer': 'https://xxx',
    },
  ),
  verifyResult: () async => true, // check order result with your server
);
if (status == PaymentStatus.success) {
  // Do something
}

Values of PaymentStatus:

enum PaymentStatus {
  idle,
  gettingArguments,
  getArgumentsFail,
  launchingUrl,
  cantLaunchUrl, // Maybe target payment app is not installed
  launchUrlTimeout, // Maybe redirecting url is fail
  jumping,
  jumpTimeout,
  verifying,
  success,
  fail,
}

Notes #

  • In iOS, for allowing to jump to the payment app from your app, you must add schemes of the payment apps 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
110
pub points
3%
popularity

Publisher

unverified uploader

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on h5pay