Paymentgateway Plugin Flutter

Flutter plugin for Paymentgateway SDK.

pub package

Getting Started

This flutter plugin is a wrapper around our Android and iOS SDKs.

The following documentation is only focused on the wrapper around our native Android and iOS SDKs.

Prerequisites

Development Tools:

  • Xcode 15 and above
  • Flutter 3.3.0 & Dart 3.4.4 and above

Installation

This plugin is available on Pub: https://pub.dev/packages/payment_gateway_plugin

Add this to dependencies in your app's pubspec.yaml

payment_gateway_plugin: ^4.0.1

Note for Android: Make sure that the minimum API level for your app is 19 or higher.

In android project add this dependencies in build.gradle file

dependencies {
    .
    .
    .
    // This is one of the dependency
    implementation 'androidx.appcompat:appcompat:1.6.1'
}

Note for iOS: Make sure that the minimum deployment target for your app is iOS 13.0 or higher. Also, This is not support SIMULATOR you can run onlly in real iPhone devices.

Run flutter packages get in the root directory of your app.

Usage

Sample code to integrate can be found in example/lib/main.dart.

Import package

import 'package:payment_gateway_plugin/payment_gateway_plugin.dart';

Create Paymentgateway instance

PaymentGatewayPlugin.open(
          '<PAYMENT_URL>', request)

Passing Payment params and URL

// For payment parammeters to refer 
// https://pgandroidintegrations.docs.stoplight.io/request-param-list

var params = {
'api_key': '<API_KEY>',
'hash': '<HASH_KEY>',
'order_id': 'TEST4000',
'mode': 'LIVE',
'description': 'Test',
'currency': 'INR',
'amount': '2',
'name': 'Senthil',
'email': 'emailsenthil@test.com',
'phone': '9597403366',
'city': 'Chennai',
'state': 'Tamilnadu',
'country': 'IND',
'zip_code': '630501',
'address_line_1': 'ad1',
'address_line_2': 'ad2',
'return_url': 'http://localhost:8888/paymentresponse'};

PaymentGatewayPlugin.open(
          '<PAYMENT_URL>', params)

Accessing response

void open(Map<String, dynamic> request, BuildContext context) async {
  try {
    print("Request Params => " + request.toString());
    response = await PaymentGatewayPlugin.open('https://pgbiz.omniware.in', request);

    if (response != null) {
      print("Response => ${response.toString()}"); // This prints the map to console
      String status = response['status'] ?? 'Unknown';
      String responseMessage = response['response']?.toString() ?? 'No response';

      setState(() {
        paymentResponse = "Status: $status\nResponse: $responseMessage";
      });
    } else {
      setState(() {
        paymentResponse = "No response received from the payment gateway.";
      });
    }
  } on PlatformException {
    setState(() {
      paymentResponse = 'Failed to initiate payment.';
    });
  }
}

List of Request Parameters

Request parameters are the parameters that will be send to our server API for payment initiation. Client should store the order id and the amount before payment initiation and compare it with the order id and amount in the response Json from our server post payment process to ensure no end user tampering on the requested parameters.

Please use this link for all params reference link

For UPI Payments Applications

Add the below given code to your info.plist

<dict>
    ...
    <key>LSApplicationQueriesSchemes</key>
	<array>
		<string>upi</string>
		<string>credpay</string>
		<string>gpay</string>
		<string>phonepe</string>
		<string>paytmmp</string>
		<string>mobikwik</string>
		<string>com.amazon.mobile.shopping</string>
		<string>bharatpe</string>
		<string>freecharge</string>
		<string>payzapp</string>
		<string>myjio</string>
		<string>bhim</string>
		<string>slice</string>
        ...
	</array>
    ...
</dict>

For Android SDK to Work

Add this code snippet to

<project_root>/android/settings.gradle

...
include ":app"
include ":payment_gateway_plugin"
...

<project_root>/android/app/build.gradle

...
dependencies {
    implementation 'androidx.appcompat:appcompat:1.6.0'
    // Other dependencies
    ...
}
...

Make Sure that you have these codes at the respected locations

<project_root>/android/app/src/main/res/values/colors.xml

<resources>
    ...
    <color name="colorPrimary">#FF6200EE</color>
    <color name="colorPrimaryDark">#FF3700B3</color>
    <color name="colorAccent">#FF03DAC5</color>
    ...
</resources>

<project_root>/android/app/src/main/res/values/styles.xml

<resources>
    ...
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>
    ...
</resources>