RazorpayTotalxsoftware - Flutter Plugin for Razorpay Integration

Launch Totalx

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

  1. 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.
  2. Configure Razorpay API keys: You’ll need your Razorpay API Key ID and Secret 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

ParameterTypeDescription
contextBuildContextThe Flutter build context.
saveInFirebaseboolIf true, saves transaction details in Firebase.
amountnumThe payment amount in currency units.
rzpKeyStringRazorpay API Key ID.
razorpayKeySecretStringRazorpay Secret Key.
appNameStringName of the application.
itemNameString?Optional name or description of the item.
userProfileRzpUserProfileUser profile containing name, phone number, and email.
successFunctionCallback function triggered on successful payment.
failureFunctionCallback function triggered on payment failure.
errorFunctionCallback 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:

Telegram