This flutter plugin lets you seamlessly integrate OPEN Payment Gateway with your flutter app and start collecting payments.

To know more about our SDKs and how to link them within the projects, refer to the documentation.

Pre-Requisites

Payment Token

A payment token represents an order or a purchase. The first step to opening up a payment page on your app is to create a payment_token. A payment_token can be created by referring to the create payment token API. This API should always be called from your server. You will receive a payment_token as a response.

Access Token

The access key is a unique key that you can generate from your OPEN dashboard.

Android

Change the minSdkVersion in your build.gradle file in the android/app/build.gradle has

minSdkVersion 19 

IOS

Minimum supported iOS version 14.0.

Get Started

Installation

Add the dependency in pubspec.yaml.

dependencies:
       open_payment: ^2.0.0

Import

import 'package:open_payment/open_payment.dart';

Usage

Calling initiate payment function on click of a button.

floatingActionButton: FloatingActionButton(
         child: const Icon(Icons.add),
             onPressed: onPaymentClick,
)

onPaymentClick function

Future<void> onPaymentClick() async {
    OpenPaymentPayload openPaymentPayload =
OpenPaymentPayload(
        accessToken: "your-access-token",
        paymentToken: "payment-token",
        environment: PaymentEnvironment.live,
//PaymentEnvironment.sandbox
        logoUrl: "your-logo-url",
        mainColor: "#83025c",
        errorColor: "#ff0000"
    );
    await OpenPayment.initiatePayment(
        openPaymentPayload: openPaymentPayload,
        onTransactionComplete: (TransactionDetails
transactionDetails) {
            // Handle transaction result
}

To see the whole implementation check example.

Initialize Open Payment Payload

You need to create a payload with the following parameters:

ParameterDescription
accessToken(Mandat ory)The access key is a unique key that you can generate from your Open dashboard. Throws an exception in case of an empty string
paymentToken(Mandatory)To create the token using the Create Payment Token API. Throws an exception in case of an empty string
environment(Mandatory)Following ENUM can be passed to this method.PaymentEnvironment.live and
PaymentEnvironment.sandbox
logoUrlImage URL for setting logo.
mainColorThe main color of the Layer will be changed to this.

Example: #f8c5c5
errorColorThe error color (icons/ error lines/error messages) of Layer will be changed to this.

Example: #83025c

onTransaction Complete implementation

This is called whenever a transaction is completed. Along with TransactionDetails passed as a parameter. TransactionDetails.status may either be captured, failed, pending, or cancelled.

πŸ“˜

Note

If onTransactionComplete is invoked it doesn't means that payment is successful. It may fail but transaction is completed is the only purpose.

onTransactionComplete: (TransactionDetails
     transactionDetails) {
         // Handle transaction result
     }

onError implementation

This is called whenever there is an integration error.

onError: (String error) {
         // Handle integration error
}