flutter_onepay 1.1.1
flutter_onepay: ^1.1.1 copied to clipboard
One stop payment solution by parish softwares
flutter_onepay #
flutter_onepay
is a Flutter plugin developed by Parish Softwares Private Limited that enables smooth integration with the Onepay payment system. It allows developers to create payment orders, process payments, and retrieve transaction details with minimal setup.
🔧 Features #
- SDK Initialization with API credentials
- Create and manage payment orders
- Secure payment processing
- Retrieve full transaction details
- Session clearing support
- Lifecycle-aware methods:
onResume()
andonDestroy()
📦 Installation #
Add the plugin in your pubspec.yaml
:
dependencies:
flutter_onepay: ^<latest_version>
Then run:
flutter pub get
🚀 Getting Started #
1. Import the package #
import 'package:flutter_onepay/flutter_onepay.dart';
🛠️ Initialize the SDK #
Before using any feature, initialize the SDK with your credentials:
final onepay = ParishSoftwaresOnepay();
await onepay.initialize('<YOUR_API_KEY>', '<YOUR_SECRET_KEY>', OnePayEnvironment.TEST | OnePayEnvironment.LIVE);
📦 Create an Order #
You can create a new order by providing required customer details and amount:
final request = {
"amount": 100,
"customerEmail": "emily.clark@gmail.com",
"customerName": "Emily Clark",
"customerPhone": "9417757511",
};
final order = await onepay.createOrder(request);
if (order != null) {
print("Order ID: ${order.id}");
print("Customer Name: ${order.name}");
print("Amount: ${order.amount}");
}
✅ Response includes:
id
amount
name
phone
email
💳 Process a Payment #
Use the order.id
from the previous step to process the payment:
final result = await onepay.processPayment(order.id);
if (result != null) {
print("Payment processed successfully!");
} else {
print("Payment failed or cancelled.");
}
📄 Get Transaction Details #
Retrieve transaction status and metadata using the order ID:
final details = await onepay.getTransactionDetails(order.id);
if (details != null) {
print("Status: ${details.paymentStatus}");
print("Customer: ${details.customerName}");
print("Amount: ${details.amount}");
}
✅ Response includes:
id
orderId
paymentStatus
customerPhone
customerName
customerEmail
createdAt
amount
🔄 Clear Session #
Always clear the session after completing the transaction:
await onepay.clear();
🔁 Lifecycle Integration #
If you're using the plugin inside a stateful or activity-based context (e.g., FlutterActivity
or a hybrid integration), you should invoke the following methods at appropriate lifecycle points:
onResume #
Call this when your activity or app resumes:
FlutterOnePay.onResume();
onDestroy #
Call this when your activity or app is being destroyed:
FlutterOnePay.onDestroy();
🆘 Support #
For any issues or integration help, please reach out to Parish Softwares Private Limited.
📄 License #
This plugin is distributed under the MIT License.