Giter Site home page Giter Site logo

quanning / h5pay-flutter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nekocode/h5pay-flutter

0.0 1.0 0.0 464 KB

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

License: Apache License 2.0

Kotlin 20.83% Swift 18.81% Objective-C 1.18% Dart 53.42% Ruby 5.77%

h5pay-flutter's Introduction

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'],
  ),
  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.

h5pay-flutter's People

Contributors

nekocode avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.