Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

order update #58

Open
wants to merge 1 commit into
base: customer_update
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
225 changes: 225 additions & 0 deletions documents/order.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
## Orders

### Create order

```cs
Dictionary<string, object> request = new Dictionary<string, object>();
request.Add("amount",100);
request.Add("currency","INR");
request.Add("receipt", "receipt#1201");
Dictionary<string, object> notes = new Dictionary<string, object>();
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<string, object> request = new Dictionary<string, object>();
request.Add("count",2);

List<Order> 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<Payment> 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":"[email protected]",
"contact":"+919999999988",
"notes":[],
"fee":44,
"tax":0,
"error_code":null,
"error_description":null,
"created_at":1572505160
}
]
}
```
-------------------------------------------------------------------------------------------------------

### Update order

```java
String orderId = "order_DaaS6LOUAASb7Y";

Dictionary<string, object> request = new Dictionary<string, object>();
Dictionary<string, object> notes = new Dictionary<string, object>();
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**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/orders/)**
4 changes: 2 additions & 2 deletions src/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Entity
HttpMethod.Post, HttpMethod.Put, HttpMethod.Patch
};

protected Entity Fetch(string id)
protected Entity Fetch(string id, Dictionary<string, object> options = null)
{
if (string.IsNullOrWhiteSpace(id))
{
Expand All @@ -40,7 +40,7 @@ protected Entity Fetch(string id)

string entityUrl = GetEntityUrl();
string relativeUrl = string.Format("{0}/{1}", entityUrl, id);
List<Entity> entitiesList = Request(relativeUrl, HttpMethod.Get, null);
List<Entity> entitiesList = Request(relativeUrl, HttpMethod.Get, options);
return entitiesList[0];
}

Expand Down
11 changes: 9 additions & 2 deletions src/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace Razorpay.Api
{
public class Order : Entity
{
new public Order Fetch(string id)
new public Order Fetch(string id, Dictionary<string, object> options = null)
{
return (Order)base.Fetch(id);
return (Order)base.Fetch(id, options);
}

new public List<Order> All(Dictionary<string, object> options = null)
Expand Down Expand Up @@ -40,5 +40,12 @@ public List<Payment> Payments()

return payments;
}

public Order Edit(Dictionary<string, object> data)
{
string relativeUrl = string.Format("orders/{0}", this["id"]);
List<Entity> entities = Request(relativeUrl, HttpMethod.Patch, data);
return (Order)entities[0];
}
}
}