PROCESS DIAGRAM

alt

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

MOTHOD: POST
Hearders:
Content-Type: application/json
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.

alt

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:

{
"service": "webpay.acquire.createorder" ,
"sign": "***" ,
"sign_type": "MD5" ,
"seller_id": "487" ,
"out_trade_no": "TR056011124" ,
"body": "Srey Oun Online Seller" ,
"total_amount": "20" ,
"currency": "USD" ,
"detail": [
{
"no": "03232"
"name": "OLAY 77",
"price": "10.05",
"qty": "2",
"discount": 0.05
}
]
}

RESPONSE:

{
"success": "true" ,
"data": {
"id": "3"
"mch_id": "1",
"user_id": "null",
"out_trade_no": "TR056011124",
"transaction_id": null,
"token": "5e0d4657f09577982b63483f35421054"
"body": "Srey Oun Online Seller",
"total_amount": "20",
"currency": "USD",
"status": "WAITING",
"seller_id": "487",
"notify_url": null,
"detail": [
{
"no": "03232"
"name": "OLAY 77",
"price": "10.05",
"qty": "2",
"discount": 0.05
}
],
"created_at": "14/08/2020 09:24 AM",
"updated_at": "2020-08-14T09:24:06.000000Z",
"payment_link": "https://devwebpayment.kesspay.io/pay/5e0d4657f09577982b63483f35421054"
}
}

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:

{
"service": "webpay.acquire.queryorder" ,
"sign": "5abaa77e13fa437b2e8ca7e52ec8fc12" ,
"sign_type": "MD5" ,
"out_trade_no": "04396-9686056051124"
}

RESPONSE:

{
"success": "true" ,
"data": {
"id": "3"
"mch_id": "1",
"user_id": "null",
"out_trade_no": "04396-9686056051124",
"transaction_id": null,
"token": "5e0d4657f09577982b63483f35421054"
"body": "Srey Oun Online Seller",
"total_amount": "20",
"currency": "USD",
"status": "WAITING",
"seller_id": "487",
"notify_url": null,
"detail": [
{
"no": "03232"
"name": "OLAY 77",
"price": "10.05",
"qty": "2",
"discount": 0.05
}
],
"created_at": "14/08/2020 09:24 AM",
"updated_at": "2020-08-14T09:24:06.000000Z",
"payment_link": "https://devwebpayment.kesspay.io/pay/5e0d4657f09577982b63483f35421054"
}
}

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:

{
"service": "webpay.acquire.queryorder" ,
"sign": "5abaa77e13fa437b2e8ca7e52ec8fc12" ,
"sign_type": "MD5" ,
"out_trade_no": "04396-9686056051124"
}

RESPONSE:

{
"success": "true" ,
"data": {
"id": "3"
"mch_id": "1",
"user_id": "null",
"out_trade_no": "04396-9686056051124",
"transaction_id": null,
"token": "5e0d4657f09577982b63483f35421054"
"body": "Srey Oun Online Seller",
"total_amount": "20",
"currency": "USD",
"status": "WAITING",
"seller_id": "487",
"notify_url": null,
"detail": [
{
"no": "03232"
"name": "OLAY 77",
"price": "10.05",
"qty": "2",
"discount": 0.05
}
],
"created_at": "14/08/2020 09:24 AM",
"updated_at": "2020-08-14T09:24:06.000000Z",
"payment_link": "https://devwebpayment.kesspay.io/pay/5e0d4657f09577982b63483f35421054"
}
}

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.

function makeSign(array $params, string $key)
{
ksort($params);
$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;
}
function toUrlParams(array $params)
{
$buff = "";
foreach ($params as $k => $v){
if($k != "sign" && $v != "" && !is_array($v)){
$buff .= $k . "=" . $v . "&";
}
}
$buff = trim($buff, "&");
return $buff;
}
Request parameters:

$params = [
"service"=> "webpay.acquire.createorder"
"sign_type"=> "MD5"
"seller_id"=> "958689692346",
"out_trade_no"=> "TR5673455626",
"total_amount"=> 16.5,
"currency"=> "USD",
"detail"=> [
{
"no"=> "03232"
"name"=> "OLAY 77",
"price"=> "10.05",
"qty"=> "2",
"discount"=> 0.05
}
]
];

$params['sign'] = makeSign($params, '{API Secret Key}');