Chapa Flutter SDK
The official Chapa Flutter SDK enables Flutter developers to integrate Chapa's Payment API seamlessly into their applications. It supports both native and web checkout, providing a robust and flexible solution for initiating and validating payments.
Features
- š Initiate Payment: Easily facilitate transactions via four supported wallets telebirr,cbebirr,mpesa and ebirr.
- ā Validate Payment Status: Confirm payment completion and notify users instantly.
- š Web Checkout Support: Enable users to use the web checkout for additional payment options.
Requirement
To accept money with Chapa in real time, a Merchant should pass all the KYC process and must be in Live mode.
If you are a developer and testing how Chapa works, you can only test using test numbers: Chapa's Test Numbers
Preview
Payment Methods in Grid View

Payment Methods in List View with Customized Button Color

Error

Successful Payment Receipt

Getting Started
Installation
Add the following dependency to your pubspec.yaml
file:
dependencies:
chapasdk: ^latest_version
Then, run the command:
flutter pub get
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
context |
BuildContext |
Yes | Context of the current widget. |
publicKey |
String |
Yes | Your Chapa public key (use test key for testing and live key for production). |
currency |
String |
Yes | Transaction currency (ETB for native checkout, ETB or USD for web checkout NB=> You can not use USD for Naive checkout is it is only available for Web checkout.). |
amount |
String |
Yes | The amount to be charged. |
email |
String |
Yes | Customerās email address. |
phone |
String |
Yes | Customerās phone number. |
firstName |
String |
Yes | Customerās first name. |
lastName |
String |
Yes | Customerās last name. |
txRef |
String |
Yes | Unique reference for the transaction. |
title |
String |
Yes | Title of the payment modal. |
desc |
String |
Yes | Description of the payment. |
namedRouteFallBack |
String |
Yes | Named route to redirect users to after payment events (success, failure, or cancellation). NB: If you are using GoRoute, AutoRoute, or any custom routing package, pass this value as an empty string "" and make sure to pass a body to the onPaymentFinished function. |
nativeCheckout |
bool |
No | Whether to use native checkout (true ) or web checkout (false ). Default is true . |
showPaymentMethodsOnGridView |
bool |
No | Display payment methods in grid (true ) or horizontal view (false ). Default is true . |
availablePaymentMethods |
List<String> |
No | List of allowed payment methods (mpesa , cbebirr , telebirr , ebirr ). Defaults to all methods. |
buttonColor |
Color |
No | Button color for native checkout. Defaults to the appās primary theme color. |
onPaymentFinished |
Function |
No | A callback function executed when namedFallBackUrl is empty, typically used for custom navigation (e.g., AutoRoute,GoRoute). |
Usage
import 'package:chapasdk/chapasdk.dart';
Chapa.paymentParameters(
context: context,
publicKey: 'CHAPUBK-@@@@',
currency: 'ETB',
amount: '1',
email: 'fetanchapa.co',
phone: '0911223344',
firstName: 'Israel',
lastName: 'Goytom',
txRef: 'txn_12345',
title: 'Order Payment',
desc: 'Payment for order #12345',
nativeCheckout: true,
namedRouteFallBack: '/',
showPaymentMethodsOnGridView: true,
availablePaymentMethods: ['mpesa', 'cbebirr', 'telebirr', 'ebirr'],
onPaymentFinished: (message, reference, amount) {
Navigator.pop(context);
},
);
Payment Responses from
For Native Checkout:
Transaction Reference Number in Native Checkout context is Chapa's Reference number for the Payment.
{
"message": "Any Descriptive message regarding the payment status",
"transactionReference": "CHHhvtn7xLEkZ",
"paidAmount": "1.00"
}
For Web Checkout:
Transaction Reference Number in Web Checkout context is The transaction reference number you generated for the payment.
Important Note: If the web checkout is initiated from the native checkout page, the Transaction Reference for the web checkout will be generated by the app itself. This is because a single transaction reference cannot be used for both native and web checkout processes. Therefore, the app will generate a separate transaction reference for the web checkout.
Payment Canceled
{
"message": "paymentCancelled",
"transactionReference": "txn_12345",
"paidAmount": "1.00"
}
Payment Successful
{
"message": "paymentSuccessful",
"transactionReference": "txn_12345" ,
"paidAmount": "1.00"
}
Payment Failed
{
"message": "paymentFailed",
"transactionReference": "txn_12345",
"paidAmount": "0.00"
}
FAQ
1. Is the fallback route mandatory?
Yes, namedRouteFallBack
is required to handle post-payment events such as success, failure, or cancellation.
2. What currencies are supported?
- Native Checkout: ONLY ETB
- Web Checkout: ETB, USD
Support
For any questions or issues:
- Email: info@chapa.co
- Documentation: Chapa Developer Docs
Start building seamless payment experiences today with the Chapa Flutter SDK! š
Libraries
- chapa_payment_initializer
- chapasdk
- chapawebview
- data/api_client
- data/dio_client
- data/dio_interceptors
- data/model/initiate_payment
- data/model/network_response
- data/model/request/direct_charge_request
- data/model/request/validate_direct_charge_request
- data/model/response/api_error_response
- data/model/response/api_response
- data/model/response/direct_charge_success_response
- data/model/response/verify_direct_charge_response
- data/services/payment_service
- domain/constants/app_colors
- domain/constants/app_images
- domain/constants/common
- domain/constants/enums
- domain/constants/extentions
- domain/constants/requests
- domain/constants/strings
- domain/constants/url
- domain/custom-widget/contact_us
- domain/custom-widget/custom_textform
- domain/custom-widget/no_connection
- features/native-checkout/bloc/chapa_native_checkout_bloc
- features/native-checkout/chapa_native_payment
- features/network/bloc/network_bloc