flutter_paystack_plus 0.0.3+1 copy "flutter_paystack_plus: ^0.0.3+1" to clipboard
flutter_paystack_plus: ^0.0.3+1 copied to clipboard

An improved implementation of payment using Paystack - Compatible with Web, Android and iOS (Bank, Bank transfer, Card, USSD, Mobile money and others).

A Flutter plugin for making payments via Paystack Payment Gateway - Compatible on Android, iOS and Web.

Features #

  • Mobile Money

  • VISA

  • Bank

  • Bank Transfer

  • USSD

  • QR

Getting started #

Before getting started, ensure you have succesfully created an account on paystack and you have your public key ready. Vist https://paystack.com to setup your account.

A. FOR WEB COMPATIBILITY: Ensure you do the following

  1. Create a file on your web folder and call it "paystack_interop.js"

  2. Copy and paste the code below on the created folder

function paystackPopUp(publicKey, email, amount, ref, onClosed, callback) {
  let handler = PaystackPop.setup({
    key: publicKey,
    email: email,
    amount: amount,
    ref: ref,
    onClose: function () {
      alert("Window closed.");
      onClosed();
    },
    callback: function (response) {
      callback();
      let message = "Payment complete! Reference: " + response.reference;
      alert(message);
    },
  });
  return handler.openIframe();
}
  1. In your web/index.html file add the following code at the top of the body tag section
<body>
<script src="https://js.paystack.co/v1/inline.js"></script>
<script src="paystack_interop.js"></script>
...
...
</body>

B. FOR ANDROID COMPATIBILITY: Ensure your minSdkVersion is 19 or higher

defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId '...'
        minSdkVersion 19 // Ensure this line is 19 or higher
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

C. NO SETUP REQUIRED for iOS

Some important parameters #

  • [publicKey] is required for web only
  • [secretKey] is required for android and iOS only
  • [context] is required for android and iOS only
  • [amount] should be multiplied by 100 [eg amount * 100]
  • [onClose] is called when the user cancels a transaction or when there is a failed transaction
  • [onSuccess] is called on successful transactions

Usage #

     FlutterPaystackPlus.openPaystackPopup(
      publicKey: '-Your-public-key-',
      customerEmail: 'youremail@gmail.com',
      context:context,
      secretKey:'-Your-secret-key-',
      amount: (amount * 100).toString(),
      reference: DateTime.now().millisecondsSinceEpoch.toString(),
      onClosed: () {
        debugPrint('Could\'nt finish payment');
      },
      onSuccess: () async {
        debugPrint('successful payment');
      },
    );

Additional information #

Here is a detailed example project => https://github.com/Princewil/flutter_paystack_plus_example

Please feel very free to contribute. Experienced an issue or want to report a bug? Please, feel free to report it. Remember to be as descriptive as possible. Thank you.

20
likes
0
points
938
downloads

Publisher

unverified uploader

Weekly Downloads

An improved implementation of payment using Paystack - Compatible with Web, Android and iOS (Bank, Bank transfer, Card, USSD, Mobile money and others).

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, js, pay_with_paystack

More

Packages that depend on flutter_paystack_plus