open_payment 3.0.0 copy "open_payment: ^3.0.0" to clipboard
open_payment: ^3.0.0 copied to clipboard

Flutter plugin which lets you seamlessly integrate OPEN Payment Gateway with your Flutter app and start collecting payments from your customers.

Summary pub package #

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 open up a payment page on your app is to create a payment_token. A payment_token can be created by referring to create payment token API. This API should be always called from your server. You will receive payment_token as a response.

Access Token: #

Access key is a unique key which you can generate from your OPEN dashboard.

Android #

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

minSdkVersion 26

iOS #

Minimum supported iOS version 14.0.

Get Started #

Installation #

Add the dependency in pubspec.yaml.

dependencies:
  open_payment: ^3.0.0

Import #

import 'package:open_payment/open_payment.dart';

Usage #

Calling initiate payment function on click of 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
        },
        onError: (String error) {
            // Handle integration error
        });
}

To see the whole implementation check example

Initialize OpenPaymentPayload #

You need to create a payload with the following parameters:

Parameter Description
accessToken(Mandatory) Access key is a unique key which you can generate from your Open dashboard. Throws exception in case of empty string
paymentToken(Mandatory) To create the token using Create Payment Token API. Throws exception in case of empty string
environment(Mandatory) Following ENUM can be passed to this method.PaymentEnvironment.live and PaymentEnvironment.sandbox
logoUrl Image url for setting logo.
mainColor Main color of Layer will be changed to this . Example: #f8c5c5
errorColor Error color (icons/ error lines / error messages) of Layer will be changed to this . Example: #83025c

onTransactionComplete implementation: #

This is called whenever transaction is completed. Along with TransactionDetails passed as parameter. TransactionDetails.status may either captured, failed , pending and 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 errors.

onError: (String error) {
    // Handle integration error
}
7
likes
150
pub points
59%
popularity

Publisher

unverified uploader

Flutter plugin which lets you seamlessly integrate OPEN Payment Gateway with your Flutter app and start collecting payments from your customers.

Documentation

API reference

License

MIT (license)

Dependencies

flutter, json_annotation

More

Packages that depend on open_payment