Integrate easily the Paygate Global Platform into your Flutter app

Overview

Integrate easily the Paygate Global Platform into your Flutter app

Features

  • Implement payment with the Paygate Global Platform.
  • Support for two payment providers : T-Money and Moov Money.

Defining terms uses

  • Transaction identifier : identifier you generate yourself (or let this plugin generate) and with which you will be able to identify the transaction and check it's status.
  • Transaction amount : amount of money you want to take from user mobile money account.
  • Transaction callbackUrl : url you want to be called when the transaction is completed.
  • Transaction provider : providers are (at this instant) MoovAfrica (MoovMoney) and Togocom (TMoney).
  • Transaction Reference : reference generated by Paygate Global itself. You can also use it to check transaction status.

Getting started

Before you start to use this package, you need to have a Paygate API Key. Create an account on the Paygate Website, fill your E-Commerce platform informations and you will receive your account APi Key.

Usage

First of all you need to initialize the plugin. Just call the Paygate.init() method. This method require your production Paygate API Key. You can also configure the API version you want to use per default when you call the pay method without specifying the version to use (if not specified the second method is used per default).

Paygate.init(
  apiKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
  apiVersion: PaygateVersion.v1, // default PaygateVersion.v2
  apiKeyDebug: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', // optional
  identifierLength: 20, // optional, default 20
);

You can initialize with a additionnal API key used when you are in debug. You can also specify the default length of the identifiers generated by the plugin (default = 20).

Init a new transaction

Paygate has two API versions. Depends on when you want to make a request post, or use the preconfigured payment page with a get request.

  1. You make a post request and Paygate return the payment transaction reference with which you can check later the transaction status.
NewTransactionResponse response = await Paygate.payV1(
    amount: 1000,
    provider: PaygateProvider.moovMoney, // required : PaygateProvider.moovMoney or PaygateProvider.tMoney
    identifier: 'TR000000010', // optional : if empty, the transaction identifier will be generated by the plugin.
    description: 'My awesome transaction', // optional : description of the transaction
    phoneNumber: '90010203', // required : phone number of the user
);
  1. You make a get request to a payment page provided and secured by Paygate.
NewTransactionResponse response = await Paygate.payV2(
    amount: 1000,
    callbackUrl: 'https://myapp.com/callback',
    provider: PaygateProvider.moovMoney, // required : PaygateProvider.moovMoney or PaygateProvider.tMoney
    identifier: 'TR000000010', // optional : if empty, the transaction identifier will be generated by the plugin.
    description: 'My awesome transaction', // optional : description of the transaction
    phoneNumber: '90010203', // required : phone number of the user
);

Once payment is made by the customer, PayGateGlobal will send a confirmation message to the e-commerce return URL (If previously provided). The message is HTTP Post Method, served with JSON payload, structured as follows:

Property Description
tx_reference Unique identifier generated by PayGateGlobal for the transaction
identifier Internal identifier of the e-commerce transaction.
payment_reference Payment reference code generated by Flooz.
amount Amount paid by customer
datetime Payment Date and Time
phone_number Telephone number of the customer who made the payment.
payment_method Payment method used by the customer. Possible values: FLOOZ, T-Money.

With either method 1 or 2, user never quit the application. This package use the custom_tabs package to open the Paygate Global payment page, when you the API version 2.

Check the transaction status

After you have initialized a transaction, you can check the status of the transaction with the verify method, called on the response (NewTransactionResponse) object. Or either juste the static method verifyTransaction, which require the transaction reference or the identifier.

if (response.ok) {
    saveReference(response.txReference); // or save the identifier in your database saveIdentifier(response.identifier);
} else {
    // Retry or debug (a message will be displayed in the console).
    /// You can access the exception with response.exception .
}

// After a delay, you can check the transaction status.
Transaction transaction = await response.verify(); 

// or 

Transaction transaction = await Paygate.verifyTransaction(response.txReference); // or Paygate.verifyTransaction(response.identifier);

Please check the example directory for a complete example with suitable UI implementations.

Additional information

I have wrote a article about this package on my blog which contains more detailled informations.

File free to contribute or fill issues when you use this package.

You might also like...

The diozz package helps you to deal with APIs easily and speed up the process of writing code.

The diozz package helps you to deal with APIs easily and speed up the process of writing code.

Diozz The diozz package helps you to deal with APIs easily and speed up the process of writing code. Installation Diozz Use that command in the termin

Nov 13, 2022

UME is an in-app debug kits platform for Flutter. Produced by Flutter Infra team of ByteDance

