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.
- 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.
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';
- 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.
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.
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. |
Here's a basic usage example of the pay method in a Flutter app:
RazorpayTotalxsoftware.pay(
context,
saveInFirebase: true,
amount: 500,
rzpKey: 'your_rzp_key',
razorpayKeySecret: 'your_rzp_secret',
appName: 'YourAppName',
itemName: 'Sample Item',
userProfile: RzpUserProfile(
name: 'John Doe',
phoneNumber: '+1234567890',
email: '[email protected]',
),
success: (PaymentSuccessResponse response) {
print('Payment Successful: ${response.paymentId}');
},
failure: (PaymentFailureResponse response) {
print('Payment Failed: ${response.message}');
},
error: (String errorMessage) {
print('Error: $errorMessage');
},
);
Explore more about TotalX at www.totalx.in - Your trusted software development company!
Join the Flutter Firebase Kerala community on Telegram for support and updates: