bharat_pay_kit 0.0.1 copy "bharat_pay_kit: ^0.0.1" to clipboard
bharat_pay_kit: ^0.0.1 copied to clipboard

A unified Flutter payment gateway package for India. Supports Razorpay, Cashfree, PhonePe, Paytm, Google Pay, PayU, Stripe, CCAvenue, Instamojo, and UPI — all with a single consistent API, stunning 3D [...]

bharat_pay_kit #

pub version MIT License Platform Dart SDK

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 APIBharatPayKit.init()BharatPayKit.pay() for any gateway
  • 🔄 Hot-swap gateways at runtime with BharatPayKit.switchGateway()
  • 💳 3D Flip CardBharatPayCardWidget with auto card-type detection
  • 🎨 Glassmorphism SheetBharatPaySheet with 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 #

Payment Sheet

3D Card Widget

Success Screen


🔧 Gateway-Specific Setup #

Razorpay #

  1. Sign up at dashboard.razorpay.com
  2. Get your Test API Key from Settings → API Keys
  3. Pass it as GatewayConfig(apiKey: 'rzp_test_...')
BharatPayKit.init(
  gateway: PaymentGateway.razorpay,
  config: GatewayConfig(apiKey: 'rzp_test_xxxxxxxxxxxx'),
);

Cashfree #

  1. Sign up at merchant.cashfree.com
  2. Create an order on your backend → get paymentSessionId
  3. 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.

  1. Fork the repo
  2. Create your feature branch (git checkout -b feature/my-feature)
  3. Commit your changes (git commit -m 'feat: add my feature')
  4. Push to the branch (git push origin feature/my-feature)
  5. 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

4
likes
140
points
43
downloads
screenshot

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A unified Flutter payment gateway package for India. Supports Razorpay, Cashfree, PhonePe, Paytm, Google Pay, PayU, Stripe, CCAvenue, Instamojo, and UPI — all with a single consistent API, stunning 3D animations, glassmorphism UI, and dark/light mode support.

Repository (GitHub)
View/report issues

Topics

#payment #gateway #india #razorpay #upi

License

MIT (license)

Dependencies

cached_network_image, flutter, flutter_animate, flutter_inappwebview, google_fonts, http, razorpay_flutter, shimmer, url_launcher

More

Packages that depend on bharat_pay_kit