azampaytanzania 0.0.4 copy "azampaytanzania: ^0.0.4" to clipboard
azampaytanzania: ^0.0.4 copied to clipboard

Flutter SDK for AzamPay Tanzania integration Which includes MNO and Bank Account collection.

AzamPay Tanzania #

A Flutter/Dart SDK for integrating with the AzamPesa Mobile Money API in Tanzania. This package provides a simple and developer-friendly interface for collecting mobile payments via various mobile network operators (MNOs), including:

  • AzamPesa
  • TigoPesa
  • M-Pesa
  • Airtel Money
  • HaloPesa

Also Bank checkout is supported Via

  • CRDB
  • NMB

โœ… Supports both Sandbox and Production environments.


โœจ Features #

  • ๐Ÿ” OAuth2 Token Generation
  • ๐Ÿ’ฐ Mobile Money Checkout (Collect Payment)
  • ๐Ÿฆ Bank Checkout (Collect Payment)
  • โš™๏ธ Simple Initialization with environment support
  • ๐Ÿงช Mockable and testable HTTP integration

๐Ÿ›  Getting Started #

1. Get Credentials #

Register on the AzamPay Developer Portal to obtain:

  • clientId
  • clientSecret
  • apiKey
  • appName

2. Add the Package #

Add the dependency to your pubspec.yaml:

dependencies:
  azampaytanzania: ^0.0.4

3. Then Run #

 flutter pub get 

4. Import the SDK #

import 'package:azampaytanzania/azampaytanzania.dart';


5. Initialize the SDk #

final azamPesa = AzamPayTanzania(
  clientId: 'your_client_id',
  clientSecret: 'your_client_secret',
  apiKey: 'your_api_key',
  appName: 'your_app_name',
  isProduction: false, // Set to true for live transactions
);

6. Collect Mobile Money Payments #

 //Mobile money Collection.
    final response = await azamPesa.collectMnoPayment(
      accountNumber: '2557xxxxxxx',
      amount: '1000',
      externalId: 'TXN123456', // Unique transaction reference from your system
      provider: "Airtel", // Other valid values: Airtel, Tigo, Halopesa, Mpesa
    );
    //Respose print
    debugPrint('Payment response: $response');

Response for Mobile Money Payments

  • Status Code 200 : Success
{
  "transactionId": "string",
  "message": "string",
  "success": true
}
  • Status Code 400 : Bad Request
{
  "errors": {
    "amount": [],
    "externalId": [],
    "accountNumber": [],
    "provider": []
  },
  "type": "string",
  "traceId": "string",
  "title": "string",
  "status": 0
}

7. Supported Mobile Providers #

Provider Name Accepted Value
AzamPesa Azampesa
TigoPesa Tigo
Airtel Money Airtel
HaloPesa Halopesa
M-Pesa Mpesa

8. Bank Account Checkout #

    //Bank checkout
    final bankResponse = await azamPesa.bankCheckout(
      referenceId: "Your Reference", //String Value
      merchantName: "Merchant name", //String Value
      amount: 2332, //Int Value 1000
      merchantAccountNumber: "merchantAccountNumber", //String Value
      merchantMobileNumber: "merchantMobileNumber", //String Value
      otp: "otp", //String Value
      provider: "provider", //"CRDB" || "NMB" only
    );
    debugPrint('Payment response : $bankResponse');

9. Supported Bank Providers #

Provider Name Accepted Value
CRDB BANK PLC CRDB
NMB BANK PLC NMB

10. How to generate Bank OTP values #

Generate CRDB OTP

How to get CRDB OTP to activate your bank account

  • Dial 15003# and Enter your SIM Banking PIN

  • Press 7 other services

  • Press 5 for azampay the select any of the below

  • Link Azampay Account > to generate OTP

  • Unlink Azampay Account > unlink linked account

  • Disconnect > disable linking


Generate NMB OTP

How to get NMB OTP to activate your bank account

  • Dial 15066#

  • Press 8 More

  • Press 5 Register Sarafu

  • Press 1 Select Account No.

Response for Bank Account Payments

  • Status Code 200 : Success
{
  "transactionId": "string",
  "message": "string",
  "success": true
}
  • Status Code 400 : Bad Request
{
  "errors": {
    "amount": [],
    "externalId": [],
    "accountNumber": [],
    "provider": []
  },
  "type": "string",
  "traceId": "string",
  "title": "string",
  "status": 0
}

11. Example #

See the full working examples of all scenarios in:

example/example.dart

12. FAQ #

How do I get credentials? Log in to the AzamPay Developer Portal and register your application to receive:

  • App Name

  • Client ID

  • Client Secret

  • API Key


13. ๐Ÿค Contributing #

  • Fork the repo

  • Create a feature branch

  • Make changes and write tests

  • Open a Pull Request

We welcome improvements, bug fixes, and feature enhancements


14. โš ๏ธ Disclaimer #

This package is not officially affiliated with AzamPay. Use at your own discretion. Refer to AzamPayโ€™s official documentation and API policies when deploying to production.

For official docs:


1
likes
160
points
37
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter SDK for AzamPay Tanzania integration Which includes MNO and Bank Account collection.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, http

More

Packages that depend on azampaytanzania