> For new integrations, EasyParcel recommends the NextGen API: https://developer.easyparcel.com/

# Making Order Payment

> EasyParcel API · Singapore · Individual · version 1.1.0.0
> Page: https://developers.easyparcel.com/sg/individual/making-order-payment · Markdown: https://developers.easyparcel.com/sg/individual/making-order-payment.md · PDF: https://developers.easyparcel.com/pdf/Singapore_Individual_1.1.0.0.pdf

This step involves payment for the orders made. The authenticated user can do single order payment. Single order payment refers to payment for a single parcel only. There are various payment conditions that may appear such as insufficient credit (when user’s account do not have sufficient credit to perfom payment), sufficient credit (when there are sufficient credit for payment) and etc.

## Endpoint

- Method: `POST`
- Demo URL: `https://demo.connect.easyparcel.sg/?ac=EPPayOrderBulk`
- Live URL: `https://connect.easyparcel.sg/?ac=EPPayOrderBulk`
- Body: `application/x-www-form-urlencoded`. Nested fields use PHP `http_build_query` names, e.g. `bulk[0][pick_code]`.
- Action: `EPPayOrderBulk`

## Request parameters

### Request L1

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `api` | string(25) | Yes | Obtain from registered account. |
| `bulk` | array | Yes | (Refer to [Request L2](#request-l2)) |
| `auto_apply_coupon` | boolean | Optional | Controls whether eligible coupons are automatically applied for the shipment. If this parameter is not specified, the behavior will follow the auto-apply coupon settings configured in EasyParcel. |

### Request L2 · `bulk[]` {#request-l2}

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `order_no` | string(15) | Yes | Acquire from the order that placed. |

## Sample code

### PHP

```php
<?php
$domain = "https://demo.connect.easyparcel.sg/?ac=";

$action = "EPPayOrderBulk";
$postparam = array(
    'api' => 'xxxxxx',
    'bulk' => array(
        array(
            'order_no' => 'EI-000JK',
        ),
        array(
            'order_no' => 'EI-000JK',
        ),
    ),
);

$url = $domain.$action;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postparam));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

ob_start();
$return = curl_exec($ch);
ob_end_clean();
curl_close($ch);

$json = json_decode($return);
echo "<pre>"; print_r($json); echo "</pre>";
?>
```

### cURL

```bash
curl -X POST 'https://demo.connect.easyparcel.sg/?ac=EPPayOrderBulk' \
  --data-urlencode 'api=xxxxxx' \
  --data-urlencode 'bulk[0][order_no]=EI-000JK' \
  --data-urlencode 'bulk[1][order_no]=EI-000JK'
```

## Response

### Response L1

| Field | Type | Description | Remarks |
| --- | --- | --- | --- |
| `api_status` | string(10) | Validation result | (Refer to [Appendix I](https://developers.easyparcel.com/sg/individual/appendix/api-return-status.md)) |
| `error_code` | int(5) | Error code | (Refer to [Appendix I](https://developers.easyparcel.com/sg/individual/appendix/api-return-status.md)) |
| `error_remark` | string(100) | Error message | (Refer to [Appendix I](https://developers.easyparcel.com/sg/individual/appendix/api-return-status.md)) |
| `result` | array | The response of the make order payment | (Refer to [Response L2](#response-l2)) |

### Response L2 · `result` {#response-l2}

| Field | Type | Description | Remarks |
| --- | --- | --- | --- |
| `orderno` | string (15) | Valid order number. | Valid and authenticated. |
| `messagenow` | string (50) | The message that shows the status of order. |  |
| `parcel` | array | The details of the parcel. | (Refer to [Response L3](#response-l3)) |

### Response L3 · `parcel` {#response-l3}

| Field | Type | Description | Remarks |
| --- | --- | --- | --- |
| `parcelno` | string (15) | Parcel number. |  |
| `awb` | string (45) | Airway bill number. |  |
| `awb_id_link` | string (300) | Link of airway bill ID. |  |

## Response samples

### Success

```json
{
  "api_status":"Success",
  "error_code":"0",
  "error_remark":"",
  "result":[
    {
      "orderno":"EI-000JK",
      "messagenow":"Fully paid",
      "parcel":[
        {
          "parcelno":"EP-00016",
          "awb":"86983174113435",
          "awb_id_link":"http:\/\/demo.connect.easyparcel.sg\/?ac=AWBLabel&id=bFk1NHNBQ08jNDYx"
        }
      ]
    },
    {
      "orderno":"EI-000JK",
      "messagenow":"Fully paid",
      "parcel":[
        {
          "parcelno":"EP-00016",
          "awb":"86983174113435",
          "awb_id_link":"http:\/\/demo.connect.easyparcel.sg\/?ac=AWBLabel&id=bFk1NHNBQ08jNDYx"
        }
      ]
    }
  ]
}
```

### Fail

```json
{
  "api_status":"Error",
  "error_code":"3",
  "error_remark":"Required api key",
  "result":[
    
  ]
}
```

## Referenced appendices

Copied from the appendix pages linked above.

### Appendix I: API Return Status

Source: https://developers.easyparcel.com/sg/individual/appendix/api-return-status.md

| api_status | error_code | error_remark |
| --- | --- | --- |
| Error | 3 | Required api key |
| Error | 4 | Invalid api key |
| Error | 5 | Unauthorized user |
| Success | 0 |  |

Support: WhatsApp EasyParcel API Support — https://api.whatsapp.com/send/?phone=6042023160

Published by EasyParcel Singapore Pte Ltd (201605202W). GST No: 201605202W.
