Skip to content

lakexyde/flutter_paystack

Repository files navigation

flutter_paystack

A PayStack SDK wrapper for flutter apps.

Only supports Android for now.

Getting Started

For help getting started with Flutter, view our online documentation.

  • Add flutter_paystack as a dependency in your pubspec.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"/>

Usage

Charging a Card

  • 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"
}

Charging a Card with Access Code

  • 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"
}

Verifying a Charge

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.

Parameter

  • reference - the transaction reference (required)

Example

$ curl https://api.paystack.co/transaction/verify/trx_1k2o600w \
   -H "Authorization: Bearer SECRET_KEY" \
   -H "Content-Type: application/json" \
   -X GET

Credit

This packages uses the PayStack Android SDK

TODO

  • Improve documentation
  • Support iOS
  • Improve example

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages