ercaspay 0.0.2 copy "ercaspay: ^0.0.2" to clipboard
ercaspay: ^0.0.2 copied to clipboard

A Flutter package for ercaspay.

Flutter plugin for ercaspay SDK

Getting started #

To use this plugin, add ercaspay as a dependency in your pubspec.yaml file.

How to Use #

This plugin uses two APIs

  1. Create a Ercaspay instance by calling the constructor Ercaspay. The constructor accepts a required instance of the following: context, business, reference, callbackUrl, amount, token It returns an instance of Ercaspay which we then call the async method .chargeTransaction() on.
import 'package:ercaspay/ercaspay.dart';

final ercaspay = Ercaspay(
   context: context,
   amount: 100,
   reference: "{{randomly generated string}}",
   callbackUrl: "{{call back url}}",
   token: "{{Secret Key}}",
   business: Business(name: "{{business name}}", email: "{{business email}}"),
   paymentMethod: 'card,transfer',
   metadata: {
      "name":"Ladenifer Jada",
      "email":"ladjada@ymail.com"
   }
);

PaymentResponse? response = await ercaspay.chargeTransaction();
  1. Handle the response Calling the .chargeTransaction() method returns a Future of PaymentResponse which we await for the actual response as seen above.
PaymentResponse? response = await ercaspay.chargeTransaction();

if (response != null) {
  if(response.success!) {
    //handle success response 
  } else {
    //Handle not successful 
  }
} else {
  //User cancelled checkout
}

Additional information #