RazorpayTotalxsoftware - Flutter Plugin for Razorpay Integration
Developed by Totalx Software
RazorpayTotalxsoftware
is a Flutter package that simplifies the integration of Razorpay payment processing with optional support for Firebase logging. It handles order creation, payment confirmation, and transaction logging to Firebase.
Table of Contents
Features
- Order Creation: Automatically generates a Razorpay order ID.
- Customizable UI: Displays a payment alert for confirmation.
- Transaction Logging: Optionally save transactions to Firebase.
- Callback Support: Callback functions for success, failure, and error handling.
Installation
Add razorpay_totalxsoftware
to your pubspec.yaml
file:
dependencies:
razorpay_totalxsoftware:
Then, import the package in your Dart file:
import 'package:razorpay_totalxsoftware/razorpay_totalxsoftware.dart';
Setup
- Initialize Firebase (Optional): Set up Firebase in your Flutter app if you plan to save transactions in Firebase. You can refer to the official Firebase setup guide for Flutter.
- Configure Razorpay API keys: You’ll need your Razorpay
API Key ID
andSecret Key
for authentication.
Usage
The primary method for initiating a payment is RazorpayTotalxsoftware.pay
. It requires various parameters, including payment details, user information, and callback functions to handle the payment flow.
Method Parameters
Parameter | Type | Description |
---|---|---|
context | BuildContext | The Flutter build context. |
saveInFirebase | bool | If true , saves transaction details in Firebase. |
amount | num | The payment amount in currency units. |
rzpKey | String | Razorpay API Key ID. |
razorpayKeySecret | String | Razorpay Secret Key. |
appName | String | Name of the application. |
itemName | String? | Optional name or description of the item. |
userProfile | RzpUserProfile | User profile containing name, phone number, and email. |
success | Function | Callback function triggered on successful payment. |
failure | Function | Callback function triggered on payment failure. |
error | Function | Callback function for errors during the payment process. |
Example
Here's a basic usage example of the pay method in a Flutter app:
RazorpayTotalxsoftware.pay(
context,
amount: 100,
saveInFirebase: true,
rzpKey: 'YOUR_RAZORPAY_KEY',
razorpayKeySecret: 'YOUR_RAZORPAY_KEY_SECRET',
appName: 'razorpay_web_totalxsoftware',
// itemName: , // optional
userProfile: RzpUserProfile(
uid: 'unique_user_id',
name: 'John Doe',
email: 'qYqgK@example.com',
phoneNumber: '1234567890',
),
success: (response) {
log(response.toString());
log('payment success');
},
failure: (response) {
log(response.toString());
},
error: (response) {
log(response.toString());
},
);
Explore more about TotalX at www.totalx.in - Your trusted software development company!
Community
Join the Flutter Firebase Kerala community on Telegram for support and updates: