API GETWAY
Use a single endpoint to access every available service based on its service’s name and dynamically parameter. We have provided two common services “create order” and “query order” for our merchant to interact with our customer over a web application (WebPay) to process the payment with dynamic amount and currency.
Development gateway URL: https://devwebpayment.kesspay.io/api/mch/v1/gateway
Authorization: Basic ****{Hashed Basic Auth (username:password)}
CREATE ORDER
Use this service to create a preorder for your seller and deliver the payment link to a buyer to process the payment.
Request Parameter:
Field | Type | Required | Description |
---|---|---|---|
service | String(64) | YES | Gateway service name. |
sign | String(64) | YES | Generated signature based on sign_type and API secret key. |
sign_type | String(64) | YES | Encrypt type is used to encrypt params. Ex: MD5 or HMAC-SHA256) |
sign_id | String(64) | YES | Gateway service name. |
out_trade_no | String(64) | YES | Unique order ID. |
body | String(255) | YES | Order title. |
total_amount | Double | YES | Total amount with two decimal. |
currency | String(3) | YES | Currency code. Ex: USD or KHR. |
detail | Array | No | Product detail. |
login_type | String(16) | No | Default is “GENERAL” the user can register and login by phone number or “FACEBOOK” used to force the user to login with Facebook only.. |
Detail
Field | Type | Required | Description |
---|---|---|---|
no | String(64) | YES | Product ID. |
name | String(64) | YES | Product Name |
price | String(64) | YES | Unit price |
qty | String(64) | YES | Unit quantity |
discount | Integer | No | Unit discount |
REQUEST:
{
]
RESPONSE:
{
],
QUERY ORDER
Use this service to check your order’s ulayment status. We used three simulle status such as WAITING, SUCCESS, CLOSED.
- WAITING: after created preorder.
- SUCCESS: buyer paid for the order.
- CLOSED: order is closed without payment.
Request Parameter:
Field | Type | Required | Description |
---|---|---|---|
service | String(64) | YES | Gateway service name. |
sign | String(64) | YES | Generated signature based on sign_type and API secret key. |
sign_type | String(64) | YES | Encrypt type is used to encrypt params. Ex: MD5 or HMAC-SHA256 |
out_trade_no | String(64) | YES | Unique order ID |
REQUEST:
RESPONSE:
{
],
QUERY ORDER
Use this service to check your order’s ulayment status. We used three simulle status such as WAITING, SUCCESS, CLOSED.
- WAITING: after created preorder.
- SUCCESS: buyer paid for the order.
- CLOSED: order is closed without payment.
Request Parameter:
Field | Type | Required | Description |
---|---|---|---|
service | String(64) | YES | Gateway service name. |
sign | String(64) | YES | Generated signature based on sign_type and API secret key. |
sign_type | String(64) | YES | Encrypt type is used to encrypt params. Ex: MD5 or HMAC-SHA256 |
out_trade_no | String(64) | YES | Unique order ID |
REQUEST:
RESPONSE:
{
],
GENERATE SIGN
We used the sign to make the API more secure. Sign value is dynamically based on request parameters.
Now you can use this $params to make a request to create an order.
$signType = $params['sign_type'];
$string = toUrlParams($params);
$string = $string . "&key=".$key;
// Hash string
if ($signType == "MD5"){
$string = md5($string);
}
else if ($signType == "HMAC-SHA256"){
}
return $string;
foreach ($params as $k => $v){
if($k != "sign" && $v != "" && !is_array($v)){
$buff .= $k . "=" . $v . "&";
}
}
$buff = trim($buff, "&");
return $buff;
Request parameters:
{
]
$params['sign'] = makeSign($params, '{API Secret Key}');