Jio Payment SDK for Flutter

pub package License Flutter Version


📑 Table of Contents

  1. Overview
  2. Features
  3. Installation
  4. Usage
  5. Handling Payment JSON Respose
  6. Security
  7. Obfuscation

📖 Overview

The Jio Payment SDK provides a seamless way to integrate Jio Payments (UPI (UPI QR, UPI INTENT, UPI VPA), NetBanking, Cards) into your Flutter applications.
It’s secure, fast, and customizable, built for production-grade payment flows.


✨ Features

  • 🔒 Secure Jio Payments integration
  • 💳 Supports UPI (UPI QR, UPI INTENT, UPI VPA), NetBanking, Cards
  • 📦 Easy to add and configure
  • 🎨 Customizable merchant branding
  • 📱 Example app included

📦 Installation

Add the dependency to your pubspec.yaml:

dependencies:
  jio_payment_sdk: ^0.0.10

Then run:

flutter pub get

⚡ Usage

Import the SDK:

import 'package:jio_payment_sdk/jio_payment_sdk.dart';

Implementing PaymentCallback:

You must implement PaymentCallback in your widget’s state class.

class _HomepageState extends State

For example:

class _HomepageState extends State<Homepage> implements PaymentCallback {
JioPaymentSdk.initializeJioPayments(….){}};
 @override
 void onPaymentCompletedResponse(PaymentResult result) {
 // Handle success/failure here
 print("Payment Response: ${result.jsonData}");
 }

Why is this critical?

  • The SDK returns payment results only through this callback. Without it, you cannot know whether the payment succeeded or failed.

  • This step acts as a bridge between your Flutter UI and the Jio Payment SDK.

Where should it be used?

  • Inside the widget that launches the payment flow (usually Homepage or CheckoutPage).

  • Example: _HomepageState if payment button is placed on Homepage. Think of PaymentCallback as a listener that waits for the payment result.

Initialize payments:

To initialize the Jio Payment SDK, you need to call JioPaymentSdk.initializeJioPayments() with the required configuration.

JioPaymentSdk.initializeJioPayments(
    /// Required Params.............................
    context,
    callback: this,
    amount: am,
    env: JioPaymentEnv.uat, // Change to JioPaymentEnv.prod in production
    merchantId: 'Enter your merchantId',
    aggId: "",
    secretKey: "Enter your secretKey",
    email: 'test@gmail.in',
    userName: 'Test User',
    merchantName: 'Ajio',
    merchantImage: "asset/Ajio logo.png",
    merchantTrId:merchantTxnNo() ,
    isAssetMerchantImage: true,


    /// Optional Params.............................
    orderSummary: OrderSummary(title: "Order Summary", items: orderDetailList),
    addlParam1: "",
    addlParam2: "",
    theme: CustomTheme(primaryColor: const Color.fromRGBO(227, 155, 43, 1), secondaryColor: Colors.black87),
    allowedPaymentTypes: ["CARD", "NB", "UPI_QR","UPI_INTENT","UPI_VPA"],
    timeOut: 1000,

);

Parameters

Parameter Data type Description
amount double The total transaction amount to be charged to the customer.
env JioPaymentEnv Defines the environment for the transaction: JioPaymentEnv.uat (Testing) or JioPaymentEnv.prod (Production).
merchantId String Unique merchant identifier
aggId String Aggregator ID
secretKey String Secret key for authentication
email String Merchant’s registered email ID
userName String Username or business name
merchantName String A name display on sdk (e.g. Reliance, Ajio).
merchantImage String A logo display on sdk (e.g. Reliance or Ajio logo displayed in the payment UI).
merchantTrId String Unique transaction ID for identifying each payment request.
isAssetMerchantImage bool Set to true if merchantImage is from local app assets; otherwise false if it’s a network URL.
orderSummary String Summary or details of the order (e.g., map
addlParam1 String Additional parameter (optional)
addlParam2 String Additional parameter (optional)
theme CustomTheme Customizes the appearance of the payment UI. Example:
dart
theme: CustomTheme(
primaryColor: const Color.fromRGBO(227, 155, 43, 1),
secondaryColor: Colors.black87,
)
allowedPaymentTypes List List of allowed payment modes: ["CARD", "NB", "UPI_QR", "UPI_INTENT", "UPI_VPA"].
timeOut int Timeout duration (in seconds) for the transaction before it expires automatically.

📤 Handling Payment JSON Response

When a payment is completed, the SDK returns a PaymentResult object that includes important transaction data.

Class Definition in sdk


class PaymentResult {
  final bool success;
  final String? transactionId;
  final dynamic jsonData;

  PaymentResult({
    required this.success,
    this.transactionId,
    this.jsonData,
  });
}

Explanation

Parameter Data type Description
success bool Indicates whether the transaction was successful (true) or failed (false).
transactionId String? The unique identifier assigned to the transaction by JioPay.
jsonData dynamic A detailed JSON object returned by the SDK containing full transaction information (e.g. status, reference ID, payment mode, message).

Example Usage

@override
void onPaymentCompletedResponse(PaymentResult result) {
  if (result.success) {
    print("Transaction Successful");
    print("Transaction ID: ${result.transactionId}");
    print("Full JSON: ${result.jsonData}");
  } else {
    print("Payment Failed");
    print("Transaction ID: ${result.transactionId}");
    print("Failure Details: ${result.jsonData}");
  }
}

Open Checkout

In this example, the checkout is triggered in initState() so the payment flow starts as soon as the screen opens.

@override
void initState() {
  super.initState();
  WidgetsBinding.instance.addPostFrameCallback((_) {
    _startPayment();
  });
}

🔒 Security

  • Do not hardcode sensitive keys in your app.
  • ✅ Always keep your secretKey secure.
  • 🛡️ Enable obfuscation in production builds.

Obfuscation

For Android builds:

flutter build apk --release --obfuscate --split-debug-info=build/debug-info

For ios builds:

flutter build ios --release --obfuscate --split-debug-info=build/debug-info

Libraries

jio_payment_sdk