flutterwave_momo_ghana 1.0.2 copy "flutterwave_momo_ghana: ^1.0.2" to clipboard
flutterwave_momo_ghana: ^1.0.2 copied to clipboard

outdated

Your users can pay you using MOMO in Ghana within your flutter app. It uses Flutterwave API.

flutterwave_momo_ghana #

A package to process momo payments within your app, currently supporting payments exclusively in Ghana. To use it, simply call its constructor with the data you wish to submit for the payment. It is a widget with a body and few UI elements so treat it like another screen/widget in your app that you send users to when they want to pay. Collect the payment details from the user whichever way you like. All that matters is that you are calling the constructor with the correct inpupts.

How to use #

So you have collected the payment details from the user and stored it somewhere, could in your state or from some persistent storage. When you are ready to initiate a payment, Navigate to this widget by calling its constructor with the named parameters listed below. Those named params are coming from the users payment details. The widget will handle everything thereafter until the payment is complete assuming correct parameters were passed to it.

How it works #

The transaction takes place in two steps first, the widget makes a call to the flutterwave api backend and displays a circular progress indicator. If the details were valid the server will return a url to finish the payment while simultaneously sending an OTP to the user to confirm. The widget will then redirect the user to a screen where they input the OTP code they received. If valid, the transaction is complete and your redirect url (if supplied) will receive the transaction details.

Important note #

After calling the constructor you must redirect the user (Navigate) to this widget. Otherwise the process will go on alright, but the user cannot see the input box where they need to input their OTP complete it.

Input params #

The constructor accepts several named param. some of which are required and others are not.

amount - required

The amount to charge (required) please modify you setting in flutterwave dashboard for who pays for the transaction fee. whatever is in you settings will be used

phone_number - required

This is the phone number connected to the MOMO account you wish to charge. If must be supplied as a 10-digit valid phone number. Please not that an OTP will be sent to the number you provide (your user). If the number is wrong but valid, then someone else may receive the OTP and your cannot complete the payment

secret_token - required

The secret key you get from your flutterwave api tab. There is a public key and encryption key. Don't use those use the secret key

network - required

This is the network provider of the of number you have supplied. Can be one of [MTN, VODAFONE, TIGO] these are the only supported network at this time

currency - not required

The currency in which the amount is quoted, default is "GHS". If not supplied, the amount will be interpreted as Ghana Cedi (GHS) To change it, please look at the flutterwave documentation for the list of currencies supported and their short forms. DO NOT SUPPLY THE FULL FORM OF THE CURRENCY, JUST THE SHORT FORM

email - not required

Email address of the person making the payment to you. If not given someone@example.com will be used

transaction_ref - not required

This is the transaction reference you want to assign to this transaction. It must be unique for each transaction. This is useful if you want to track transactions in you app later. You are free to generate the reference whatever way you choose. If not supplied, we will assign a random reference to each transaction. if not supplied transaction will just terminate at the end

redirect_url - not required

This is a url and will be verified. If valid the api will send a confirmation of the transaction to this url as query parameters. This is useful for cases where you want to store successful transactions in your database or something similar. You can designate a url from your own api to receive this data and process the way want

full_name - not required

The name of the person you are charging. It is not required but you can include it so that you will know who did the payment

Example code #

import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:flutterwave_momo_ghana/flutterwave_momo_ghana.dart';
import 'package:flutter/material.dart';

class FlutterwaveMOMOGhanaExampleClass extends StatefulWidget {
  @override
  _FlutterwaveMOMOGhanaExampleClassState createState() => _FlutterwaveMOMOGhanaExampleClassState();
}

class _FlutterwaveMOMOGhanaExampleClassState extends State<FlutterwaveMOMOGhanaExampleClass> {
  String amount = "10";
  String secret_token = "Your-secret-token-here";
  String currency = "GHS";
  String email = "someone@example.com";
  String transaction_ref = "some-reference-number-you generated";
  String phone_number= "valid-ghanaian-phone-number";
  String network = "MTN | VODAFONE | TIGO";
  String redirect_url = "your-magic-api-link";
  String full_name = "Fellow Ghanaian";

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
      // YOUR INPUT COMPONENTS GO HERE TO COLLECT THE INFORMATION YOU NEED
        FormField(),
        FormField(),
        FormField(),
        FormField(),

        FlatButton(
          child: Text("Proceed to pay"),
          onPressed: (){
          // validate you form input to make sure you have the correct inputs
          // then redirect the user to the widget inputing the correct data
          Navigator.of(context).push(
              CupertinoPageRoute(builder: (context) =>
              FlutterwaveGhanaMOMO(amount: amount, phone_number: phone_number, network: network, currency: currency, secret_token: secret_token, redirect_url: redirect_url, email: email, transaction_ref: transaction_ref, full_name: full_name,),
              ),
          );
          //
        }
        ,)

      ],
      //
    );
  }
}

7
likes
30
pub points
10%
popularity

Publisher

unverified uploader

Your users can pay you using MOMO in Ghana within your flutter app. It uses Flutterwave API.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, http, uuid, webview_flutter

More

Packages that depend on flutterwave_momo_ghana