From 724ec9640c7d521b36e1ed3243d90544242acf7f Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Thu, 23 Jun 2022 12:31:25 +0530 Subject: [PATCH] order update --- documents/order.md | 225 +++++++++++++++++++++++++++++++++++++++++++++ src/Entity.cs | 4 +- src/Order.cs | 11 ++- 3 files changed, 236 insertions(+), 4 deletions(-) create mode 100644 documents/order.md diff --git a/documents/order.md b/documents/order.md new file mode 100644 index 0000000..10fbc8a --- /dev/null +++ b/documents/order.md @@ -0,0 +1,225 @@ +## Orders + +### Create order + +```cs +Dictionary request = new Dictionary(); +request.Add("amount",100); +request.Add("currency","INR"); +request.Add("receipt", "receipt#1201"); +Dictionary notes = new Dictionary(); +notes.Add("notes_key_1","Tea, Earl Grey, Hot"); +notes.Add("notes_key_1","Tea, Earl Grey, Hot"); +request.Add("notes",notes); + +Order order = client.Order.Create(request); +``` + +**Parameters:** + +| Name | Type | Description | +|-----------------|---------|------------------------------------------------------------------------------| +| amount* | integer | Amount of the order to be paid | +| currency* | string | Currency of the order. Currently only `INR` is supported. | +| receipt | string | Your system order reference id. | +| notes | array | A key-value pair | +|partial_payment | boolean | Indicates whether customers can make partial payments on the invoice . Possible values: true - Customer can make partial payments. false (default) - Customer cannot make partial payments. | + +**Response:** + +```json +{ + "id": "order_EKwxwAgItmmXdp", + "entity": "order", + "amount": 50000, + "amount_paid": 0, + "amount_due": 50000, + "currency": "INR", + "receipt": "receipt#1", + "offer_id": null, + "status": "created", + "attempts": 0, + "notes": [], + "created_at": 1582628071 +} +``` + +------------------------------------------------------------------------------------------------------- + +### Fetch all orders + +```cs +Dictionary request = new Dictionary(); +request.Add("count",2); + +List orders = client.Order.All(request); +``` + +**Parameters** + +| Name | Type | Description | +|------------|-----------|--------------------------------------------------------------| +| from | timestamp | timestamp after which the orders were created | +| to | timestamp | timestamp before which the orders were created | +| count | integer | number of orders to fetch (default: 10) | +| skip | integer | number of orders to be skipped (default: 0) | +| authorized | boolean | Orders for which orders are currently in authorized state. | +| receipt | string | Orders with the provided value for receipt. | +| expand[] | string | Used to retrieve additional information about the payment.Possible value is `payments` or `payments.card`, `transfers` or `virtual_account` | + +**Response:** + +```json +{ + "entity": "collection", + "count": 1, + "items": [ + { + "id": "order_EKzX2WiEWbMxmx", + "entity": "order", + "amount": 1234, + "amount_paid": 0, + "amount_due": 1234, + "currency": "INR", + "receipt": "Receipt No. 1", + "offer_id": null, + "status": "created", + "attempts": 0, + "notes": [], + "created_at": 1582637108 + } + ] +} +``` +------------------------------------------------------------------------------------------------------- + +### Fetch particular order + +```cs +String orderId = "order_JkaIDdkgGXVcwS"; + +Order order = client.Order.Fetch(orderId); +``` +**Parameters** + +| Name | Type | Description | +|----------|--------|-------------------------------------| +| orderId* | string | The id of the order to be fetched | + +**Response:** + +```json +{ + "id":"order_DaaS6LOUAASb7Y", + "entity":"order", + "amount":2200, + "amount_paid":0, + "amount_due":2200, + "currency":"INR", + "receipt":"Receipt #211", + "status":"attempted", + "attempts":1, + "notes":[], + "created_at":1572505143 +} +``` +------------------------------------------------------------------------------------------------------- + +### Fetch payments for an order + +```java +String orderId = "order_DaaS6LOUAASb7Y"; + +List orders = client.Order.Fetch(orderId).Payments(); +``` +**Parameters** + +| Name | Type | Description | +|----------|--------|-------------------------------------| +| orderId* | string | The id of the order to be retrieve payment info | + +**Response:** +```json +{ + "entity":"collection", + "count":1, + "items":[ + { + "id":"pay_DaaSOvhgcOfzgR", + "entity":"payment", + "amount":2200, + "currency":"INR", + "status":"captured", + "order_id":"order_DaaS6LOUAASb7Y", + "invoice_id":null, + "international":false, + "method":"card", + "amount_refunded":0, + "refund_status":null, + "captured":true, + "description":"Beans in every imaginable flavour", + "card_id":"card_DZon6fd8J3IcA2", + "bank":null, + "wallet":null, + "vpa":null, + "email":"gaurav.kumar@example.com", + "contact":"+919999999988", + "notes":[], + "fee":44, + "tax":0, + "error_code":null, + "error_description":null, + "created_at":1572505160 + } + ] +} +``` +------------------------------------------------------------------------------------------------------- + +### Update order + +```java +String orderId = "order_DaaS6LOUAASb7Y"; + +Dictionary request = new Dictionary(); +Dictionary notes = new Dictionary(); +notes.Add("notes_key_1","2t"); +notes.Add("notes_key_2","1t"); +request.Add("notes",notes); + +Order orders = client.Order.Fetch(orderId).Edit(request); +``` +**Parameters** + +| Name | Type | Description | +|----------|--------|-------------------------------------| +| orderId* | string | The id of the order to be retrieve payment info | +| notes* | object | A key-value pair | + +**Response:** +```json +{ + "id":"order_DaaS6LOUAASb7Y", + "entity":"order", + "amount":2200, + "amount_paid":0, + "amount_due":2200, + "currency":"INR", + "receipt":"Receipt #211", + "offer_id":null, + "status":"attempted", + "attempts":1, + "notes":{ + "notes_key_1":"Tea, Earl Grey, Hot", + "notes_key_2":"Tea, Earl Grey… decaf." + }, + "created_at":1572505143 +} +``` +------------------------------------------------------------------------------------------------------- + + +**PN: * indicates mandatory fields** +
+
+**For reference click [here](https://razorpay.com/docs/api/orders/)** \ No newline at end of file diff --git a/src/Entity.cs b/src/Entity.cs index 5e739b7..2261bcc 100644 --- a/src/Entity.cs +++ b/src/Entity.cs @@ -30,7 +30,7 @@ public class Entity HttpMethod.Post, HttpMethod.Put, HttpMethod.Patch }; - protected Entity Fetch(string id) + protected Entity Fetch(string id, Dictionary options = null) { if (string.IsNullOrWhiteSpace(id)) { @@ -40,7 +40,7 @@ protected Entity Fetch(string id) string entityUrl = GetEntityUrl(); string relativeUrl = string.Format("{0}/{1}", entityUrl, id); - List entitiesList = Request(relativeUrl, HttpMethod.Get, null); + List entitiesList = Request(relativeUrl, HttpMethod.Get, options); return entitiesList[0]; } diff --git a/src/Order.cs b/src/Order.cs index 01a57c7..adbca02 100644 --- a/src/Order.cs +++ b/src/Order.cs @@ -4,9 +4,9 @@ namespace Razorpay.Api { public class Order : Entity { - new public Order Fetch(string id) + new public Order Fetch(string id, Dictionary options = null) { - return (Order)base.Fetch(id); + return (Order)base.Fetch(id, options); } new public List All(Dictionary options = null) @@ -40,5 +40,12 @@ public List Payments() return payments; } + + public Order Edit(Dictionary data) + { + string relativeUrl = string.Format("orders/{0}", this["id"]); + List entities = Request(relativeUrl, HttpMethod.Patch, data); + return (Order)entities[0]; + } } } \ No newline at end of file