jio_payment_sdk 0.0.9
jio_payment_sdk: ^0.0.9 copied to clipboard
A Flutter package to integrate Jio Payment Gateway.
Jio Payment SDK for Flutter #
π Table of Contents #
π Overview #
The Jio Payment SDK provides a seamless way to integrate Jio Payments (UPI, NetBanking, Cards, QR, VPA) into your Flutter applications.
Itβs secure, fast, and customizable, built for production-grade payment flows.
β¨ Features #
- π Secure Jio Payments integration
- π³ Supports UPI, NetBanking, QR, VPA, 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.9
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<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: 'JP2000000000031',
aggId: "",
secretKey: "abc",
email: 'test@gmail.in',
userName: 'Test User',
merchantName: 'Reliance',
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),
paymentMethod: PaymentMethod.netBanking,
allowedPaymentTypes: ["CARD", "NB", "UPI_QR","UPI_INTENT","UPI_VPA"],
timeOut: 1000,
);
Callback Handling
Your widgetβs state should implement the PaymentCallback interface to handle payment results.
@override
void onPaymentCompletedResponse(PaymentResult result) {
setState(() => _isPaying = false);
if (result.success) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Payment Successful π"),
backgroundColor: Colors.green,
),
);
Future.delayed(const Duration(seconds: 2), () {
Navigator.pop(context);
});
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Payment Failed β"),
backgroundColor: Colors.red,
),
);
_showFailureDialog();
}
}
Parameters
Parameter | Description |
---|---|
amount |
Amount to be charged (double) |
env |
Environment (JioPaymentEnv.uat or JioPaymentEnv.prod ) |
merchantId |
Provided by JioPay |
secretKey |
Secret key for authentication |
merchantTrId |
Unique transaction ID |
orderSummary |
Details of products in the order |
theme |
Customize payment UI colors |
allowedPaymentTypes |
List of allowed payment modes (CREDIT_CARD , DEBIT_CARD , NB , UPI_QR , UPI_INTENT , UPI_VPA ) |
timeOut |
Timeout in seconds for transaction |
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. - π Rotate keys regularly.
- π‘οΈ Enable obfuscation in production builds.
π‘οΈ ProGuard / Obfuscation #
For Android builds:
flutter build apk --release --obfuscate --split-debug-info=build/debug-info
If you are using ProGuard, add these rules:
-keepattributes *Annotation*
-dontwarn com.yourcompany.jio_payment_sdk.**
-keep class com.yourcompany.jio_payment_sdk.** {*;}