# Submit Quick Order

With this API endpoint, you can submit a new quick order for a list of customers. You can add customers with their customer uuid, email and phone number. Country code and msisdn within phone number should be separated by "^".


-----

### Endpoint

```
POST https://demo-api.frontpayment.no/api/v1/connect/orders/quick
```

#### Authorization

To access this endpoint, include a `Bearer Token` in the `Authorization` header of your request. You can obtain this token from Frontpayment.

**Example Authorization Header:**
`Authorization: Bearer YOUR_FRONTPAID_BEARER_TOKEN`

### Request Payload

Send the following parameters as a JSON object in the request body:

```json
{
    "customers": [
        "CSRT1502423833",
        "+880^1934657823",
        "test.email@yopmail.com"
    ],
    "orderDate": "{{orderDate}}",
    "dueDateForPaymentLink": "{{dueDate}}",
    "referenceNo": null,
    "customerReference": null,
    "products": {
        "0": { 
            "name": "Health Scan",
            "productId": null,
            "quantity": "2",
            "rate": 30,
            "discount": 0,
            "tax": "10",
            "amount": 60
        }
    },
    "sendOrderBy": {
        "sms": false,
        "email": true
    },
    "orderSummary": {
        "subTotal": 54.55,
        "totalTax": 5.45,
        "totalDiscount": 0.00,
        "grandTotal": 60.00
    },
    "customerNotes": null,
    "tnc": null

}
```

### Validation Rules

Make sure your request meets the following requirements:

<table style="width: 100%">
  <thead>
    <tr>
      <th style="width: 260px">Field</th>
      <th style="width: 80px">Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code>customers</code></td>
      <td><code>array</code></td>
      <td><strong>Required</strong></td>
    </tr>
    <tr>
      <td><code>customers.*</code></td>
      <td><code>string</code></td>
      <td><strong>Required</strong> email / customer uuid / phone number of customer.</td>
    </tr>
    <tr>
      <td><code>products.*.name</code></td>
      <td><code>string</code></td>
      <td><strong>Required</strong> Name of the product.</td>
    </tr>
    <tr>
      <td><code>products.*.productId</code></td>
      <td><code>string</code></td>
      <td><strong>Optional</strong> Unique identifier for the product.</td>
    </tr>
    <tr>
      <td><code>products.*.quantity</code></td>
      <td><code>numeric</code></td>
      <td><strong>Required</strong> Quantity of the product.</td>
    </tr>
    <tr>
      <td><code>products.*rate</code></td>
      <td><code>numeric</code></td>
      <td><strong>Required</strong> Rate per unit of the product.</td>
    </tr>
    <tr>
      <td><code>products.*.discount</code></td>
      <td><code>numeric</code></td>
      <td><strong>Optional</strong> Discount applied to the product.</td>
    </tr>
    <tr>
      <td><code>products.*.tax</code></td>
      <td><code>numeric</code></td>
      <td><strong>Required</strong> Tax rate must be (e.g., <code>0</code>, <code>12</code>, <code>15</code>, <code>25</code>), Unless you have other configuration.</td>
    </tr>
    <tr>
      <td><code>products.*.amount</code></td>
      <td><code>numeric</code></td>
      <td><strong>Required</strong> Total amount for the product line item.</td>
    </tr>
    <tr>
      <td><code>orderSummary.subTotal</code></td>
      <td><code>numeric</code></td>
      <td><strong>Required</strong> Subtotal of all products before tax and discount.</td>
    </tr>
    <tr>
      <td><code>orderSummary.totalTax</code></td>
      <td><code>numeric</code></td>
      <td><strong>Required</strong> Total tax for the order.</td>
    </tr>
    <tr>
      <td><code>orderSummary.totalDiscount</code></td>
      <td><code>numeric</code></td>
      <td><strong>Required</strong> Total discount for the order.</td>
    </tr>
    <tr>
      <td><code>orderSummary.grandTotal</code></td>
      <td><code>numeric</code></td>
      <td><strong>Required</strong> Grand total of the order.</td>
    </tr>
    <tr>
      <td><code>sendOrderBy.sms</code></td>
      <td><code>boolean</code></td>
      <td><strong>Nullable</strong> If you want to send order paytment link via customer phone number.</td>
    </tr>
    <tr>
      <td><code>sendOrderBy.email</code></td>
      <td><code>boolean</code></td>
      <td><strong>Nullable</strong> If you want to send order payment link via email.</td>
    </tr>
    <tr>
      <td><code>orderDate</code></td>
      <td><code>string</code></td>
      <td><strong>Required</strong> Provide Current / Future Date as Unix timestamp for the Date of the order.</td>
    </tr>
    <tr>
      <td><code>referenceNo</code></td>
      <td><code>string</code></td>
      <td><strong>Nullable</strong> Any reference number.</td>
    </tr>
    <tr>
      <td><code>customerReference</code></td>
      <td><code>string</code></td>
      <td><strong>Nullable</strong> Any value for customer reference.</td>
    </tr>
  </tbody>
</table>


### Response

A successful request will return a `201 Created` status with the following JSON payload:

```json
{
    "status_code": 201,
    "status_message": "OK",
    "message": "quickOrderAddedSuccessfully",
    "is_data": false,
    "data": null
}
```

API returns a `417` error for payload validation errors

```json
{
    "status_code": 417,
    "status_message": "Client Error",
    "message": "payloadValidationErrors",
    "is_error": true,
    "errors": "Array"
}
```

API returns a `500` or `510` error, it means something failed on the server side

```json
{
  "status_code": 510,
  "status_message": "Execution Exception Occurred",
  "message": "somethingWentWrong",
  "is_error": true,
  "errors": "Array"
}
```