ConnectIPS Flutter
ConnectIPS Flutter is a Flutter package that simplifies the integration of the Connect IPS payment gateway into your mobile or web applications. It leverages the official Connect IPS documentation for a seamless integration experience.
Features
- Easy integration with Connect IPS payment gateway.
- Supports both staging and live environments.
- Provides widgets and methods to customize payment flows.
- Token-based transaction authentication.
- Supports transaction verification using Basic Authentication.
Getting Started
Prerequisites
- Merchant Enrollment Before integrating ConnectIPS, ensure you have a merchant account. Merchants must enroll their applications through their respective banks by providing the necessary documentation. After successful enrollment, you will receive the following:
- MERCHANTID: Unique integer ID to identify the merchant.
- APPID: Unique string ID for the merchant's application.
- APPNAME: Application name identifying the merchant and its application.
- CREDITOR.pfx: Digital certificate file for signing tokens.
- URLs for Redirection You must provide the following URLs for transaction redirection:
- Success URL: Redirected upon successful payment.
- Failure URL: Redirected upon failed payment or manual return.
Setting Up
-
Storing and accessing the private key Store the key from
CREDITOR.pfx
file as an environment variable in your backend or any cloud storage and retrieve it using secure server side code like creating a authenticated request to get the token. It is bad practice to keep private keys in the app. -
Add Dependency Add
connect_ips_flutter
to your pubspec.yaml:
dependencies:
connect_ips_flutter: any
- Import the Package
import 'package:connect_ips_flutter/connect_ips_flutter.dart';
Usage
Configuration
Set up your configuration using CIPSConfig
:
final config = const CIPSConfig.stag(
creditorKey: '<-- your authenticated server-side request to get the token -->',
merchantID: '<merchant_id>',
appID: '<app_id>',
appName: '<app_name>',
transactionID: '<unique_transaction_id>',
successUrl: 'https://example.com/success',
failureUrl: 'https://example.com/failure',
transactionAmount: 1000, // Amount in paisa
);
You can create a unique transaction id by also using a utiltiy function generateTransactionID([int length = 20])
. This helper function will generate a unique transaction id of given length
. Optional param length
default to 20
.
Note: Transaction ID can be only maximum of 20 characters. For more info and other related character information, visit Merchant Interface docs.
For production, use CIPSConfig.live
.
Payment Integration
- Using Payment Button
ConnectIPSPaymentButton(
config: config,
onMessage: (connectIPS, {description, event, needsPaymentConfirmation, statusCode}) {
log('Message: $description, Event: $event, Status Code: $statusCode');
},
onPaymentResult: (paymentResult, connectIps) {
log('Payment Result: $paymentResult');
},
);
- Using Custom Instance
late ConnectIps connectIps;
@override
void initState() {
super.initState();
connectIps = ConnectIps(
config: CIPSConfig.stag(...),
onMessage: (connectIPS, {description, event, needsPaymentConfirmation, statusCode}) {
log('Description: $description, Status Code: $statusCode');
connectIPS.close(context);
},
onPaymentResult: (paymentResult, connectIps) {
log('Result: $paymentResult');
connectIps.close(context);
},
onReturn: ([payment]) {
log('Redirection after payment: $payment');
},
);
}
void initiatePayment() {
connectIps.open(context);
}
Transaction Verification
Verification is done via Basic Authentication using a username and password provided by NCHL:
final vConfig = VerificationConfig(
username: '<username>',
password: '<password>',
);
Add this to your payment button or custom instance for transaction verification.
Testing
To create a test credentials for payment, use the following link for registering a test account. After creating a test account, consult with NCHL team to link a test bank account.
Contributions
Contributions are welcome! Feel free to report issues or submit pull requests to improve this project.
Stay Connected
For further details, refer to the official documentation.