The Tickpay Flutter plugin acts as a wrapper around our native Android and iOS SDKs.

Refer to our Standard Android SDK and Standard iOS SDK documentation for more information on these SDKs.

We recommend you read our Payment Flow document before proceeding with the integration.

Installation

  1. Download the plugin from Pub.dev.
  2. Add the below code to dependencies in your app’s pubspec.yml
    Copytickpay_flutter: 1.1.0

    Minimum Version Requirement:

    • For Android, ensure that the minimum API level for your app is 19 or higher.
    • For iOS, ensure that the minimum deployment target for your app is iOS 10.0 or higher. Also, don’t forget to enable bitcode for your project.
  3. Run flutter packages get in the root directory of your app.

Usage

Sample code to integrate can be found here.

Import package#

Use the below code to import the tickpay_flutter.dart file to your project.
import 'package:tickpay_flutter/tickpay_flutter.dart';

Create Tickpay instance

_tickpay = Tickpay();

Attach Event Listeners

The plugin uses event-based communication and emits events when payments fail or succeed.

The event names are exposed via the constants EVENT_PAYMENT_SUCCESSEVENT_PAYMENT_ERROR and EVENT_EXTERNAL_WALLET from the Tickpay class.

Use the on(String event, Function handler) method on the Tickpay instance to attach event listeners.

_tickpay.on(Tickpay.EVENT_PAYMENT_SUCCESS, _handlePaymentSuccess); _tickpay.on(Tickpay.EVENT_PAYMENT_ERROR, _handlePaymentError); _tickpay.on(Tickpay.EVENT_EXTERNAL_WALLET, _handleExternalWallet);
The handlers would be defined in the class as:
void _handlePaymentSuccess(PaymentSuccessResponse response) { // Do something when payment succeeds } void _handlePaymentError(PaymentFailureResponse response) { // Do something when payment fails } void _handleExternalWallet(ExternalWalletResponse response) { // Do something when an external wallet is selected }
To clear event listeners, use the clear method on the Tickpay instance.
_tickpay.clear(); // Removes all listeners

Setup Options

var options = {
'key': '<YOUR_KEY_ID>',
'amount': 100, //in the smallest currency sub-unit.
'name': 'Acme Corp.',
'description': 'Fine T-Shirt',
'prefill': {
'contact': '6158458785',
'email': 'john.deo@example.com'
}
};

Open Checkout

Use the below code to open the Tickpay checkout.
_tickpay.open(options);

API

Documented below is the API package for the plugin.

Class#

Tickpay

Method (Open Checkout)

The below method opens the checkout.

open(map<String, dynamic> options)

The options map has key as a required property. All other properties are optional. Refer to our standard checkout documentation for a complete list of options for the checkout form.

Method (Register Event Listeners)#

The below method registers event listeners for payment events.

on(String eventName, Function listener)

Method (Clear all Listeners)#

clear()

Scroll to top
Bitnami