https://github.com/nekocode/h5pay-flutter
A H5/HTML5 payment (such as Alipay, WeChat-Pay) plugin for flutter.
https://github.com/nekocode/h5pay-flutter
flutter widget
Last synced: 3 months ago
JSON representation
A H5/HTML5 payment (such as Alipay, WeChat-Pay) plugin for flutter.
- Host: GitHub
- URL: https://github.com/nekocode/h5pay-flutter
- Owner: nekocode
- License: apache-2.0
- Created: 2019-10-13T16:52:27.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-03T03:37:50.000Z (over 1 year ago)
- Last Synced: 2025-03-20T17:23:30.009Z (3 months ago)
- Topics: flutter, widget
- Language: Dart
- Homepage:
- Size: 450 KB
- Stars: 42
- Watchers: 2
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# h5pay
[](https://travis-ci.com/nekocode/h5pay-flutter)
[](https://pub.dev/packages/h5pay)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).
```dart
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`:
```dart
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:
```xml
LSApplicationQueriesSchemes
weixin
alipay
alipays```
### Advanced
If you have more complex requirements, you can use the `H5PayWidget`. Check the [example](example) for more detail.