Razorpay 3.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Razorpay --version 3.0.2
                    
NuGet\Install-Package Razorpay -Version 3.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Razorpay" Version="3.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Razorpay" Version="3.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Razorpay" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Razorpay --version 3.0.2
                    
#r "nuget: Razorpay, 3.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Razorpay@3.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Razorpay&version=3.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Razorpay&version=3.0.2
                    
Install as a Cake Tool

Razorpay .NET SDK

Razorpay client .NET Api. The api follows the following practices

  • Namespaced under Razorpay.Api .
  • Client throws exceptions instead of returning errors.
  • Options are passed as Dictionary instead of multiple arguments wherever possible.
  • All request and responses are communicated over JSON.
  • A minimum of .Net 4.0 is required.

Installation

If you are using nuget package manager:

Install-Package Razorpay

else

  • Download Nuget package from here
  • Package supports only .Net 4.0 and .net 4.5, Add the required version as reference to your project.

Usage

Initialize

RazorpayClient client = new RazorpayClient(key, secret); 
                      OR
RazorpayClient client = new RazorpayClient(baseUrl, key, secret); 

Get Payments

Dictionary<string, object> options = new Dictionary<string,object>();

options.Add("from", startTime); // start time is a unix timestamp, you can get unix timestamp using                                // Utils.ToUnixTimestamp  method

List<Payment> payments = client.Payment.All(options);

Get Payment using Id

Payment payment = client.Payment.Fetch(id);

Capture a payment

Dictionary<string, object> options = new Dictionary<string,object>();

options.Add("amount", amountToBeCaptured); 

Payment payment = payment.Capture(options);

Refund a payment

Refund refund = payment.createRefund();

Fetch All Refunds for a payment

List<Refund> refunds = payment.getAllRefunds();

Fetch One Refund for a payment using refund id

Refund refund = payment.fetchRefund(id);

Accessing the payment attributes

paymentAmount = payment["amount"];

Create an order

Dictionary<string, object> options = new Dictionary<string,object>();

options.Add("amount", TransactionAmount); 
options.Add("currency", "INR"); 
options.Add("receipt", "MerchantTransactionId"); 
options.Add("payment_capture", 1); 

Order order = Order.Create(options);

Create a customer

Dictionary<string, object> options = new Dictionary<string,object>();

options.Add("name", "customer name"); 
options.Add("contact", "9999999999"); 
options.Add("email", "foo@example.com"); 
options.Add("fail_existing", 0); 

Customer customer = Customer.Create(options);

Development

  • Open solution in visual studio 2013, it should build fine

Ubuntu

Compiling using Mono

  • Download the 'Newtonsoft.Json' nuget package.
nuget install Newtonsoft.Json -Version 7.0.1 -OutputDirectory packages
  • Download the 'NUnit' nuget package.
nuget install NUnit -Version 3.6.1 -OutputDirectory packages
  • Create a bin folder in the root directory
mkdir bin
  • Compile the source code into a library
mcs -t:library -lib:"/usr/lib/mono/4.5" -r:"System.dll,System.Net.dll,System.Net.Http.dll,System.Core.dll,System.Xml.dll,System.Xml.Linq.dll,System.Core.dll,./packages/Newtonsoft.Json.7.0.1/lib/net45/Newtonsoft.Json.dll" -out:"bin/RazorpayClient.dll" ./src/**/*.cs -lib:/usr/lib/mono/2.0
  • copy Dependency dll
cp packages/Newtonsoft.Json.7.0.1/lib/net45/Newtonsoft.Json.dll ./bin
cp packages/NUnit.3.6.1/lib/net45/nunit.framework.dll ./bin
  • Compile test exe
mcs -t:exe -lib:"/usr/lib/mono/4.5,./bin" -r:"RazorpayClient.dll,Newtonsoft.Json.dll,nunit.framework.dll" -out:"bin/RazorpayApiTest.exe" ./test/*.cs
  • Run Test exe
mono bin/RazorpayApiTest.exe [key] [secret]

Compiling using xbuild

Run xbuild (in the root directory where sln file exist)

FAQ

  1. In case the last command fails with "invalid cert received from server", run below commands
Product Compatible and additional computed target framework versions.
.NET Framework net40 is compatible.  net403 was computed.  net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on Razorpay:

Package Downloads
SnkNetServer

Package Description

Tailgrape.DotNet.Utilities

Core Utilities for ASP.NET Core

SnkRazorPayHelper

SnkRazorPayHelper

Genius.PaymentLibrary

Lightweight Razorpay .NET client for creating orders.

Tailgrape.Api.DotNet.Utilities.PaymentGatewayHelper

Core Utilities for ASP.NET Core

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.3.2 56,824 9/4/2025
3.3.1 1,065 9/2/2025
3.3.0 672 9/2/2025
3.2.0 6,020 8/9/2025
3.1.4 57,155 12/27/2024
3.1.3 53,129 6/24/2024
3.1.2 13,106 5/13/2024
3.1.1 8,386 2/29/2024
3.1.0 18,364 10/31/2023
3.0.2 36,191 10/19/2022
3.0.0 156,726 11/12/2018
2.2.0 22,817 1/9/2018
2.1.0 3,963 9/27/2017
2.0.0 13,241 7/6/2017
1.1.1 3,295 11/19/2016
1.1.0 3,607 6/2/2016
1.0.0 3,683 12/19/2015

Razorpay SDK for .Net v3