UME is an in-app debug kits platform for Flutter. Produced by Flutter Infra team of ByteDance

flutter_ume English Flutter 应用内调试工具平台 当前版本内置 10 个插件, 开发者可以创建自己的插件,并集成进 UME 平台。 详见本文为 UME 开发插件部分。 flutter_ume 快速接入 特别说明 功能介绍 为 UME 开发插件 版本说明 兼容性 单测覆盖率

Dec 30, 2022

Pensil Teaching App is an education platform created in flutter.

Pensil Teaching App is an education platform created in flutter.

Pensil Teaching App Pensil Teach App is an education platform created specifically for the tutors of the digital age. Pensil Teaching app reduce gap b

Dec 1, 2022

Get Version - Get the Version Name, Version Code, Platform and OS Version, and App ID on iOS and Android. Maintainer: @rodydavis

Get Version - Get the Version Name, Version Code, Platform and OS Version, and App ID on iOS and Android. Maintainer: @rodydavis

Get Version - Get the Version Name, Version Code, Platform and OS Version, and App ID on iOS and Android.

Jan 4, 2023

Flutter library to add gestures and animations to each Shape you draw on your canvas in your CustomPainter

Flutter library to add gestures and animations to each Shape you draw on your canvas in your CustomPainter

Flutter library to bring your CustomPainter 🎨 to Life ✨ ⚡️ touchable library gives you the ability to add various gestures and animations to each Sha

Jan 7, 2023

A comprehensive, cross-platform path manipulation library for Dart.

A comprehensive, cross-platform path manipulation library for Dart. The path package provides common operations for manipulating paths: joining, split

Dec 29, 2022

Easy to use cross-platform regex replace command line util

replace Easy to use cross-platform regex replace command line util. Can't remember the arguments to the find command? or how xargs works? Maybe sed is

Feb 1, 2022

Uproot(uprt) is a multi-platform (Windows, MacOs, and Linux) command line utility written in Dart to convert a router's DHCP IP Reservations between routers

Uproot(uprt) is a multi-platform (Windows, MacOs, and Linux) command line utility written in Dart to convert a router's DHCP IP Reservations between routers

UPROOT Uproot(uprt) is a multi-platform (Windows, MacOs, and Linux) command line utility written in Dart to convert a router's DHCP IP Reservations be

Jan 1, 2023

Flutter App which lets you share memes among your friends.

Flutter App which lets you share memes among your friends.

meme_share_app About App Flutter App which lets you share memes among your friends . Here one have 2 options : NEXT : Load Next Meme. SHARE : To Share

Oct 30, 2021
Owner
Kokou AGBAVON
Flutter & mobile stacks lover. JAMstack enthusiast. Humanist. Africa future optimist. Child of internet.
Kokou AGBAVON
Open source SDK to quickly integrate subscriptions, stop worring about code maintenance, and getting advanced real-time data

Open source SDK to quickly integrate subscriptions, stop worring about code maintenance, and getting advanced real-time data. Javascript / iOS glue framework

glassfy 8 Oct 31, 2022
A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully & easily modifiable.

A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully

Muhammad Hamza 20 Jun 7, 2022
A flutter utility to easily create flavors in your flutter application

Flutter Flavorizr A flutter utility to easily create flavors in your flutter application Getting Started Let's start by setting up our environment in

Angelo Cassano 268 Jan 1, 2023
A dart package to help you parse and evaluate infix mathematical expressions into their prefix and postfix notations.

A dart package to help you parse and evaluate infix mathematical expressions into their prefix and postfix notations.

Miguel Manjarres 2 Jan 28, 2022
Easily swap Flutter web renderers at runtime

renderer_switcher Swap Web Renderers in a Flutter Web app at runtime. Installation To use this plugin, add renderer_switcher as a dependency in your p

Wilson Wilson 12 Oct 21, 2022
A Flutter library to make Rest API clients more easily. Inspired by Java Feing.

A Flutter library to make Rest API clients more easily. Inspired by Java Feing. Features Facilitated JSON encode and decode using common interfaces. F

null 2 Mar 15, 2022
A Dart package to web scraping data from websites easily and faster using less code lines.

Chaleno A flutter package to webscraping data from websites This package contains a set of high-level functions that make it easy to webscrap websites

António Nicolau 30 Dec 29, 2022
Volt is a wrapper over the Revolt API for easily writing bots using the Dart language.

Volt is a wrapper over the Revolt API for easily writing bots using the Dart language. It is currently in active development so not all of the functionality has yet been implemented.

null 8 Dec 13, 2022