flutter_payunit 0.0.12 copy "flutter_payunit: ^0.0.12" to clipboard
flutter_payunit: ^0.0.12 copied to clipboard

The new Pay Unit SDK Package facilitates the intergration of payments on your applications with a single button and on the go.

Nest Logo

Welcome to The Pay Unit Flutter SDK Seamlessly accept and manage payments in your app

Pub Version GitHub repo size GitHub issues GitHub Repo stars GitHub forks GitHub code size in bytes Website Twitter Follow Website

Description #

Pay Unit SDK Package facilitates the intergration of payments on your applications with a single button and on the go.

Installation #

Run this command:

With dart #

dart pub add flutter_payunit 

With Flutter #

flutter pub add flutter_payunit

Manually #

dependencies:
  flutter_payunit: <latest_version>

Import package #

import 'package:flutter_payunit/flutter_payunit.dart';

Add the PayUnitButton #

PayUnitButton(
              apiUsername: "<Your apiuser>",
              apiPassword:  "<Your apiPassword>",
              apiKey: "<Your apiKey>",
              mode: 'live', // live or test
              paymentCountry: '<Transaction country>'
              notifyUrl: "<Your notification url>",
              returnUrl: "<Your return url>",
              totalAmount: "<Your transaction amount>",
              currency:"XAF", 
              buttonTextColor: Colors.white,
              buttonText: "Pay now",
              width: double.infinity
              color: Colors.orange
              actionAfterProccess: (transactionId, transactionStatus, phoneNumber, transactionGateway) {
               // a callback that has transactionId, transactionStatus, phoneNumber and transactionGateway
              },
              onPaymentInitiated: (transactionId, phoneNumber, transactionGateway) {
                // In case user closes the app before transaction status is gotten,
                // store transaction details locally and constantly check status anywhere from app
                // For more info on getting transaction status, check: https://developer.payunit.net/rest-api/get-payment-status
                // An example function to get transaction status is provided below
              },
          ),

Check transaction status in background #

// USe this function to check transaction status in background when user closes app.
  Future<Map<String, dynamic>> getTransactionStatus({
    required String xApiKey,
    required String apiUserName,
    required String apiPassword,
    required String mode,
    required String transactionId,
  }) async {
    final dioClient = Dio(
      BaseOptions(
        baseUrl: "https://gateway.payunit.net",
        connectTimeout: const Duration(seconds: 15),
        contentType: 'application/json',
      ),
    );
    final token = base64.encode(utf8.encode('$apiUserName:$apiPassword'));
    final response = await dioClient.get(
      '/api/gateway/paymentstatus/$transactionId',
      options: Options(
        headers: {
          'Authorization': 'Basic $token',
          'x-api-key': xApiKey,
          'mode': mode,
        },
      ),
    );
    // final status = response.data['data']['transaction_status'];
    return response.data;
  }

PayUnit Button Parameters #

  • apiUsername : Your apiUsername is provided on your payunit dashboard and looks like "xxxxxx-xxxxxxx-xxxxxx-xxxxxx"
  • apiPassword : Your apiPassword is provided on your payunit dashboard and looks like "xxxxxx-xxxxxxx-xxxxxx-xxxxxx"
  • apiKey : Your application token eg sand_xxxxxx or live_xxxxxx
  • Mode : Your Mode can either be test or live.
  • Currency : The currency of your transaction eg XAF for FCFA
  • buttonTextColor: Custom the color of the text PayUnit button
  • color : Use this to customise the backgroun color of the PayUnit Button
  • actionAfterProccess : Here is the action which starts after the end of the payment, you can perform some operation here, like display an alertDialog after the end of the payment.
  • onPaymentInitiated : In case user closes the app before transaction status is gotten, store transaction details locally and constantly check status anywhere from app.
  • transactionId, transactionStatus and phoneNumber are callBack parameters of the actionAfterProccess function, don't modify them .

Gallery #

gallery - Copy

Clients #

clients - Copy
2
likes
160
points
722
downloads

Publisher

unverified uploader

Weekly Downloads

The new Pay Unit SDK Package facilitates the intergration of payments on your applications with a single button and on the go.

Repository (GitLab)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

auto_size_text, dio, flutter, intl, logger, url_launcher

More

Packages that depend on flutter_payunit