Skip to content

A simple and efficient way to integrate AzamPay payment gateway into your Dart/Flutter applications.

License

Notifications You must be signed in to change notification settings

kaykhahima/dart_azampay

Repository files navigation

AzamPay Dart Package

pub package GitHub Actions Workflow Status

dart_azampay is a Dart package that provides a simple and efficient way to integrate AzamPay payment gateway into your Dart/Flutter applications. With Azampay, you can easily make mobile and bank payments, request payment link, disbursements, and pay bills.

Features

  • Mobile payments
  • Bank payments
  • Get payment partners
  • Request payment link
  • Disbursements
  • Pay bills

Installation

Add dart_azampay to your pubspec.yaml file:

dependencies:
  dart_azampay: latest_version

Run dart pub get to install the package, or, install it directly from the command line:

dart pub add dart_azampay

Getting Started

Initialize and make requests

Initialize the package with your app name, client ID, and secret key. You can find these details on your AzamPay portal. If you haven't registered yet, you can do so here. Register, verify your account, create an app and get your credentials.

Example: Mobile Payment Checkout

// initialize the AzamPay client
final azamPayClient = AzamPayClient(
   appName: 'My-App',
   clientId: '4a4c16d1-52cc-48eddf23-bfff',
   clientSecret: 'BR2USg29BIubf...vU5ErDtc=',
   sandbox: true, // set to false for production
);

// create an instance of the Checkout service
final checkoutService = Checkout(azamPayClient);

// Create a MNOCheckoutRequest
final mnoRequest = MnoCheckoutRequest(
   accountNumber: '255764XXXXXX',
   additionalProperties: {}, //optional
   amount: '1000',
   currency: 'TZS',
   externalId: 'external-id',
   provider: MnoProvider.mpesa, // or any other provider
);

// Example usage of the checkout service
final res = await checkoutService.mnoPayment(request: mnoRequest);
print('mno checkout response: ${res.data}');

Services

This package allows you to use services based on your needs. For instance, you can use only the checkout service or the bill payment service.

Supported services

1. Checkout service

// instance of the checkout service
final checkoutService = Checkout(azamPayClient);

// mobile payment checkout
final res = await checkoutService.mnoPayment(request: mnoRequest);
print('mno checkout response: ${res.data}');

// bank payment checkout
final res = await checkoutService.bankPayment(request: bankRequest);
print('bank checkout response: ${res.data}');

2. Partners service

// Instance of the partners service
final partnersService = Partners(azamPayClient);

// Get payment partners
final partners = await partnersService.getPaymentPartners();
print('Partners list: $partners'); // Prints the list of partners

// Request payment link
final res = await partnersService.requestPaymentLink(postCheckoutRequest);
print('Payment link: ${res.data}'); // Prints the payment link

Related packages

Contributing

Contributions are welcome! If you have suggestions for improvements or new features, please open an issue or submit a pull request.

License

This project is licensed under the BSD 3-Clause License. See the LICENSE file for details.

About

A simple and efficient way to integrate AzamPay payment gateway into your Dart/Flutter applications.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages