/shoket

A Flutter wrapper for Shoket Payment API

Primary LanguageC++MIT LicenseMIT

Shoket Flutter Wrapper

A simple Flutter wrapper for the shoket payment API, for more information on the API visit Shoket Official website.

Getting Started

Prerequisites

  • Ensure you have your API keys.

Installation

  • Add the dependency

In your pubspec.yaml file add:

shoket: 0.0.4

Import in your file:

import"package:shoket/shoket.dart";

run flutter pub get

Usage

  1. Create a Shoket instance by calling the constructor Shoket(). The constructor accepts an API KEY as parameter. It returns an instance of Shoket which we then call the async method .charge() or .verify() on.
final shoket = Shoket(apiKey: "apiKey");
  1. Create a payment object with the payment details
var paymentDetails = Payment(
                      amount: "1000",
                      customerName: "John DOe",
                      email: "johndoe@gmail.com",
                      numberUsed: "255717000000",
                      channel: "Halotel");
  1. Get the response by calling .charge() method passing paymentDetails object as a parameter. NOTE chargeresponse can be null
final ChargeResponse? response = await shoket.charge(paymentDetails);
  1. Handle the response
if (response == null) {
  // the transaction failed
} else {
  var status = response.status;
  if (status == "success") {
    // provide value to customer
  } else {
    // check message
    print(response.message);
  }
}

Extra

Check example app provided for further assistance

Credits

License

This project is licensed under the MIT License.