bharat_pay_kit
One API. Ten Indian Payment Gateways. Zero lock-in.
bharat_pay_kit is a production-ready Flutter package that provides a unified, plug-and-play interface for 10 major Indian payment gateways — with a single consistent API, stunning 3D animations, glassmorphism UI components, and full dark/light mode support.
✨ Features
- ⚡ Unified API —
BharatPayKit.init()→BharatPayKit.pay()for any gateway - 🔄 Hot-swap gateways at runtime with
BharatPayKit.switchGateway() - 💳 3D Flip Card —
BharatPayCardWidgetwith auto card-type detection - 🎨 Glassmorphism Sheet —
BharatPaySheetwith staggered entrance animations - ✅ Animated Status Screens — progressive checkmark stroke + confetti / shake X
- 🌀 Processing Animation — rotating gradient arc spinner
- 📱 Gateway Chip Selector — horizontally scrollable, animated pill chips
- 🇮🇳 Indian Currency Formatter — ₹ 1,00,000 / ₹ 1.2L notation
- 🔍 Card Type Detection — Visa, Mastercard, RuPay, Amex from number prefix
- 🌙 Dark / Light Mode — full Material 3 theme support
- 📖 dartdoc on every API — IDE-friendly, pub.dev score optimised
- 🧪 30+ Unit Tests — covering all models, utils, and validators
🏦 Supported Gateways
| Gateway | UPI | Cards | Wallets | Netbanking | Integration |
|---|---|---|---|---|---|
| Razorpay | ✅ | ✅ | ✅ | ✅ | SDK (razorpay_flutter) |
| Cashfree | ✅ | ✅ | ✅ | ✅ | Hosted Checkout URL |
| PhonePe | ✅ | ❌ | ❌ | ❌ | UPI Deep-link |
| Paytm | ✅ | ✅ | ✅ | ✅ | UPI Deep-link |
| Google Pay | ✅ | ❌ | ❌ | ❌ | tez:// Deep-link |
| PayU | ✅ | ✅ | ✅ | ✅ | WebView Checkout |
| Stripe | ❌ | ✅ | ❌ | ❌ | REST API |
| CCAvenue | ✅ | ✅ | ✅ | ✅ | WebView Checkout |
| Instamojo | ✅ | ✅ | ❌ | ❌ | REST API + WebView |
| UPI Generic | ✅ | ❌ | ❌ | ❌ | upi:// Deep-link |
🚀 Installation
Add to your pubspec.yaml:
dependencies:
bharat_pay_kit: ^0.0.1
Or run:
dart pub add bharat_pay_kit
⚡ Quick Start
Step 1 — Initialise
import 'package:bharat_pay_kit/bharat_pay_kit.dart';
// Call once, typically in main() or before your payment screen
BharatPayKit.init(
gateway: PaymentGateway.razorpay,
config: GatewayConfig(
apiKey: 'rzp_test_xxxxxxxxxxxx',
secretKey: 'YOUR_SECRET_KEY',
environment: PayEnvironment.sandbox,
),
);
Step 2 — Create a PaymentRequest
final request = PaymentRequest(
amount: 999.0,
orderId: 'order_unique_123',
customerName: 'Aarav Sharma',
customerEmail: 'aarav@example.com',
customerPhone: '9876543210',
description: 'Premium Subscription',
);
Step 3 — Make the Payment
final response = await BharatPayKit.pay(request, context: context);
if (response.isSuccess) {
print('Payment ID: ${response.paymentId}');
print('Order ID: ${response.orderId}');
} else {
print('Error: ${response.errorMessage}');
}
🧩 Widget Usage
BharatPayButton
BharatPayButton(
amount: 499.0,
label: 'Pay Now',
onPayPressed: () => BharatPayKit.pay(request, context: context),
onSuccess: () => Navigator.pushReplacementNamed(context, '/success'),
onFailure: () => showDialog(...),
showAmount: true,
borderRadius: 14,
height: 56,
)
BharatPaySheet.show()
await BharatPaySheet.show(
context,
gateways: [PaymentGateway.razorpay, PaymentGateway.upiGeneric],
request: request,
configBuilder: (gw) => GatewayConfig(apiKey: _keyFor(gw)),
onSuccess: (response) => print('Paid via ${response.gateway.displayName}'),
onFailure: (response) => print('Failed: ${response.errorMessage}'),
);
BharatPayCardWidget
BharatPayCardWidget(
cardNumber: '4111111111111111',
cardHolderName: 'Priya Patel',
expiryDate: '08/27',
cvv: '456',
// cardType auto-detected as CardType.visa
)
BharatPayStatusWidget
BharatPayStatusWidget(
response: paymentResponse,
onContinue: () => Navigator.pop(context), // success
onRetry: () => Navigator.pop(context), // failure
successMessage: 'Booking Confirmed!',
)
BharatPayGatewaySelector
BharatPayGatewaySelector(
gateways: PaymentGateway.values,
initialSelected: PaymentGateway.razorpay,
onGatewaySelected: (gw) {
BharatPayKit.switchGateway(gateway: gw, config: configFor(gw));
},
)
📱 Platform Support
| Platform | Support |
|---|---|
| Android | ✅ Full |
| iOS | ✅ Full |
| Web | ⚠️ Partial (UPI deep-links not supported on web) |
📸 Screenshots



🔧 Gateway-Specific Setup
Razorpay
- Sign up at dashboard.razorpay.com
- Get your Test API Key from Settings → API Keys
- Pass it as
GatewayConfig(apiKey: 'rzp_test_...')
BharatPayKit.init(
gateway: PaymentGateway.razorpay,
config: GatewayConfig(apiKey: 'rzp_test_xxxxxxxxxxxx'),
);
Cashfree
- Sign up at merchant.cashfree.com
- Create an order on your backend → get
paymentSessionId - Pass the session ID in
request.metadata:
final request = PaymentRequest(
amount: 299.0,
orderId: 'cf_order_001',
...
metadata: {'paymentSessionId': 'SESSION_ID_FROM_BACKEND'},
);
BharatPayKit.init(
gateway: PaymentGateway.cashfree,
config: GatewayConfig(apiKey: 'YOUR_APP_ID'),
);
UPI Generic (No Setup Required)
BharatPayKit.init(
gateway: PaymentGateway.upiGeneric,
config: GatewayConfig(apiKey: 'merchant@upi'), // VPA
);
final response = await BharatPayKit.pay(request, context: context);
🤝 Contributing
Contributions are welcome! Please read our contributing guide before submitting a PR.
- Fork the repo
- Create your feature branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -m 'feat: add my feature') - Push to the branch (
git push origin feature/my-feature) - Open a Pull Request
Open an issue for bugs, feature requests, or questions.
📄 License
This project is licensed under the MIT License.
Copyright © 2025 bharat_pay_kit contributors
Libraries
- bharat_pay_kit
- BharatPayKit — Unified Flutter payment gateway package for India.