# PlaceOrder API

#### **Base URL :**

{% hint style="info" %}

> **`Staging :`** [**https://stagingaccount.xoxoday.com/chef**](https://stagingaccount.xoxoday.com/chef)
>
> **`Production :`** [**https://accounts.xoxoday.com/chef**](https://accounts.xoxoday.com/chef)
> {% endhint %}

{% tabs %}
{% tab title="Request" %}

```bash
curl -X POST {OAUTH_URL}/v1/oauth/api 
-H 'Authorization: Bearer eyJ0b2tlbkNvbnRlbnQiOnsiaXNzdWVkRm9yIjoiRnJlc2h3b3JrcyIsInNjb3BlIjoiIiwiaXNzdWVkQXQiOjE1NTk4MDQ1Nzg1ODIsImV4cGlyZXNBdCI6IjIwMTktMDYtMjFUMDc6MDI6NTguNTgyWiIsInRva2VuX3R5cGUiOiJVU0VSIn0sImFfdCI6ImV5SmxibU1pT2lKQk1USTRRMEpsETFVoVE1qVTJJaXdpWVd4bklqb2lSVU5FU0MxRlV5SXNJbXRwWkNJNkltVnVZeUlzSW1Wd2F5STZleUpyZEhraU9pSkZReUlzSW1OeWRpSTZJbEF0TWpVMklpd2llQ0k2SWpoMmJVTkVRMUZQZW1wQlNHWndabXQ0TVhjNVluZHphM1JhZWtRek0ySXRZamx0VVhSclEyRnhNV3NpTENKNUlqb2lZMGR0V2kxdWIySjBWbUptTVdGdVNraDBUMmxoWW5VMFZHUlVhRzVVYmpCYWRuWnJabGMwYzBWb2N5SjlmUS4uU1h3TlNUSWhFUXNlN0htaXpPUmFIQS5NRzBVUy1lek1IOEFsbWFLc2ZTY3Nwa2FlYzBIcW9FcUV1YXRoNHRSTTRpeVg2dFByX1ZjTnlsdnk5YjlGLTZHR01DbjY1TjYwYnpIUUJtRVZvZGRYVWlvQS1kTkpuaE9KdThHczRfeW9pM042VGFOdWhjRENCUGtwWk1CeTlDRjJBaEh4UGotQkd0SzdEamhNbjBBQXpTM1VhTE11eUdrTmNwSGxQSUxNcFlVM' 
--header 'Content-Type: application/json'
  -d '{
	"query": "plumProAPI.mutation.placeOrder",
	"tag": "plumProAPI",
	"variables": {
		"data":{
			"productId":15365,
	        	"quantity": 1,
	        	"denomination": 20, 
	        	"email":"",
	        	"contact":"+1-5234567890",
	        	"tag":"",
	        	"poNumber":"PO12662",
			"notifyReceiverEmail":0,
			"notifyAdminEmail":0
		}
	}
}

```

{% endtab %}

{% tab title="Response" %}

#### `200 : Success`

`returns list of vouchers filtered by the applicable filters`

```bash
{
    "data": {
        "placeOrder": {
             status: 1,
             data:{
               "orderId": 1,
               "vouchers":[{
                 "amount": "10",
                 "country": "ES",
                 "currency": "INR",
                 "orderId": 128618,
                 "pin": "key_c26323726135beaa4e",
                 "productId": 28543,
                 "type": "codePin",
                 "validity": "2020-10-02",
                 "voucherCode": "4162581029814703",
                 "currencyValue": 0.1,
               }],
               "amountCharged": 90,
               "currencyCode": "USD",
               "tag": "",
               "discountPercent": 10,
               "orderDiscount": 10,
               "orderTotal": 100,
               "orderStatus": "complete",
               "deliveryStatus": "pending"
             }
           }
    }
}
```

#### `400 : Failure`

`Validation error in place order`

```
{ 
   code: 400, 
   errorId: PLE10001,
   errorInfo: "Validation error in place order”,
   error: "Eg: Bad request"
}
```

#### `401 : Failure`

`Clinets not allowed to place international orders`

```
{ 
   code: 401, 
   errorId: PLE10019,
   errorInfo: "Clients are not allowed to place international orders”,
   error: "Eg: Unauthorized, Client is unauthorized for international orders"
}
```

#### `403 : Failure`

`For procuring amazon vouchers , one needs to get amazon KYC done.`

```
 { 
   code: 403, 
   errorId: PLE10015,
   errorInfo: "Amazon KYC is not approved",
   error: "Eg: Forbidden, Ordering Amazon voucher requires client KYC to be approved"
}
```

#### `404 : Failure`&#x20;

`Invalid denomination for the product`

```
{ 
   code: 404, 
   errorId: PLE10018,
   errorInfo: "Invalid denomination for the product",
   error: "Eg: Not found, ProductId and Denomination Combination Not Found, Order Details Not Found"
}
```

#### `422: Failure`

`Failed to process order`

```
{ 
   code: 422, 
   errorId: PLE10012,
   errorInfo: "Failed to process order",
   error: "Eg: Unprocessable Entity, Order Process Failed due to Unavailability of Vouchers"
}
```

#### `409 : Failure`

`Client not allowed to place more than 10 orders`

```
 {
    code: 409,
    "errorId": "PLE10041",
    "errorInfo": "Clients are not allowed to place more than 10 Qty",
    "error": "Order Failed, as per your current setup you are not allowed to add more than 10 qty. Plz contact cs@xoxoday.com to get more clarity"
}
```

#### `502 : Failure`&#x20;

`Failed to fetch currency details of the client.`

```
{ 
   code: 502, 
   errorId: PLE10020,
   errorInfo: "Failed to get currency details for the client",
   error: "Eg: Bad Gateway, Currency API did not return data"
}
```

#### `500: Failure`

`Internal server error`

```
{ 
   code: 500, 
   error: "Eg: Internal server error"
}
```

{% endtab %}
{% endtabs %}

## Parameters

{% tabs %}
{% tab title="Request " %}

#### `Body Parameters`

<table data-header-hidden><thead><tr><th width="256">Property</th><th width="154">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>Property</code></td><td><code>Type</code></td><td><strong><code>Description</code></strong></td></tr><tr><td><code>productId</code><strong><code>*</code></strong></td><td><code>Integer</code></td><td><code>ProductId of the product to be ordered</code></td></tr><tr><td><code>quantity</code><strong><code>*</code></strong></td><td><code>Integer</code></td><td><code>Quantity of the product to be ordered</code></td></tr><tr><td><code>denomination</code></td><td><code>Integer</code></td><td><code>Denomination of the product to be ordered</code></td></tr><tr><td><code>email</code></td><td><code>String</code></td><td><code>Email on which the product should be delivered</code></td></tr><tr><td><code>contact</code></td><td><code>String</code></td><td><code>Mobile number the product should be delivered to in the format specified, Optional for products except Paytm</code></td></tr><tr><td><code>tag</code></td><td><code>String</code></td><td><code>A comment or reference data parameter</code></td></tr><tr><td><code>poNumber</code></td><td><code>String</code></td><td><code>Client-side orderId or reference id</code></td></tr><tr><td><code>notifyAdminEmail*</code></td><td><code>Integer</code></td><td><code>Send 1 if order reference need to be emailed to Admin user</code></td></tr><tr><td><code>notifyReceiverEmail*</code></td><td><code>Integer</code></td><td><code>Send 1 if the product should be delivered via email to the receiver</code></td></tr></tbody></table>

{% hint style="info" %}
**"\*" means the parameter is mandatory**
{% endhint %}
{% endtab %}

{% tab title="Response" %}

#### **`Body Parameters`**

| **`Property`**               | **`Type`**    | **`Description`**                                                                                                |
| ---------------------------- | ------------- | ---------------------------------------------------------------------------------------------------------------- |
| **`status`**                 | **`Integer`** | **`0 (Failure) / 1 (Successful)`**                                                                               |
| **`orderId`**                | **`Integer`** | **`Order id of the order`**                                                                                      |
| **`tag`**                    | **`String`**  | **`Order’s tag`**                                                                                                |
| **`amountCharged`**          | **`Integer`** | **`Amount charged for the order in Client’s base currency`**                                                     |
| **`Currency Code`**          | **`String`**  | **`Base currency code of the client`**                                                                           |
| **`currencyValue`**          | **`Float`**   | `Currency Value will be showing the exchange rate between the base currency of the account and product currency` |
| **`discountPercent`**        | **`Float`**   | **`Percentage of discount if any`**                                                                              |
| **`orderDiscount`**          | **`Float`**   | **`Discount amount based on discount Percent`**                                                                  |
| **`orderTotal`**             | **`Float`**   | **`Order total of the order excluding the discount`**                                                            |
| **`deliveryStatus`**         | **`String`**  | **`Product delivery status of the order`**                                                                       |
| **`vouchers`**               | **`Array`**   | **`Array of vouchers ordered`**                                                                                  |
| **`vouchers.productid`**     | **`Integer`** | **`Product Id of the product,`**                                                                                 |
| **`vouchers.voucherCode`**   | **`String`**  | **`Voucher Code or url based on the type parameter`**                                                            |
| **`vouchers.pin`**           | **`String`**  | **`Pin for the voucher if applicable`**                                                                          |
| **`vouchers.validity`**      | **`String`**  | **`The validity of the voucher`**                                                                                |
| **`vouchers.amount`**        | **`String`**  | **`Denomination of the voucher ordered`**                                                                        |
| **`vouchers.currency`**      | **`String`**  | **`The currency of the ordered product`**                                                                        |
| **`vouchers.currencyValue`** | **`Float`**   | **`Value compared to INR`**                                                                                      |
| **`vouchers.orderStatus`**   | **`String`**  | **`Order place status of the order`**                                                                            |
| **`vouchers.country`**       | **`String`**  | **`Countries that the product can be redeemed in`**                                                              |
| **`vouchers.type`**          | **`String`**  | **`Type of vouchers,For eg: pin, codePin, url`**                                                                 |

{% hint style="info" %}
**vouchers.xyz= vouchers property objects**
{% endhint %}
{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Note:** We do not currently support Notification by SMS functionality
{% endhint %}
