Official java bindings for the Razorpay API.
Documentation of Razorpay's API and their usage is available at https://docs.razorpay.com
Java 1.8 or later
Mock Tests Support till Java 1.8
Add this dependency to your project's POM:
<dependency>
<groupId>com.razorpay</groupId>
<artifactId>razorpay-java</artifactId>
<version>1.4.6</version>
</dependency>
Add this dependency to your project's build file:
implementation "com.razorpay:razorpay-java:1.4.6"
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
// Initialize client
RazorpayClient instance = new RazorpayClient("key_id", "key_secret");
Map<String, String> headers = new HashMap<String, String>();
razorpayClient.addHeaders(headers);
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/.
// Initialize client
RazorpayClient instance = new RazorpayClient("access_token");
Map<String, String> headers = new HashMap<String, String>();
razorpayClient.addHeaders(headers);
Make custom requests
You can make custom API requests using clients. For example, here is how to make custom request to /payments/path
endpoint.
Entity response = razorpayClient.Payments.post("path", JSONObject requestBody);