https://github.com/iamngoni/pesepay
Pesepay helps businesses in Africa get paid by anyone, anywhere in the world
https://github.com/iamngoni/pesepay
africa business dart dartlang flutter gateway iamngoni payments pesepay zimbabwe
Last synced: about 2 months ago
JSON representation
Pesepay helps businesses in Africa get paid by anyone, anywhere in the world
- Host: GitHub
- URL: https://github.com/iamngoni/pesepay
- Owner: iamngoni
- License: mit
- Created: 2023-03-02T11:24:41.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-08-25T20:31:03.000Z (about 2 months ago)
- Last Synced: 2025-08-25T20:41:50.709Z (about 2 months ago)
- Topics: africa, business, dart, dartlang, flutter, gateway, iamngoni, payments, pesepay, zimbabwe
- Language: Dart
- Homepage:
- Size: 83 KB
- Stars: 13
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Pesepay
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link]
[](https://github.com/felangel/mason)
[![License: MIT][license_badge]][license_link]![]()
![]()
Pesepay helps businesses in Africa get paid by anyone, anywhere in the world
> This is still WIP! Try out and contribute where you can.
## Installation 💻
**❗ In order to start using Pesepay you must have the [Dart SDK][dart_install_link] installed on your machine.**
Add `pesepay` to your `pubspec.yaml`:
```yaml
dependencies:
pesepay:
```Install it:
```sh
dart pub get
```---
## Usage 🔥
### Import package
```dart
import 'package:pesepay/pesepay.dart';
```### Declare and initialize
```dart
final pesepay = Pesepay(
integrationKey: '',
encryptionKey: '',
resultUrl: '',
returnUrl: '',
);
```### Get list of active currencies
```dart
final List currencies = await Pesepay.getActiveCurrencies();
```
Sample Currency
```dart
Currency(
name: Zimbabwe Dollar,
description: Zimbabwe Dollar,
code: ZWL,
defaultCurrency: false,
rateToDefault: 604.25,
active: true
)
```### Get list of payment methods for selected currency
```dart
final List methods = await Pesepay.getPaymentMethodsByCurrency(currency);
```Sample PaymentMethod
```dart
PaymentMethod(
active: true,
code: PZW201,
currencies: [ZWL],
description: Make payment directly from your mobile phone.,
id: 1,
maximumAmount: 50000.0,
minimumAmount: 2.0,
name: Ecocash,
processingPaymentMessage: Please enter PIN on the phone that is making the payment.,
redirectRequired: false,
redirectURL: null,
requiredFields: [
RequiredField(
displayName: Phone Number,
fieldType: TEXT,
name: customerPhoneNumber,
optional: false
)
]
)
```### Perform Web Transaction
This relies on the returned web `redirectUrl` that customers can use to complete the transactionFirst step would be to create the transaction:
```dart
final Transaction transaction = pesepay.createTransaction(
amount: 1,
currencyCode: 'ZWL',
transactionDescription: 'Bag of potatoes',
transactionReference: '111-222-333'
)
```Then process the transaction:
```dart
final TransactionResponse response = await pesepay.initiateWebTransaction(transaction);
```If the above execution results in any error either within the package itself or from the Pesepay server side you should except a `PesepayException`. So it would be helpful to handle that.
### Perform Seamless Transaction
First step here would be to create the transaction:
```dart
final SeamlessTransaction seamlessTransaction = pesepay.createSeamlessTransaction(
customerName: 'Cool Name',
customerEmail: 'yourmail@email.com',
customerPhone: '0777111111',
amount: 1,
currencyCode: 'ZWL',
transactionDescription: 'Banana Peel',
transactionReference: '111-222-333',
paymentMethodCode: paymentMethodCode,
);
```Process the seamless transaction:
```dart
final TransactionResponse response = await pesepay.initiateSeamlessTransaction(transaction);
```### Check transaction status
```dart
final TransactionResponse response = await pesepay.checkTransactionStatus(pollUrl);
```### Serverless Checkout ?
Instead of using delays to check transaction status you can also `stream` the `TransactionResponse` using the poll url.- `pesepay.streamTransactionResponse(..)` takes a required `pollUrl` string and optional `streamInterval` in seconds which is the interval to poll the url, default to `20` sec
- You can stream status and show current transaction status on UI to user with a `StreamBuilder(..)` like below:```dart
final String pollUrl = response.pollUrl;// in Widget build(..) method
// you can do something like
StreamBuilder(
stream: pesepay.streamTransactionResponse(pollUrl),
builder: (context, AsyncSnapshot snapshot) {
if(snapshot.hasData) {
final TransactionResponse response = snapshot.data!;
return response.paid ? SuccessWidget() : OtherWidgetsForErrorOrWaiting();
} else {
return CircularProgressIndicator();
}
}
)
```### Full Usage Example
```dart
void main() async {
try {
final pesepay = Pesepay(
integrationKey: '',
encryptionKey: '',
resultUrl: '',
returnUrl: '',
);final Transaction transaction = pesepay.createTransaction(
amount: 1,
currencyCode: 'ZWL',
transactionDescription: 'Bag of potatoes',
transactionReference: '111-222-333'
);final TransactionResponse response = await pesepay.initiateWebTransaction(transaction);
// Add a delay before checking status, maybe 20-30 seconds
await Future.delayed(const Duration(seconds: 30))// Check status
final TransactionResponse pollResponse = await pesepay.checkTransactionStatus(response.pollUrl);if (pollResponse.paid) {
// well you've done it
print('I deserve drinks 🍻');
} else {
// not yet pal
print('👎🏿')
}} on PesepayException catch (e) {
print(e.message);
} catch (e) {
// hell
}
}
```---
[dart_install_link]: https://dart.dev/get-dart
[github_actions_link]: https://docs.github.com/en/actions/learn-github-actions
[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg
[license_link]: https://opensource.org/licenses/MIT
[logo_black]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_black.png#gh-light-mode-only
[logo_white]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_white.png#gh-dark-mode-only
[mason_link]: https://github.com/felangel/mason
[very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg
[very_good_analysis_link]: https://pub.dev/packages/very_good_analysis
[very_good_coverage_link]: https://github.com/marketplace/actions/very-good-coverage
[very_good_ventures_link]: https://verygood.ventures
[very_good_ventures_link_light]: https://verygood.ventures#gh-light-mode-only
[very_good_ventures_link_dark]: https://verygood.ventures#gh-dark-mode-only
[very_good_workflows_link]: https://github.com/VeryGoodOpenSource/very_good_workflows