ipg_flutter is a Flutter plugin that allows merchants registered with Spemai (Pvt) Ltd to securely save their customersβ card details and retrieve them later for fast and secure payments.
Features
- Securely save customer card details
- Retrieve saved cards
- Perform card-based payments with previously saved cards
- Three powerful callback handlers:
addCardEventCallbackβ card addition statusgetCustomersEventCallbackβ returns saved cardscustomerPaymentEventCallbackβ returns payment results
Getting started
Add the dependency in your pubspec.yaml:
dependencies:
ipg_flutter: ^1.1.3
Usage
var ipg = Ipg.init(
appToken: 'your_token',
appId: 'your_app_id',
firstName: 'John',
lastName: 'Doe',
email: 'john.doe@sample.com',
phoneNumber: '0000000000',
);
// Start card addition flow
ipg.addNewCard(context);
// Callback when card add flow completes
ipg.addCardEventCallback = (status, errorMessage) {
print("Adding card result: $status - $errorMessage");
};
// Retrieve customer list (saved cards)
ipg.getCustomers();
// Callback when customers are retrieved
ipg.getCustomersEventCallback = (customerList, errorMessage) {
print("Customers: $customerList");
};
// Make customer payment
// Valid Currency codes: LKR, USD
ipg.makeCustomerPayment(amount, currencyCode, customerCardToken);
// Listen to payment status
ipg.customerPaymentEventCallback = (status, errorMessage ) {
print("Payment Status: $status - $errorMessage");
};
Android Setup
Since this package communicates with the internet, make sure you have added the following permission in your AndroidManifest.xml file:
<uses-permission android:name="android.permission.INTERNET" />
π¦ Example
Clone the repo and run the example:
cd example
flutter create
flutter run
You can also view the code in the example/ folder.
π§© API Reference
| Method | Description |
|---|---|
Ipg.init(...) |
Initializes the IPG with merchant/user |
ipg.addNewCard(context) |
Launches secure add-card flow |
ipg.makeCustomerPayment(amount, currencyCode, customerCardToken) |
Make Customer payment using tokenized card |
ipg.getCustomers() |
Fetches list of saved customer cards |
addCardEventCallback |
Callback for add card result |
getCustomersEventCallback |
Callback for saved customers |
paymentStatusCallback |
Callback for payment completion status |
β οΈ Special Instruction
Make sure to use the same
environment appId(dev, staging, or production) when adding cards and when making payments.
For example, if you use your development app_id when calling:
var ipg = Ipg.init(
appToken: 'your_token',
appId: 'your_app_id',
);
ipg.addNewCard(context);
then you must also use the same environment app_id with customer_token when calling:
ipg.makeCustomerPayment(amount, currencyCode, customerCardToken);
If you instead use a different environment (e.g., dev app_id to add card, then prod app_id to pay), Spemai backend will reject the request because the card was added under a different environment.---
β FAQ
Is this plugin secure?
Yes, it uses encrypted communication and secure storage through Spemai's backend.
Can any app use this?
Only merchants registered with Spemai (Pvt) Ltd can use this plugin via provided credentials.
Which platforms are supported?
- β Android
- β iOS
- β Web (planned)
π License
π Links
Libraries
- bloc/3ds_bloc
- bloc/add_new_card_bloc
- bloc/ipg_bloc
- ipg_config
- ipg_flutter
- models/create_customer_token_request
- models/create_customer_token_response
- models/customer_list_response
- models/customer_payment_request
- models/customer_payment_response
- models/three_d_s_status_response
- networking/http_client
- networking/response
- repository/customer_repository
- resources/colors
- resources/images
- resources/strings
- screens/3ds_screen
- screens/add_new_card_screen
- util/card_number_input_formatter
- util/card_type_detection
- util/common_alert_dialogs
- util/custom_exception
- util/expiry_date_input_formatter
- util/extensions
- util/rsa_encryption_helper
- widgets/inter_bold_text
- widgets/inter_medium_text
- widgets/inter_regular_text
- widgets/inter_regular_text_filed
- widgets/rounded_text_field