# Create Binding

| Environment | URL                                                            |
| ----------- | -------------------------------------------------------------- |
| TEST        | [http://pgtest.payon.com.kh](http://pgtest.payon.com.kh:36605) |
| PRODUCTION  | [https://pg.payon.com.kh](https://pg.payon.com.kh:35505)       |

## Create Binding

<mark style="color:green;">`POST`</mark> `{{URL}}/pg/binding/register`

This endpoint allows you to register card binding without payment.

#### Headers

| Name           | Type   | Description                                                    |
| -------------- | ------ | -------------------------------------------------------------- |
| Authentication | string | Authentication token to track down who is emptying our stocks. |

#### Request Body

| Name                                            | Type   | Description                                                                                |
| ----------------------------------------------- | ------ | ------------------------------------------------------------------------------------------ |
| merchantId<mark style="color:red;">\*</mark>    | string | Merchant's Identification                                                                  |
| termId<mark style="color:red;">\*</mark>        | string | Terminal's Identification                                                                  |
| clientId<mark style="color:red;">\*</mark>      | string | Customer's Identification                                                                  |
| paymentMethod<mark style="color:red;">\*</mark> | string | Payment Method( PAYON, CREDIT\_DEBIT)                                                      |
| wdlAcNo<mark style="color:red;">\*</mark>       | string | Card Number                                                                                |
| wdlCvv                                          | string |                                                                                            |
| wdlExpiry                                       | string | Card expiration date(year and moth) in the following format: YYYYMM.                       |
| wdlNm                                           | string | Name of the cardholder                                                                     |
| payonPin                                        | string | PAYON's PIN. It's required when using PAYON's payment method.                              |
| phone                                           | string | Phone must be valid, It will use for verification for create binding in PAYON PG's system. |
| pin                                             | string | User passcode to identify before do any transaction in PAYON PG's System.                  |
| email                                           | string | Email                                                                                      |

{% tabs %}
{% tab title="200 Binding successfully registered." %}

```
{
    "txDt": null,
    "txSeqNo": null,
    "merchantId": "C0000143",
    "termId": "CT03000003",
    "wdlAcNo": "520473**1003",
    "wdlExpiry": "202512",
    "wdlNm": null,
    "clientId": "C0000143CT0300000302",
    "phone": null,
    "email": null,
    "bindingId": "7ce4dda7-b9f8-4343-883b-e5ff6295e5f9",
    "resultCode": "0000",
    "resultMsg": "Success"
}
```

{% endtab %}
{% endtabs %}

### Example Request

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

```bash
curl --location --request POST 'http://pgtest.payon.com.kh/pg/createBinding' \
--data-raw '{
    "merchantId":"C0000143",
    "termId":"CT03000003",
    "clientId":"02",
    "wdlAcNo":"5204730000001003",
    "wdlCvv":"100",
    "wdlExpiry":"202512",
    "wdlNm":"MC",
    "phone":"855964444781",
    "email":"",
    "pin":"123456"

}'
```

{% endtab %}

{% tab title="Http" %}

```http
POST /pg/createBinding HTTP/1.1
Host: pgtest.payon.com.kh
Content-Length: 242

{
    "merchantId":"C0000143",
    "termId":"CT03000003",
    "clientId":"02",
    "wdlAcNo":"5204730000001003",
    "wdlCvv":"100",
    "wdlExpiry":"202512",
    "wdlNm":"MC",
    "phone":"855964444781",
    "email":"",
    "pin":"123456"

}
```

{% endtab %}

{% tab title="PHP\_Http-Request2" %}

```php
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('http://pgtest.payon.com.kh/pg/createBinding');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setBody('{\n    "merchantId":"C0000143",\n    "termId":"CT03000003",\n    "clientId":"02",\n    "wdlAcNo":"5204730000001003",\n    "wdlCvv":"100",\n    "wdlExpiry":"202512",\n    "wdlNm":"MC",\n    "phone":"855964444781",\n    "email":"",\n    "pin":"123456"\n\n}');
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}
```

{% endtab %}

{% tab title="PHP\_ cURL" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'http://pgtest.payon.com.kh/pg/createBinding',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "merchantId":"C0000143",
    "termId":"CT03000003",
    "clientId":"02",
    "wdlAcNo":"5204730000001003",
    "wdlCvv":"100",
    "wdlExpiry":"202512",
    "wdlNm":"MC",
    "phone":"855964444781",
    "email":"",
    "pin":"123456"

}',
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

>

{% endtab %}

{% tab title="Javascript-Jquery" %}

```javascript
var settings = {
  "url": "http://pgtest.payon.com.kh/pg/createBinding",
  "method": "POST",
  "timeout": 0,
  "data": "{\n    \"merchantId\":\"C0000143\",\n    \"termId\":\"CT03000003\",\n    \"clientId\":\"02\",\n    \"wdlAcNo\":\"5204730000001003\",\n    \"wdlCvv\":\"100\",\n    \"wdlExpiry\":\"202512\",\n    \"wdlNm\":\"MC\",\n    \"phone\":\"855964444781\",\n    \"email\":\"\",\n    \"pin\":\"123456\"\n\n}",
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
```

{% endtab %}

{% tab title="Javascript- XHR" %}

```javascript
var data = "{\n    \"merchantId\":\"C0000143\",\n    \"termId\":\"CT03000003\",\n    \"txId\":\"1614595772233350\",\n    \"amount\":\"1\"\n\n\n}";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "http://pgtest.payon.com.kh/pg/payonApp/payment");

xhr.send(data);
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.payon.com.kh/payon-api-reference/create-binding.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
