zainpay 0.1.16 copy "zainpay: ^0.1.16" to clipboard
zainpay: ^0.1.16 copied to clipboard

A flutter package to implement zainpay on your flutter application.

Zainpay Flutter Package #

The Flutter library helps you create seamless payment experiences in your flutter mobile app.

Table of Contents #

  1. Requirements
  2. Installation
  3. Usage
  4. License

Requirements #

  1. Zainpay Account API Keys
  2. Supported Flutter version >= 1.17.0

Installation #

  1. Add the dependency to your project. In your pubspec.yaml, file add: zainpay: 0.1.15.
  2. Run flutter pub get.

Usage #

Initializing a Zainpay instance #

To create an instance, you should call the Zainpay constructor. This constructor accepts a mandatory instance of the following:

  • context
  • fullName
  • email
  • publicKey
  • callBackUrl
  • mobileNumber
  • zainboxCode
  • transactionRef
  • amount
  • isTest

It returns an instance of Zainpay which we then call the async method .charge() on.

_handlePaymentInitialization() async {

    final Zainpay zainpay = Zainpay(
        context: context,
        fullName: fullNameController.text,
        email: emailController.text,
        publicKey: getPublicKey(),
        callBackUrl: "https://localhost:8080/success",
        mobileNumber: phoneController.text,
        zainboxCode: getZainBoxCode(),
        transactionRef: getRandomString(12),
        amount: amountController.text,
        isTest: true
    );

    final PaymentResponse? response = await zainpay.charge();

    if (response != null) {
        debugPrint("${response.toJson()}");
    } else {
        debugPrint("No Response");
    }
}

Handling the response #

Calling the .charge() method returns a Future of PaymentResponse? which we await for the actual response as seen above.

final PaymentResponse? response = await zainpay.charge();

if (response != null) {
    showLoading(response.status!);
    debugPrint("${response.toJson()}");
} else {
    showLoading("No Response!");
}

Note:

  1. PaymentResponse can be null if a user cancels the transaction by pressing back.
  2. You need to confirm the transaction is successful. Ensure that the txRef, amount, and status are correct and successful.
  3. Be sure to verify the transaction details before providing value.

License #

By contributing to the Flutter library, you agree that your contributions will be licensed under its MIT license.

Copyright (c) zainpay.ng

0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

A flutter package to implement zainpay on your flutter application.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

awesome_card, cupertino_icons, flutter, flutter_inappwebview, fluttertoast, font_awesome_flutter, http, intl, overlay_support

More

Packages that depend on zainpay