Razorpay SDK for .NET - Official payment processing library
$ dotnet add package RazorpayRazorpay client .NET Api. The api follows the following practices
Using the NuGet Command Line Interface (CLI)
nuget install Razorpay
else
RazorpayClient can be instantiated via two ways:
Instantiate RazorpayClient with key_id & key_secret. You can obtain the keys from the dashboard app https://dashboard.razorpay.com/#/app/keys
RazorpayClient client = new RazorpayClient(key, secret);
client.addHeader(string,string);
Instantiate RazorpayClient with access_token. The access_token can be obtained only in case if you are a platform partner. For more information, refer page - https://razorpay.com/docs/partners/platform/.
RazorpayClient client = new RazorpayClient(access_token);
client.addHeader(string,string);
The project now uses a unified multi-targeting approach. Simply:
# Restore dependencies
dotnet restore
# Build all target frameworks
dotnet build --configuration Release
# Create NuGet package
dotnet pack --configuration Release
📢 Important Note: We do not provide pre-built DLLs for .NET Framework 4.0 and 4.5 in our NuGet package. These frameworks are legacy (2010-2012) and most applications have migrated to newer versions. However, you can still use Razorpay with these frameworks by compiling the source code manually.
Not included in NuGet package - For .NET Framework 4.0 and 4.5 support, you can manually compile the source code:
# 1. Install required NuGet packages
nuget install Newtonsoft.Json -Version 13.0.3 -OutputDirectory packages
nuget install Portable.BouncyCastle -Version 1.9.0 -OutputDirectory packages
# 2. Compile for .NET 4.0
csc /target:library /out:Razorpay-net40.dll /reference:packages/Newtonsoft.Json.13.0.3/lib/net40/Newtonsoft.Json.dll /reference:packages/Portable.BouncyCastle.1.9.0/lib/net40/BouncyCastle.Crypto.dll /reference:System.dll /reference:System.Core.dll /reference:System.Net.dll /reference:System.Net.Http.dll /reference:Microsoft.CSharp.dll src/**/*.cs
# 3. Compile for .NET 4.5
csc /target:library /out:Razorpay-net45.dll /reference:packages/Newtonsoft.Json.13.0.3/lib/net45/Newtonsoft.Json.dll /reference:packages/Portable.BouncyCastle.1.9.0/lib/net40/BouncyCastle.Crypto.dll /reference:System.dll /reference:System.Core.dll /reference:System.Net.dll /reference:System.Net.Http.dll /reference:Microsoft.CSharp.dll src/**/*.cs
Note: .NET Standard 2.0 provides better compatibility and is recommended over .NET Framework 4.0/4.5.
Razorpay.sln - it will build all target frameworksThe project includes GitHub Actions workflow that:
nuget install Newtonsoft.Json -Version 13.0.3 -OutputDirectory packages
nuget install Portable.BouncyCastle -Version 1.9.0 -OutputDirectory packages
nuget install NUnit -Version 3.6.1 -OutputDirectory packages
mkdir bin
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.13.0.3/lib/net45/Newtonsoft.Json.dll,./packages/Portable.BouncyCastle.1.9.0/lib/net40/BouncyCastle.Crypto.dll" -out:"bin/RazorpayClient.dll" ./src/**/*.cs -lib:/usr/lib/mono/2.0
cp packages/Newtonsoft.Json.13.0.3/lib/net45/Newtonsoft.Json.dll ./bin
cp packages/Portable.BouncyCastle.1.9.0/lib/net40/BouncyCastle.Crypto.dll ./bin
cp packages/NUnit.3.6.1/lib/net45/nunit.framework.dll ./bin
mcs -t:exe -lib:"/usr/lib/mono/4.5,./bin" -r:"RazorpayClient.dll,Newtonsoft.Json.dll,BouncyCastle.Crypto.dll,nunit.framework.dll" -out:"bin/RazorpayApiTest.exe" ./test/*.cs
mono bin/RazorpayApiTest.exe [key] [secret]
Run xbuild (in the root directory where sln file exist)