paygic 1.0.3
paygic: ^1.0.3 copied to clipboard
Official plugin of Paygic Upi Payments by Paygic payment gateway. Powered by Yes Bank.
Paygic #
A Flutter plugin for native UPI payments with Paygic. Features a native popup UI with UPI intent support for PhonePe, GPay, Paytm, and more.
Features #
- ✅ Simple Integration - Just 3 parameters needed to start
- ✅ Native popup UI - Beautiful bottom sheet instead of webview
- ✅ UPI Intent support - Launch PhonePe, GPay, Paytm, or any UPI app
- ✅ Real-time updates - Socket.IO integration for instant payment status
- ✅ QR Code - Display QR for scanning with any UPI app
- ✅ UPI ID collect - Enter UPI ID to receive payment request
- ✅ Android & iOS - Full platform support
Installation #
Add to your pubspec.yaml:
dependencies:
paygic: ^1.0.0
Then run:
flutter pub get
Quick Start #
import 'package:paygic/paygic.dart';
// Initiate payment - that's it!
final result = await Paygic.initiatePayment(
context: context,
mid: 'YOUR_MERCHANT_ID', // Get from Paygic
token: 'YOUR_API_TOKEN', // Get from Paygic
amount: 100.0,
merchantReferenceId: 'ORDER123', // Your unique order ID
customerName: 'John Doe',
customerEmail: '[email protected]',
customerMobile: '9876543210',
);
// Handle result
if (result.isSuccess) {
print('Payment successful! UTR: ${result.utr}');
} else if (result.isCancelled) {
print('User cancelled payment');
} else if (result.isFailed) {
print('Payment failed: ${result.errorMessage}');
}
That's all you need! The plugin automatically:
- Creates a payment page via Paygic API
- Establishes real-time socket connection
- Shows the payment UI
- Handles UPI app launching
- Returns the result
Required Parameters #
| Parameter | Type | Description |
|---|---|---|
context |
BuildContext | Required for showing bottom sheet |
mid |
String | Merchant ID (get from Paygic) |
token |
String | API Token (get from Paygic) |
amount |
double | Payment amount (₹1 - ₹1,00,000) |
merchantReferenceId |
String | Your unique order/transaction ID |
customerName |
String | Customer's name |
customerEmail |
String | Customer's email |
customerMobile |
String | Customer's 10 digit mobile |
Payment Result #
final result = await Paygic.initiatePayment(...);
// Check status
if (result.isSuccess) {
// Payment successful
print('UTR: ${result.utr}');
print('Amount: ₹${result.amount}');
} else if (result.isFailed) {
// Payment failed
print('Error: ${result.errorMessage}');
} else if (result.isCancelled) {
// User closed the popup
} else if (result.isPending) {
// Payment pending (rare)
}
PaymentResult Properties #
| Property | Type | Description |
|---|---|---|
status |
PaymentStatus | success, failed, cancelled, pending, timeout |
isSuccess |
bool | Quick check for success |
isFailed |
bool | Quick check for failure |
isCancelled |
bool | Quick check for cancellation |
utr |
String? | Unique Transaction Reference (on success) |
amount |
double? | Transaction amount |
errorMessage |
String? | Error message (on failure) |
rawResponse |
Map? | Raw server response |
Configuration (Optional) #
final result = await PaygicUpi.initiatePayment(
context: context,
mid: 'YOUR_MID',
token: 'YOUR_TOKEN',
amount: 100.0,
merchantReferenceId: 'ORDER123',
customerName: 'John Doe',
customerEmail: '[email protected]',
customerMobile: '9876543210',
// Optional configuration
config: PaymentConfig(
timeout: Duration(minutes: 5),
showQrCode: true,
showUpiIdInput: true,
primaryColorValue: 0xFF2B1966,
),
);
Helper Methods #
Check UPI App Availability #
// Check if any UPI app is installed
final hasUpi = await Paygic.hasUpiApp();
// Get list of installed UPI apps
final apps = await Paygic.getInstalledUpiApps();
// Check specific app
final hasPhonePe = await Paygic.isAppInstalled(UpiApp.phonePe);
Manual Payment Status Check #
final result = await Paygic.checkPaymentStatus(
pageId: 'PAGE_ID',
);
Platform Setup #
Android #
Add UPI intent query in android/app/src/main/AndroidManifest.xml:
<manifest>
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="upi" />
</intent>
</queries>
<!-- ... -->
</manifest>
iOS #
Add URL schemes query in ios/Runner/Info.plist:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>phonepe</string>
<string>gpay</string>
<string>paytm</string>
<string>bhim</string>
<string>upi</string>
</array>
Complete Example #
import 'package:flutter/material.dart';
import 'package:paygic/paygic.dart';
class CheckoutPage extends StatelessWidget {
final double orderAmount = 499.0;
Future<void> _handlePayment(BuildContext context) async {
final result = await Paygic.initiatePayment(
context: context,
mid: 'YOUR_MERCHANT_ID',
token: 'YOUR_API_TOKEN',
amount: orderAmount,
merchantReferenceId: 'ORDER_${DateTime.now().millisecondsSinceEpoch}',
customerName: 'Customer Name',
customerEmail: '[email protected]',
customerMobile: '9876543210',
);
if (result.isSuccess) {
// Navigate to success page
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) => OrderSuccessPage(utr: result.utr!),
),
);
} else if (result.isFailed) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Payment failed: ${result.errorMessage}')),
);
}
}
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () => _handlePayment(context),
child: Text('Pay ₹$orderAmount'),
);
}
}
Example App #
See the example directory for a complete demo app.
cd example
flutter run
Getting Merchant Credentials #
Contact Paygic to get your:
- MID (Merchant ID)
- API Token
Website: paygic.in
Support #
For issues and feature requests, please open an issue.
License #
MIT License - see LICENSE for details.
Made with ❤️ by Paygic