A PayStack SDK wrapper for flutter apps.
For help getting started with Flutter, view our online documentation.
-
Add
flutter_paystack
as a dependency in yourpubspec.yaml
file. -
For Android, add the following tag in your android/app/src/main/AndroidManifest.xml file within the tags:
<meta-data android:name="co.paystack.android.PublicKey" android:value="INSERT-PUBLIC-KEY-HERE"/>
- Import
paystack_flutter
import 'package:flutter_paystack/flutter_paystack.dart';
- Call the
chargeCard
method with Card parameters
Map<string, dynamic> cardOptions ={
"cardNumber": "4084084084084081", "cvc": "408",
"expiryMonth": "08",
"expiryYear": "2019",
"amountInKobo": 2000,
"email": "payu@me.com"
};
FlutterPaystack.chargeCard(cardOptions)
.then((res) => {
// Do something with the response
print(res);
}).catchError(print);
- Response object
{
reference: "trx_1k2o600w"
}
- Import
paystack_flutter
import 'package:flutter_paystack/flutter_paystack.dart';
- Call the
chargeCardWithAccessCode
method with Card parameters
Map<string, dynamic> cardOptions ={
"cardNumber": "4084084084084081", "cvc": "408",
"expiryMonth": "08",
"expiryYear": "2019",
"accessCode": "2p3j42th639duy4"
};
FlutterPaystack.chargeCard(cardOptions)
.then((res) => {
// Do something with the response
print(res);
}).catchError(print);
- Response object
{
reference: "trx_1k2o600w"
}
Verify a charge by calling Paystack's REST API with the reference
obtained above. An authorization_code
will be returned once the card has been charged successfully. Learn more about that here.
- reference - the transaction reference (required)
$ curl https://api.paystack.co/transaction/verify/trx_1k2o600w \
-H "Authorization: Bearer SECRET_KEY" \
-H "Content-Type: application/json" \
-X GET
This packages uses the PayStack Android SDK
- Improve documentation
- Support iOS
- Improve example
MIT