Skip to content

totalxsoftwaredevelopers/razorpay_totalxsoftware

Repository files navigation

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,
  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: 'john.doe@example.com',
  ),
  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!

Community

Join the Flutter Firebase Kerala community on Telegram for support and updates:

Telegram

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages