Skip to content

Commit

Permalink
Merge pull request #36 from razorpay/invoice-cancel
Browse files Browse the repository at this point in the history
invoice: Adds cancel endpoint
  • Loading branch information
ankit-rzp authored Aug 22, 2018
2 parents 2aa7a92 + 3ccf89b commit a3689c3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ Refund refund = razorpayClient.Payments.fetchRefund("refund_id");
* Create Transfer for a payment:
```java
JSONObject request = new JSONObject();

JSONArray transfers = new JSONArray();

JSONObject transfer = new JSONObject();
transfer.put("amount", <amount>); // The amount should be in paise.
transfer.put("currency", "INR");
transfer.put("account", <account_id>);

transfers.put(transfer);
request.put("transfers", transfers);

Expand Down Expand Up @@ -164,7 +164,7 @@ List<Payment> payments = razorpayClient.Orders.fetchPayments("order_id");
You can use the Utils class to verify the signature received in response to a payment made using Orders API
```java
JSONObject paymentResponse = new JSONObject();
options.put("razorpay_order_id", "<order_id>");
options.put("razorpay_order_id", "<order_id>");
options.put("razorpay_payment_id", "<payment_id>");
options.put("razorpay_signature", "<signature>");
Utils.verifyPaymentSignature(paymentResponse, "<secret_key>");
Expand All @@ -189,11 +189,10 @@ 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");
request.put("sms_notify", "0");

Invoice invoice = razorpayClient.Invoices.create(request);
```

* Fetch a particular invoice:
```java
Invoice invoice = razorpayClient.Invoices.fetch("invoice_id");
Expand All @@ -202,6 +201,10 @@ Invoice invoice = razorpayClient.Invoices.fetch("invoice_id");
```java
List<Invoice> invoices = razorpayClient.Invoices.fetchAll();
```
* Cancel a particular invoice:
```java
Invoice invoice = razorpayClient.Invoices.cancel("invoice_id");
```

### [Cards](https://docs.razorpay.com/v1/page/cards)

Expand Down Expand Up @@ -256,7 +259,7 @@ JSONObject request = new JSONObject();
request.put("amount", <amount>); // The amount should be in paise.
request.put("currency", "INR");
request.put("account", <account_id>);

Transfer transfer = razorpayClient.Transfers.create(request);
```

Expand Down Expand Up @@ -411,8 +414,8 @@ List<Payment> paymentList = razorpayClient.VirtualAccounts.fetchPayments("virtua

* Make custom requests

You can make custom API requests using clients. For example, here is how to make custom request to `/payments/path` endpoint.
You can make custom API requests using clients. For example, here is how to make custom request to `/payments/path` endpoint.

```java
Entity response = razorpayClient.Payments.post("path", JSONObject requestBody);
```
```
1 change: 1 addition & 0 deletions src/main/java/com/razorpay/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class Constants {
static final String INVOICE_CREATE = "invoices";
static final String INVOICE_GET = "invoices/%s";
static final String INVOICE_LIST = "invoices";
static final String INVOICE_CANCEL = "invoices/%s/cancel";

static final String CARD_GET = "cards/%s";

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/razorpay/InvoiceClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ public List<Invoice> fetchAll(JSONObject request) throws RazorpayException {
public Invoice fetch(String id) throws RazorpayException {
return get(String.format(Constants.INVOICE_GET, id), null);
}

public Invoice cancel(String id) throws RazorpayException {
return post(String.format(Constants.INVOICE_CANCEL, id), null);
}
}

0 comments on commit a3689c3

Please sign in to comment.