Latest commit 4768623 Jan 10, 2017 @ankit-rzp ankit-rzp committed on GitHub Update README
Updating with the new version
Failed to load latest commit information.
src/main/java/com/razorpay [Invoice API] Dec 3, 2016
.gitignore Update Readme File Nov 7, 2016
LICENSE.txt Add MIT License Nov 8, 2016 Update README Jan 10, 2017
pom.xml [Invoice API] Upgrading version Dec 3, 2016

Razorpay Java SDK

Official java bindings for the Razorpay API.


Documentation of Razorpay's API and their usage is available at


Java 1.7 or later


Maven users

Add this dependency to your project's POM:


Gradle users

Add this dependency to your project's build file:

compile "com.razorpay:razorpay-java:1.1.0"


Instantiate RazorpayClient with key_id & key_secret. You can obtain the keys from the dashboard app

// Initialize client
RazorpayClient razorpayClient = new RazorpayClient("key_id", "key_secret");


  • Fetch all payments
List<Payment> payments = razorpayClient.Payments.fetchAll();
  • Fetch a particular payment:
Payment payment = razorpayClient.Payments.fetch("payment_id");
// The the Entity.get("attribute_key") method has flexible return types depending on the attribute
int amount = payment.get("amount");
String id = payment.get("id");
Date createdAt = payment.get("created_at");
  • Capturing a payment:
JSONObject options = new JSONObject();
options.put("amount", 1000);
razorpayClient.Payments.capture("payment_id", options);
// Note: Amount should be same as the original amount while creating the payment. The amount should be in paise.
  • Refund a payment:
// For full refunds
Refund refund = razorpayClient.Payments.refund("payment_id");

// For partial refunds
JSONObject refundRequest = new JSONObject();
refundRequest.put("amount", 100);
Refund refund = razorpay.Payments.refund("payment_id", refundRequest);
// Note: Amount to be refunded should be less than or equal to the original amount.The amount should be in paise.
  • Fetch all refunds for a payment:
List<Refund> refund = razorpayClient.Payments.fetchAllRefunds("payment_id");
  • Fetch refund for a payment:
Refund refund = razorpayClient.Payments.fetchRefund("payment_id", "refund_id");


  • Fetch all refunds:
List<Refund> refunds = razorpayClient.Refunds.fetchAll();
  • Fetch a particular refund:
Refund refund = razorpayClient.Refunds.fetch("refund_id");


  • Create a new order:
JSONObject options = new JSONObject();
options.put("amount", 5000); // Note: The amount should be in paise.
options.put("currency", "INR");
options.put("receipt", "txn_123456");
Order order = razorpayClient.Orders.create(options);
  • Fetch a particular order:
Order order = razorpayClient.Orders.fetch("order_id");
  • Fetch all orders:
List<Order> orders = razorpayClient.Orders.fetchAll();
  • Fetch payments for an order:
List<Payment> payments = razorpayClient.Orders.fetchPayments("order_id");


  • Create a new invoice:
JSONObject lineItem = new JSONObject();
lineItem.put("amount", 100); // Note: The amount should be in paise.
lineItem.put("name", "name_invoice");

JSONArray lineItems = new JSONArray();

JSONObject request = new JSONObject();
request.put("line_items", lineItems);
request.put("date", 1480768625); // Timestamp in seconds
request.put("currency", "INR");
request.put("sms_notify", "0"); 

Invoice invoice = razorpayClient.Invoices.create(request);
  • Fetch a particular invoice:
Invoice invoice = razorpayClient.Invoices.fetch("invoice_id");
  • Fetch all invoices:
List<Invoice> invoices = razorpayClient.Invoices.fetchAll();