flutter_paystack_plus 0.0.1+1 flutter_paystack_plus: ^0.0.1+1 copied to clipboard
Implement payment using Paystack.
A Flutter plugin for making payments via Paystack Payment Gateway - For web only.
Features #
-
Mobile Money
-
VISA
-
Bank
-
Bank Transfer
-
USSD
-
QR
-
EFT
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.
-
Create a file on your web folder and call it "paystack_interop.js"
-
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();
}
- 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>
Usage #
FlutterPaystackPlus.openPaystackPopup(
publicKey: '-Your-public-key-',
email: 'youremail@gmail.com',
amount: (amount * 100).toString(),
ref: 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.