SDKs overview

Razorpay IFSC offers a suite of Software Development Kits (SDKs) and libraries designed to facilitate the integration of its payment gateway services into various applications and platforms. These tools are developed to simplify the process of interacting with the Razorpay API, providing developers with pre-built functions and methods for common operations such as creating orders, processing payments, managing refunds, and handling webhooks. The availability of SDKs across multiple programming languages and mobile frameworks aims to reduce development time and effort, allowing for faster deployment of payment solutions.

The SDKs abstract the underlying HTTP requests and JSON parsing, enabling developers to work with familiar object-oriented paradigms within their chosen language or framework. This approach helps to minimize errors and enhance the developer experience. Razorpay emphasizes providing comprehensive API documentation to support the use of these SDKs, including detailed guides and example code snippets for various use cases. The SDKs are regularly updated to ensure compatibility with the latest API versions and to incorporate new features or security enhancements.

For mobile development, specific SDKs are available for Android, iOS, React Native, and Flutter, allowing native and cross-platform applications to integrate payment flows directly. Server-side SDKs for languages like Node.js, Python, PHP, Ruby, Java, and .NET enable backend systems to manage payment lifecycle events, interact with Razorpay's dashboard, and implement server-to-server API calls securely. These SDKs are typically distributed through standard package managers for each language, simplifying installation and dependency management.

Official SDKs by language

Razorpay maintains official SDKs for a range of popular programming languages and mobile development frameworks. These SDKs are developed and supported by Razorpay to ensure optimal performance, security, and compatibility with their payment gateway services. Each SDK is tailored to the conventions and best practices of its respective language, providing an idiomatic development experience.

Language/Platform Package Name Install Command (Example) Maturity
Node.js razorpay npm install razorpay Stable
Python razorpay pip install razorpay Stable
PHP razorpay/razorpay composer require razorpay/razorpay Stable
Ruby razorpay gem install razorpay Stable
Java com.razorpay:razorpay-java Add to pom.xml or build.gradle Stable
.NET Razorpay dotnet add package Razorpay Stable
Android com.razorpay:checkout Add to build.gradle Stable
iOS Razorpay Add to Podfile (CocoaPods) Stable
React Native razorpay/razorpay-react-native npm install razorpay/razorpay-react-native Stable
Flutter razorpay_flutter Add to pubspec.yaml Stable

Each SDK provides specific functionalities tailored to its environment. For instance, mobile SDKs often include UI components for payment forms, while server-side SDKs focus on API interactions for order creation, refund initiation, and webhook verification. Developers can find detailed usage instructions and API references for each SDK within the official Razorpay documentation portal, which includes specific guides for creating payments and managing transactions.

Installation

Installation of Razorpay SDKs typically follows the standard practices for each programming language or platform. This usually involves using a package manager to add the SDK as a dependency to your project. The following examples illustrate common installation methods:

Node.js

For Node.js projects, the Razorpay SDK can be installed via npm (Node Package Manager):

npm install razorpay

After installation, you can require the SDK in your JavaScript or TypeScript files:

const Razorpay = require('razorpay');

Python

Python developers can install the SDK using pip:

pip install razorpay

Then import it into your Python scripts:

import razorpay

PHP

PHP projects typically use Composer for dependency management:

composer require razorpay/razorpay

Ensure Composer's autoloader is included in your project:

require 'vendor/autoload.php';
use Razorpay\Api\Api;

Java

For Java projects, you would typically add the dependency to your pom.xml (for Maven) or build.gradle (for Gradle). For Maven:

<dependency>
    <groupId>com.razorpay</groupId>
    <artifactId>razorpay-java</artifactId>
    <version>1.4.3</version> <!-- Use the latest version -->
</dependency>

For Gradle:

implementation 'com.razorpay:razorpay-java:1.4.3' // Use the latest version

Android

Android applications integrate the Razorpay Checkout SDK by adding it to the build.gradle file of the app module:

dependencies {
    implementation 'com.razorpay:checkout:1.6.14' // Use the latest version
}

Further configuration, such as manifest declarations and theme adjustments, is detailed in the Razorpay Android integration guide.

iOS

For iOS applications, CocoaPods is the recommended method for installation:

pod 'Razorpay'

Then run pod install. For Swift Package Manager (SPM) or manual integration, consult the Razorpay iOS integration documentation.

Quickstart example

This quickstart example demonstrates how to create a payment order using the Node.js SDK, which is a common first step in integrating Razorpay. This example assumes you have already installed the Node.js SDK and have your API keys (Key ID and Key Secret) ready. These keys are available from your Razorpay dashboard settings.

First, initialize the Razorpay client with your API keys:

const Razorpay = require('razorpay');

const instance = new Razorpay({
  key_id: 'YOUR_KEY_ID',
  key_secret: 'YOUR_KEY_SECRET',
});

Next, define the parameters for your order, including the amount, currency, and a receipt ID. The amount must be in the smallest currency unit (e.g., paise for INR).

const options = {
  amount: 50000, // amount in smallest currency unit (e.g., 50000 paise = INR 500.00)
  currency: 'INR',
  receipt: 'order_rcptid_11',
  notes: {
    key1: 'value3',
    key2: 'value2'
  }
};

Finally, create the order using the orders.create method:

instance.orders.create(options, (err, order) => {
  if (err) {
    console.error('Error creating order:', err);
  } else {
    console.log('Order created successfully:', order);
    // The 'order' object contains the order_id which is needed for client-side payment initiation.
    // Example: { id: 'order_xxxxxxxxxxxxxx', entity: 'order', amount: 50000, currency: 'INR', ... }
  }
});

This server-side order creation generates an order_id that is then passed to the client-side (web or mobile) for initiating the payment checkout process. The client-side integration, typically using Razorpay's Checkout.js or mobile SDKs, uses this order_id to display the payment interface and collect payment details from the user. For a complete end-to-end flow, refer to the Razorpay server-side integration documentation.

Community libraries

While Razorpay provides a comprehensive set of official SDKs, the developer community also contributes various libraries, plugins, and integrations that extend Razorpay's functionality or adapt it to specific platforms not officially supported. These community-driven projects can offer solutions for niche use cases, custom UI components, or integrations with content management systems (CMS) and e-commerce platforms.

Community libraries are often found on platforms like GitHub, npm, PyPI, or Packagist. Examples include plugins for popular e-commerce platforms such as WooCommerce or Magento, or custom wrappers for less common programming languages. When considering a community library, it is important to evaluate its maintenance status, community support, and adherence to security best practices, as these are not officially endorsed or maintained by Razorpay.

Developers should check the project's documentation, issue tracker, and recent commit history to assess its reliability. While official SDKs are recommended for core payment processing, community contributions can be valuable for extending reach or simplifying integration into specific ecosystems. For instance, payment gateways often integrate with various platforms, as highlighted in Stripe's documentation on plugins for various platforms, which is a common approach across payment providers.

Before deploying any community-developed solution in a production environment, it is advisable to conduct thorough testing and security audits. Official Razorpay documentation and support channels remain the primary resource for critical payment gateway integrations. However, exploring community forums and repositories can uncover useful tools for specific development needs, such as custom reporting or specialized webhook handlers.