POS Consumer-presented QR Code(B Scan C)Integration Guide

Overview

This document describes how merchant or software company use Ksher Quickpay API. The target readers are R&D engineers, architects and other related integration engineers.

Applicable Cases

Support E-Wallets: WeChat Pay/Alipay/Airpay/LinePay/True Money

User Experience Scenarios

quick 1
quick 2
quick 3

Payment Flow Sequence Diagram

Quick pay payment flow
Figure 1. Quick pay payment flow
  1. The cashier calculates the total amount of the goods chosen by the buyer.

  2. The buyer opens the Ewallet App on mobile and presents QR code to the cashier.

  3. The cashier uses scanner over POS/EDC to scan the QR code.

  4. The POS/EDC system call quick_pay API.

  5. The buyer may need to confirm the payment by entering PIN or using fingerprint.

  6. A response will be returned to POS/EDC system with the payment result of 'SUCCESS', 'FAIL' or 'NOTSURE'.

  7. If 'result': 'NOTSUER', Merchant must check the payment status by using order_query API to confirm the current payment status.

  8. For order_query operations, if the payment state is always' NOTSUER', the cashier can choose to reverse this order. It is strongly recommended to reverse any abnormal order.

Specifications of Quick Pay APIs

Order Apply

API method

URL

https://api.mch.ksher.net/KsherPay/quick_pay

Method

POST

Parameter organization format

application/x-www-form-urlencoded

Order Apply Request Parameters

Parameter Type Required Example Description

appid

String(32)

YES

mch12345

Your Merchant Number. Check on merchant ksher. The format is mch{Merchant No}.

nonce_str

String(32)

YES

ae0e6jm55qlq1o7

Random string, must be unique for signature.

channel

String(32)

NO

wechat

Value range:

wechat: Wechat Wallet.

alipay: Alipay Wallet.

alipayplus: Alipay+ Wallet. Country support only Japan and Thailand.

truemoney: TrueMoney Wallet. Country support only Thailand.

airpay: Shopeepay Wallet. Country support only Thailand.

linepay: Rabbit LINE Pay Wallet. Country support only Thailand.

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

Digital signature for verifying the authenticity of digital messages. Please check how to got Signature Algorithm page

mch_order_no

String(256)

YES

123456acb

Merchant order number, generated by merchant self. It must be unique on the merchant side.

total_fee

Integer

YES

100

total amount of the order and it must be an integer, add 00 for decimal.Example 150.50 THB total_fee = 15050

fee_type

String(16)

YES

THB

Currency code for total_fee. refer to with ISO 4217. Value range:

THB: Thailand

MYR: Malaysia

JPY: Japan

AED: United Arab Emirates dirham (UAE)

product

String(512)

NO

Name or description of your product info.

attach

String(127)

NO

any extra information can be added here.

device_id

String(32)

NO

POS001

terminal id from which the request is sent, assigned by merchant.

operator_id

String(32)

NO

41234

operator_id number at cashier, using for merchant have muti level account or Cashier. For more information please check at Muti level account or Cashier

auth_code

String(32)

YES

POS001

authorization code, scanned from the barcode or QR code on the wechat interface of consumer

notify_url

String(256)

NO

http://www.myweb.com/wepay/pay_notify

the url to receive the asynchronous notification about the status of the payment from Ksher; If merchant leaves this field blank, then there will be no notification to send back to merchant.

Example 1. Request Example wechat
{
    "appid": "mch20163",
    "auth_code": "130140675276722852",
    "channel": "wechat",
    "fee_type": "THB",
    "mch_order_no": "1495773587",
    "nonce_str": "sQ8gfSpeeV5Ld8ulW9q7JxUnXSOiZ90Y",
    "sign": "4b609e384500ba8b2ed5eddbcc3aab5c7325c45a13bb5 31655ac459022da0d15ead7e6ab8d73f6d1182117547a6e53871c8da44d99cf02e9d8420c9b20130a2c",
    "time_stamp": "20170526113947",
    "total_fee": 100,
    "version": "3.0.0"
}

Order Apply SUCCESS Response Parameters

Parameter Type Required Example Description

code

int

YES

0

Value Range: * 0: it only shows the calling of the API is successful, not meaning the target business operation succeed. * Non 0: Calling of the API failed, merchant can use the same parameters to launch the request again.

msg

String(32)

YES

the response message.

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

Digital signature for verifying the authenticity of digital messages. Please check how to got Signature Algorithm page

status_code

reserved for future use

status_msg

reserved for future use

time_stamp

String(32)

YES

2020042015374848S

the time stamp of request order

time_end

String(14)

NO

2014-10-30 13:35:25

the merchant local time when the order is finished,the format is yyyy-MM-dd HH:mm:ss

version

version of the API

data Parameters (JSON )

appid

String(32)

YES

mch35000

Your Merchant Number. Check on how to find your appid/Merchant No.. The format is mch{Merchant No}.

attach

String(127)

NO

any extra information can be added here.

cash_fee

int

YES

the amount buyer paid in the currency of cash_fee_type

cash_fee_type

int

YES

comply with ISO 4217, CNY by default.

channel_order_no

String(32)

YES

Order no. Generated by wechat.

device_id

String(32)

NO

POS001

terminal id from which the request is sent, assigned by merchant.

fee_type

String(16)

YES

THB

Currency code for total_fee. refer to with ISO 4217. Value range:

THB: Thailand

MYR: Malaysia

JPY: Japan

AED: United Arab Emirates dirham (UAE)

ksher_order_no

String(32)

YES

generated by Ksher

mch_order_no

String(256)

YES

123456acb

Merchant order number, generated by merchant self. It must be unique on the merchant side.

nonce_str

String(32)

YES

ae0e6jm55qlq1o7

Random string, must be unique for signature.

openid

String(128)

YES

Each customer has a unique id under each service provider.

operation

QUICK-PAY

this shows what operatation the request is.

operator_id

String(32)

NO

41234

operator_id number at cashier, using for merchant have muti level account or Cashier. For more information please check at Muti level account or Cashier

rate

string(16)

YES

exchange rate of foreign currency to RMB.

result

string(16)

YES

SUCCESS

Value range: SUCCESS

time_end

String(14)

NO

2014-10-30 13:35:25

the merchant local time when the order is finished,the format is yyyy-MM-dd HH:mm:ss

total_fee

Integer

YES

100

total amount of the order and it must be an integer, add 00 for decimal.Example 150.50 THB total_fee = 15050

Example 2. SUCCESS Response Example
{
    "code": 0,
    "data":
    {
        "appid":"mch20163",
        "attach": "",
        "cash_fee": 1,
        "cash_fee_type": "CNY",
        "channel_order_no": "4001432001201706013662559711",
        "device_id": "",
        "fee_type": "THB",
        "ksher_order_no": "60020170526123947574894",
        "mch_order_no": "1495773587",
        "nonce_str": "sQ8gfSpeeV5Ld8ulW9q7JxUnXSOiZ90Y",
        "openid": "o5x64wG48fnZyqWOxqJl-MPSkNJ4",
        "operation": "QUICK-PAY",
        "operator_id": "",
        "rate": "0.200212",
        "result": "SUCCESS",
        "time_end": "2017-06-01 10:24:37",
        "total_fee": 100
    },
    "msg": "ok",
    "sign": "65126acc40a48761751eb9fbabf41ca6d08a44be2a175edcaa95cc7e119c224d76d82d5776be6f80ce9a4e535469a7514d318faf5619151266532557ac0f8bd2",
    "status_code": "",
    "status_msg": "",
    "time_stamp": "",
    "version": "3.0.0"
}

Order Query Fail Response Parameters

Parameter Type Required Example Description

code

int

YES

0

Value Range: * 0: it only shows the calling of the API is successful, not meaning the target business operation succeed. * Non 0: Calling of the API failed, merchant can use the same parameters to launch the request again.

msg

String(32)

YES

the response message.

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

Digital signature for verifying the authenticity of digital messages. Please check how to got Signature Algorithm page

status_code

reserved for future use

status_msg

reserved for future use

time_stamp

String(32)

YES

2020042015374848S

the time stamp of request order

version

version of the API

data Parameters (JSON )

err_code

String(32)

YES

SYSTEMERROR

Refer to the error list for the details

err_msg

String(128)

YES

system error

the detailed description of the error

nonce_str

String(32)

YES

ae0e6jm55qlq1o7

Random string, must be unique for signature.

result

string(16)

YES

FAIL

Value range: FAIL, NOTSURE

Example 3. Fail Response Example
{
    "code": 0,
    "data": {
        "err_code": "KSHER_DUPLICATED_ORDERNO",
        "err_msg": "order no. already used.",
        "nonce_str": "33f52a98cd684deadbe78fab3365ef81",
        "result": "FAIL"
    },
    "msg": "ok",
    "sign": "8f0891d6ebf9060e24065e1c8423e154e5b3a5c9ffcca92fc838e89216f0f9d5918879489fe60797681f4db8f13b9cb32ad02afd1642cf1907f9ef81a8d9f895",
    "status_code": "",
    "status_msg": "",
    "time_stamp": "2020-12-25T16:45:25.211077+08:00",
    "version": "3.0.0"
}

Order Query

API method

URL

https://api.mch.ksher.net/KsherPay/order_query

Method

POST

Parameter organization format

application/x-www-form-urlencoded

Order Query Request Parameters

Parameter Type Required Example Description

appid

String(32)

YES

mch35000

Your Merchant Number. Check on how to find your appid/Merchant No.. The format is mch{Merchant No}.

nonce_str

String(32)

YES

ae0e6jm55qlq1o7

Random string, must be unique for signature.

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

Digital signature for verifying the authenticity of digital messages. Please check how to got Signature Algorithm page

mch_order_no

String(32)

YES

order number on merchant side, must be unique

ksher_order_no

String(32)

YES

Order no. generated by Ksher.

channel_order_no

String(32)

YES

Order no. generated by payment channel(wechat, alipay etc.) Note: Not all these three parameters(mch_order_no, ksher_order_no, channel_order_no) are needed to provide at one time, but at least one should be provided.

channel

String(32)

YES

wechat

Value range: wechat/alipay/alipayplus/linepay/airpay/promptpay/truemoney

time_stamp

String(256)

YES

time stamp example: "time_stamp": "20190622131804"

Example 4. Request Example
 {
    "appid": "mch36591",
    "mch_order_no": "test5",
    "nonce_str": "b9536a67afb9153ac880492191857c93",
    "sign": "98b1bcf1546145eff11ad38e1b6dcbc7d929497bdada7bb585da693dd75ea69812d57cd8e983f3db47879810553be42bb0aad40c8103ce60100037857e13c121f4c3c5f456673dee78a9ca66d5096942def3315ec1f6036beaf515e0302f6a4377c03ad2c8de5a6ab17b8e1e6f485c5bad3aa22cae6f0562e6740149788b23b9",
    "time_stamp": "2020122516065757S"
}

Order Query SUCCESS Response Parameters

Parameter Type Required Example Description

code

int

YES

0

code msg:

  • 0: it only shows the calling of the API is successful, not meaning the target business operation succeed.

  • Not 0: Calling of the API failed, merchant can use the same parameter to launch the request again.

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

Digital signature for verifying the authenticity of digital messages. Please check how to got Signature Algorithm page

msg

String(32)

YES

the response message.

status_code

int

YES

  • 0: it only shows the calling of the API is successful, not meaning the target business operation succeed.

  • Not 0: Calling of the API failed, merchant can use the same parameters to launch the request again.

status_msg

String(256)

NO

the status message

time_stamp

String(256)

YES

"20190622131804"

time stamp

version

String(32)

YES

"3.0.0"

API version

data Parameters (JSON )

appid

String(32)

YES

mch35000

Your Merchant Number. Check on how to find your appid/Merchant No.. The format is mch{Merchant No}.

attach

String(127)

NO

any extra information can be added here.

cash_fee

int

YES

specifies the total cash payment amount of a transaction.

cash_fee_type

string(16)

YES

CNY

comply with ISO 4217, CNY by default.

channel_order_no

String(32)

YES

Order no. generated by payment channel(wechat, alipay etc.) Note: Not all these three parameters(mch_order_no, ksher_order_no, channel_order_no) are needed to provide at one time, but at least one should be provided.

device_id

String(32)

NO

POS001

terminal id from which the request is sent, assigned by merchant.

fee_type

String(16)

YES

THB

Currency code for total_fee. refer to with ISO 4217. Value range:

THB: Thailand

MYR: Malaysia

JPY: Japan

AED: United Arab Emirates dirham (UAE)

mch_order_no

String(32)

YES

generated by merchant self, it must be unique on the merchant side, same as the input.

ksher_order_no

String(32)

YES

Order no. generated by Ksher.

merchant_remark

string

nonce_str

String(32)

YES

Random string

openid

String(16)

YES

CNY

Each user has a unique id under E-Wallet.

operation

String(16)

YES

ORDER-QUERY

this shows what operatation the request is.

operator_id

String(32)

NO

41234

operator_id number at cashier, using for merchant have muti level account or Cashier. For more information please check at Muti level account or Cashier

rate

string(16)

YES

exchange rate of foreign currency to RMB.

raw_total_fee

Int

YES

total amount of the order and it must be an integer, the unit is cent

time_end

String(14)

NO

20141030133525

the time when the order is finished,the format is yyyyMMddHHmmss

total_fee

Int

YES

total amount of the order and it must be an integer, the unit is cent

openid

string(16)

YES

o5x64wG48fnZyqWOxqJl-MPSkNJ4

Each user has a unique id under E-Wallet.

result

string(16)

YES

SUCCESS

Value Range: FAIL/SUCCESS/CLOSED/NOTPAY/PAYERROR/PENDING/NOTSURE/USERPAYING/REFUND

  • FAIL: stands for the order query operation failed for some reasons, such as: the order no. could not be found in the ksher database or some parameters are not correct, etc. , it does not means the order failed, merchant should decide the next step according to the error code.

  • SUCCESS: Payment successful, customer already paid.

  • CLOSED: the order is closed, so customer will be not able to pay it any more.

  • NOTPAY: customer quit the payment window, so payment not finished.

  • PAYERROR: the order failed for some reasons, like: wrong password, errors occurred between wechat and bank.

  • PENDING: order pendding on enter PIN

  • NOTSURE: unknown status. on between waiting customer paid..

  • USERPAYING: Wait customer enter PIN. waiting and then call the Query Order API again to check current transaction status.

  • REFUND: the order has refunded partially or completely.

  • Note: after order apply, merchant should regard SUCCESS as final result, the rest result :"NOTPAY/PAYERROR/PENDING/NOTSURE/USERPAYING" means real time status , not the final result, user still can pay again. "FAIL" Only happened when payment channel bank system error, which happens very few. "REFUND" means this amount already turn back to consumer’s.

  • Query Suggestion: Merchant should continue Polling query order result Until you got SUCCESS or over polling time limit. The time limit of polling query should be one day time (45mins once a second and then half an hour , one hour once) just in case. The Actually the "expire_time" is only limit the gateway page valid time. As long as your user redirect to KTB Payment page within gateway expire time, he still can pay with this order after time expired because he is already left gateway page and stepped into KTB Payment page, in which Ksher can not control. so please polling query payment result very often within your expire_time+15mins ,for example every second. If after 45mins it still not SUCCESS, continue polling query for one day but not that often , maybe half an hour , two hour a time.

Example 5. SUCCESS Response Example
{
    "code": 0,
    "data": {
        "appid": "mch32148",
        "attach": "",
        "cash_fee": 7,
        "cash_fee_type": "CNY",
        "channel": "wechat",
        "channel_order_no": "4200000607202006237838347168",
        "consumer_remark": "",
        "device_id": "",
        "fee_type": "THB",
        "ksher_order_no": "90020200623192741778187",
        "mch_order_no": "1592911660",
        "merchant_remark": "\u6d4b\u8bd5",
        "nonce_str": "f4d6aefa63f67ed4abdd83c164191b63",
        "openid": "o2G4c04tmsU-wsCG7jN_ORL5Vh14",
        "operation": "ORDER-QUERY",
        "operator_id": "25382",
        "rate": "0.223410",
        "raw_total_fee": 1,
        "result": "SUCCESS",
        "time_end": "2020-06-23 18:28:31",
        "total_fee": 1
    },
    "msg": "ok",
    "sign": "1ce187f310e73b26f91e76501bb5d360798d22dba67b1b6120209784ea4c6c6f0318650858a575b43c9ded8e5f2931cdecfa8e110af6ec4f93639011c97b07fe",
    "status_code": "",
    "status_msg": "",
    "time_stamp": "2020-06-23T19:28:34.761046+08:00",
    "version": "3.0.0"
}

Order Query Fail Response Parameters

Parameter Type Required Example Description

code

int

YES

0

Value Range:

  • 0: it only shows the calling of the API is successful, not meaning the target business operation succeed.

  • Non 0: Calling of the API failed, merchant can use the same parameters to launch the request again.

sign

String(256)

YES

refer to relevant chapter Signature Algorithm

msg

String(32)

YES

the response message.

status_code

int

YES

  • 0: it only shows the calling of the API is successful, not meaning the target business operation succeed.

  • Non 0: Calling of the API failed, merchant can use the same parameters to launch the request again.

status_msg

String(256)

NO

the status message

time_stamp

String(256)

YES

"20190622131804"

time stamp

version

String(32)

YES

"3.0.0"

API version

data Parameters (JSON )

result

string(16)

YES

FAIL

Value range: FAIL, NOTSURE

err_code

String(32)

YES

SYSTEMERROR

Refer to the error list for the details

err_msg

String(128)

YES

system error

the detailed description of the error

nonce_str

String(32)

YES

Random string

Example 6. Fail Response Example
{
    "code": 0,
    "data": {
        "err_code": "KSHER_INVALID_ORDER_NO",
        "err_msg": "failed to find this order no ('mch_order_no:test5 ksher_order_no: channel_order_no:' ).",
        "nonce_str": "b9536a67afb9153ac880492191857c93",
        "result": "FAIL"
    },
    "msg": "ok",
    "sign": "715f342bed7bffa1e9deb68ff1125283572ee3cde61373aadeca1e90b5a554cc112059baa962eba5c117466a2ecd98ef7c3ef7d9b60f4b07b9b2a9d74a92f823",
    "status_code": "",
    "status_msg": "",
    "time_stamp": "2020-12-25T17:26:41.364745+08:00",
    "version": "3.0.0"
}

Order Refund

API method

URL

https://api.mch.ksher.net/KsherPay/order_refund

Method

POST

Parameter organization format

application/x-www-form-urlencoded

Order Refund Request Parameters

Parameter Type Required Example Description

appid

String(32)

YES

mch12345

Your Merchant Number. Check on merchant ksher. The format is mch{Merchant No}.

nonce_str

String(32)

YES

ae0e6jm55qlq1o7

Random string, must be unique for signature.

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

Digital signature for verifying the authenticity of digital messages. Please check how to got Signature Algorithm page

mch_order_no

String(32)

YES

2103301701291052

order number on merchant side, must be unique

ksher_order_no

String(32)

NO

90020210330180132318847

Order no. generated by Ksher. ksher Order no. should be provided when request card payment refund

channel_order_no

String(32)

YES

1207919130

Order no. generated by payment channel(wechat, alipay etc.) Note: Not all these three parameters(mch_order_no, ksher_order_no, channel_order_no) are needed to provide at one time, but at least one should be provided.

channel

String(32)

NO

wechat

Value range: alipay,wechat,linepay,airpay,promptpay,truemoney

total_fee

Integer

YES

100

total amount of the order and it must be an integer, add 00 for decimal.Example 150.50 THB total_fee = 15050

fee_type

String(16)

YES

THB

Currency code for total_fee. refer to with ISO 4217. Value range:

THB: Thailand

MYR: Malaysia

JPY: Japan

AED: United Arab Emirates dirham (UAE)

mch_refund_no

String(32)

YES

refund_2103301701291052

generated by merchant self, each refund no. can be used once only.

refund_fee

Int

YES

100

amount to refund, unit is cent, it must be an integer. refund partly is permitted.

attach

String(127)

NO

any extra information can be added here.

device_id

String(32)

NO

POS001

terminal id from which the request is sent, assigned by merchant.

operator_id

String(32)

NO

41234

operator_id number at cashier, using for merchant have muti level account or Cashier. For more information please check at Muti level account or Cashier

version

String(32)

NO

API version

Example 7. Request Example
 {
    "appid": "mch35005",
    "fee_type": "THB",
    "mch_order_no": "2103301701291052",
    "mch_refund_no": "refund_2103301701291052",
    "nonce_str": "9c75d11e7572f887dbbfe374f205d5eb",
    "refund_fee": 100,
    "sign": "29cb8b5997f5e15e4c15a8caa4c7eb057a4185f1c6ecaa2a5a826b07bd07fe96a86c964abb38dcf5984399974266784cba8214478a6d9eccada4aa64ccb336d0af31aba0e63eaf0b3e972b19578b0116fdafd9c63f0756d15714284b556dbb76761a09291985bcf06319e4da5abda2652d18b8ce56962c0375168205d9abd301",
    "time_stamp": "2021033014385656S",
    "total_fee": 100
}

or

 {
    "appid": "mch35005",
    "fee_type": "THB",
    "ksher_order_no": "90020210330180132318847",
    "mch_order_no": "2103301701291052",
    "mch_refund_no": "refund_2103301701291052",
    "nonce_str": "9c75d11e7572f887dbbfe374f205d5eb",
    "refund_fee": 100,
    "sign": "0a0efce05ccfbd17d16ae46724a8be7398656177064ac9a71ea3acc6f3fe7a46bebf458d4d15ee4bb6eb750d8cd79dd633a1c13eafd1c8894e45122d3cc4a3f381e4a3874decbdce38b3d3f9de343455bb741f07e019a960e50f577c13b4a6bd0aaf7cc1a47effe38196a64cb730b9d85ef166f3d6c6f7fca6c8edcb1bc87700",
    "time_stamp": "2021033014385656S",
    "total_fee": 100
}

Order Refund SUCCESS Response Parameters

Parameter Type Required Example Description

code

int

YES

0

Value Range:

  • 0: it only shows the calling of the API is successful, not meaning the target business operation succeed.

  • Non 0: Calling of the API failed, merchant can use the same parameter to launch the request again.

msg

String(32)

YES

the response message.

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

Digital signature for verifying the authenticity of digital messages. Please check how to got Signature Algorithm page

status_code

int

YES

1: it only shows the calling of the API is successful, not meaning the target business operation succeed.

Non 0: Calling of the API failed, merchant can use the same parameters to launch the request again.

status_msg

String(256)

NO

the status message

time_stamp

String(32)

YES

2020042015374848S

the time stamp of request order

version

String(32)

NO

"3.0.0"

API version

data Parameters (JSON )

appid

String(32)

YES

mch35000

Your Merchant Number. Check on how to find your appid/Merchant No.. The format is mch{Merchant No}.

attach

String(127)

NO

any extra information can be added here.

cash_refund_fee

int

YES

the currency Amount refunded to customer, normally in CNY.

channel_order_no

String(32)

YES

1207919130

Order no. generated by payment channel(wechat, alipay etc.) Note: Not all these three parameters(mch_order_no, ksher_order_no, channel_order_no) are needed to provide at one time, but at least one should be provided.

channel_refund_no

String(32)

YES

1207919130

generated by channel(wechat), each refund no. can be used once only.

device_id

String(32)

NO

POS001

terminal id from which the request is sent, assigned by merchant.

fee_type

String(16)

YES

THB

Currency code for total_fee. refer to with ISO 4217. Value range:

THB: Thailand

MYR: Malaysia

JPY: Japan

AED: United Arab Emirates dirham (UAE)

ksher_order_no

String(32)

YES

90020210330180132318847

Order no. generated by Ksher.

ksher_refund_no

String(32)

YES

90020210330180400878914

generated by Ksher, each refund no. can be used once only.

mch_order_no

String(32)

YES

generated by merchant self, it must be unique on the merchant side.

mch_refund_no

String(32)

YES

generated by merchant self, each refund no. can be used once only.

nonce_str

String(32)

YES

Random string

operator_id

String(32)

NO

41234

operator_id number at cashier, using for merchant have muti level account or Cashier. For more information please check at Muti level account or Cashier

refund_fee

Int

YES

100

amount to refund, unit is cent, it must be an integer. refund partly is permitted.

result

string(16)

YES

SUCCESS

Value range: SUCCESS

total_fee

Int

YES

total amount of the order and it must be an integer, the unit is cent

Example 8. SUCCESS Response Example
{
    "code": 0,
    "data": {
        "appid": "mch35005",
        "attach": "",
        "cash_refund_fee": 100,
        "channel": "airpay",
        "channel_order_no": "1207919130",
        "channel_refund_no": "1207919130",
        "device_id": "",
        "fee_type": "THB",
        "ksher_order_no": "90020210330180132318847",
        "ksher_refund_no": "90020210330180400878914",
        "mch_order_no": "2103301701291052",
        "mch_refund_no": "refund_2103301701291052",
        "nonce_str": "9c75d11e7572f887dbbfe374f205d5eb",
        "operator_id": "",
        "refund_fee": 100,
        "refund_time": "2021-03-30 17:04:01",
        "result": "SUCCESS",
        "total_fee": 100
    },
    "msg": "ok",
    "sign": "4e8defe365f08a66b28f40843117268c49c772807196ac0b55591f992a9dcdff5d68f8fec01f029d0922df6795b72e211a3fc2de8056e4b19dc6ceaad86894f1",
    "status_code": "",
    "status_msg": "",
    "time_stamp": "2021-03-30T18:04:01.525337+08:00",
    "version": "3.0.0"
}

Order Refund FAIL Response Parameters

Parameter Type Required Example Description

code

int

YES

0

Value Range:

  • 0: it only shows the calling of the API is successful, not meaning the target business operation succeed.

  • Non 0: Calling of the API failed, merchant can use the same parameter to launch the request again.

msg

String(32)

YES

the response message.

version

String(32)

YES

"3.0.0"

version of the API

status_code

int

YES

0: it only shows the calling of the API is successful, not meaning the target business operation succeed.

Non 0: Calling of the API failed, merchant can use the same parameters to launch the request again.

status_msg

String(256)

NO

the status message

time_stamp

String(32)

YES

2020042015374848S

the time stamp of request order

data Parameters (JSON )

result

string(16)

YES

FAIL

Value range:

  • FAIL : failed to close,in this case, merchant should re-launch the close request.

  • NOTSURE: it is not sure if the close operation succeed.

err_code

String(32)

YES

SYSTEMERROR

refer to the error list for the details

err_msg

String(128)

YES

system error

the detailed description of the error

nonce_str

String(32)

YES

Random string

Example 9. FAIL Response Example
{
    "code": 0,
    "data": {
        "err_code": "KSHER_SYSTEMERROR",
        "err_msg": "ksher system error. please retry.",
        "nonce_str": "19f47657a679646276f213eb67782763",
        "result": "FAIL"
    },
    "msg": "ok",
    "sign": "055ac35d8eede994c67398ede3ce91c3970460b379f26eff58bc4a838a9f1a837e41dc4a9a5c1fe6f1ba8f153459f679cdbfaeec94bcbcb16fe0d54a76b84e59",
    "status_code": "",
    "status_msg": "",
    "time_stamp": "2020-07-14T16:43:41.178834+08:00",
    "version": "3.0.0"
}

QR value Format

TrueMoney

have total of 14 numbers, the first two digits start with "00". Example 00002727475523

LINE Pay

have 12 length and have only numbers. Example 3486 6978 2883

Shopee

total of 20 numbers, the first 4 digits will start with "918" Example 9180 3136 0216 0934 1400

Alipay and Alipay+

QR Code value for detect B scan C Alipay and Alipay+

Length of CPC Code Issuer ID (CII) Other Conditions Regular Expression Code Issuer

1

17

28

N/A

28[0-9]{15}

AlipayCN

2

18

28

N/A

28[0-9]{16}

AlipayCN

3

19

280 ~ 288

N/A

28[0-8][0-9]{16}

AlipayCN

4

19

289

14th byte does not equal to "6"

289[0-9]{10}[0-57-9][0-9]{5}

AlipayCN

5

19

289

14th byte equals to "6"

289[0-9]{10}6[0-9]{5}

A+

6

24

28100100 ~ 28100199

N/A

281001[0-9]{18}

AlipayCN

Please refer to this regular expression.

  1. You can identify if its a A+ code based on #5 rule first. If its no, go to step 2

  2. Validate for Alipay CN for #1,#2,#3,#4 and #6 and route to Alipay China.

WeChat Pay

total 18 numbers, starting with "13".

Webhook Notify

What’s Webhook?

  • Webhook is API response when Customer paid like event. It make customer don’t need to polling to check status.

When webhook callback?

  • add parameter name "notify_url" when you request, ksher will initiate a webhook callback.

  • ksher will polling check the status payment within 2 hours.

    • if the order has been successful payment within 2 hours, webhook will callback.

    • if the order has not been paid within 2 hours , The merchant needs to query request by yourself.

  • If ksher got callback from wallet. we will call webhook to merchant also.

What going on If internet not stable and don’t got webhook at the first time?

  • If the merchant does not return correct format,we will try to callback again.

Correct format response

{"result": "SUCCESS", "msg": "OK"}

This is table webhook with times notification, if customer not response correct success type and or we can’t callback

Times retry Times between the last retry

1st retry

1s

2nd retry

2s

3rd retry

2s

4th retry

10s

5th retry

30s

6th retry

1min

7th retry

10min

8th retry

1hour

9th retry

3hour

10th retry

5hour

11th retry

8hour

12th retry

12hour

Delayed messages will be retried 12 times within 29 hours

After consumer pays, Ksher system will notify merchant only SUCCUSSFULL payment

API method

URL

http://api.mch.ksher.net/KsherPay/pay_notify

Method

POST

Parameter organization format

text/plain;charset=utf-8

Payment Result of SUCCESS

Parameter Type Required Example Description

code

int

YES

0

0: it only shows the calling of the API is successful, not meaning the target business operation succeed.

status_code

int

YES

  • 0: it only shows the calling of the API is successful, not meaning the target business operation succeed.

  • Non 0: Calling of the API failed, merchant can use the same parameters to launch the request again.

status_msg

String(256)

NO

the status message

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

Digital signature for verifying the authenticity of digital messages. Please check how to got Signature Algorithm page

version

String(32)

YES

"3.0.0"

API version

msg

String(32)

YES

ok

the response message.

time_stamp

String(256)

YES

"20190622131804"

time stamp

data Parameters (JSON )

appid

String(32)

YES

mch35000

Your Merchant Number. Check on how to find your appid/Merchant No.. The format is mch{Merchant No}.

nonce_str

String(32)

YES

ae0e6jm55qlq1o7

Random string, must be unique for signature.

openid

String(128)

YES

o5x64wG48fnZyqWOxqJl-MPSkNJ4

Customer’s id under this merchant’s public account.

channel_order_no

String(32)

YES

4001432001201705110439447536

Order no. generated by payment channel(alipay, alipay etc.)Note:Not all these three parameters(mch_order_no, ksher_order_no, channel_order_no) are needed to provide at one time, but at least one should be provided.

operator_id

String(32)

NO

41234

operator_id number at cashier, using for merchant have muti level account or Cashier. For more information please check at Muti level account or Cashier

cash_fee_type

String

YES

THB

e-wallet local currency, e.g. THB for Thailand e-wallets, CNY for Chinese e-wallets Alipay, WeChat Pay.

ksher_order_no

String(32)

YES

90020210420105438458353

Order no. generated by Ksher.

time_end

String(14)

YES

2014-10-30 13:35:25

the merchant local time when the order is finished,the format is yyyy-MM-dd HH:mm:ss

fee_type

String(16)

YES

THB

Currency code for total_fee. refer to with ISO 4217. Value range:

THB: Thailand

MYR: Malaysia

JPY: Japan

AED: United Arab Emirates dirham (UAE)

attach

String(127)

YES

any extra information can be added here.

rate

string(16)

YES

exchange rate of foreign currency to RMB.

result

string(16)

YES

SUCCESS

Status payment. Value range: SUCCESS

total_fee

Integer

YES

100

total amount of the order and it must be an integer, add 00 for decimal.Example 150.50 THB total_fee = 15050

operation

String

YES

QUICK-PAY

this shows what operatation the request is.

device_id

String(32)

NO

POS001

terminal id from which the request is sent, assigned by merchant.

cash_fee

int

YES

specifies the total cash payment amount of a transaction.

mch_order_no

String(32)

YES

generated by merchant self, it must be unique on the merchant side, same as the input.

order_no

String(32)

YES

generated by merchant self, it must be unique on the merchant side, same as the input.Equate to mch_order_no.

Example 10. SUCCESS Example

Data will response in text format following like this

{"code": 0, "version": "3.0.0", "status_code": "", "msg": "ok", "time_stamp": "2023-05-22T15:14:55.794084+08:00", "status_msg": "", "data": {"openid": "tmn.10036553303", "channel_order_no": "230522141453987OFSWN", "operator_id": "29398", "cash_fee_type": "THB", "ksher_order_no": "90020230522151258706179", "nonce_str": "4XiQyVYA98tNo21jSX24oatxw6FTXo6D", "time_end": "2023-05-22 14:14:53", "fee_type": "THB", "attach": "", "rate": 0.0, "result": "SUCCESS", "total_fee": 100, "appid": "mch35005", "order_no": "20230522140400", "operation": "NATIVE-PAY", "device_id": "", "cash_fee": 100, "channel": "truemoney", "mch_order_no": "20230522140400"}, "sign": "40cb0b83dd675d5f043ac57696d92575e337431fc682d3dbe529cb324cb2a4cfefe6984b9811790c6c1f0dc75e4fa83a8bb3114ad9a3eeef55dba453ea844706"}

after convert data to json format will following this

{
   "code":0,
   "version":"3.0.0",
   "status_code":"",
   "msg":"ok",
   "time_stamp":"2023-05-22T15:14:55.794084+08:00",
   "status_msg":"",
   "data":{
      "openid":"tmn.10036553303",
      "channel_order_no":"230522141453987OFSWN",
      "operator_id":"29398",
      "cash_fee_type":"THB",
      "ksher_order_no":"90020230522151258706179",
      "nonce_str":"4XiQyVYA98tNo21jSX24oatxw6FTXo6D",
      "time_end":"2023-05-22 14:14:53",
      "fee_type":"THB",
      "attach":"",
      "rate":0.0,
      "result":"SUCCESS",
      "total_fee":100,
      "appid":"mch35005",
      "order_no":"20230522140400",
      "operation":"NATIVE-PAY",
      "device_id":"",
      "cash_fee":100,
      "channel":"truemoney",
      "mch_order_no":"20230522140400"
   },
   "sign":"40cb0b83dd675d5f043ac57696d92575e337431fc682d3dbe529cb324cb2a4cfefe6984b9811790c6c1f0dc75e4fa83a8bb3114ad9a3eeef55dba453ea844706"
}
notes:

In the notify calling back function, a response is needed to return to Ksher Server, the response is JSON formated and the content is as follow:

Example 11. For success:
{"result": "SUCCESS", "msg": "OK"}
Example 12. For error:
{"result": "FAIL", "msg": "some error information"}

Order Close

API method

URL

https://api.mch.ksher.net/KsherPay/order_close

Method

POST

Parameter organization format

application/x-www-form-urlencoded

Order Close Request Parameters

Parameter Type Required Example Description

appid

String(32)

YES

mch12345

Your Merchant Number. Check on merchant ksher. The format is mch{Merchant No}.

nonce_str

String(32)

YES

ae0e6jm55qlq1o7

Random string, must be unique for signature.

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

Digital signature for verifying the authenticity of digital messages. Please check how to got Signature Algorithm page

channel

String(32)

YES

wechat

Value range:

  • airpay

  • wechat

  • alipay

  • alipayplus :only japan merchant

  • ktbcard

mch_order_no

String(32)

YES

order number on merchant side, must be unique

ksher_order_no

String(32)

YES

Order no. generated by Ksher.

channel_order_no

String(32)

YES

Order no. generated by payment channel(wechat, alipay etc.) Note: Not all these three parameters(mch_order_no, ksher_order_no, channel_order_no) are needed to provide at one time, but at least one should be provided.

time_stamp

String(256)

YES

time stamp example: "time_stamp": "20190622131804"

Example 13. Request Example
{
    "code": 0,
    "data": {
        "appid": "mch36591",
        "mch_order_no": "test3",
        "nonce_str": "7a57e84495bfe7abff4ff23591516511",
        "result": "SUCCESS"
    },
    "msg": "ok",
    "sign": "61805f39c7c484d936cbf40c864b11b9fec0b93205fdbc4efe5b71c9c7dfd98152e1ebc9af5866dd54cf58008418b52ea6122e7994f1d3fe5e6d559a8b022e5f",
    "status_code": "",
    "status_msg": "",
    "time_stamp": "2020-12-25T17:44:54.226116+08:00",
    "version": "3.0.0"
}

Order Close SUCCESS Response Parameters

Parameter Type Required Example Description

code

int

YES

0

code msg:

  • 0: it only shows the calling of the API is successful, not meaning the target business operation succeed.

  • Not 0: Calling of the API failed, merchant can use the same parameter to launch the request again.

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

Digital signature for verifying the authenticity of digital messages. Please check how to got Signature Algorithm page

msg

String(32)

YES

the response message.

status_code

int

YES

  • 0: it only shows the calling of the API is successful, not meaning the target business operation succeed.

  • Not 0: Calling of the API failed, merchant can use the same parameters to launch the request again.

status_msg

String(256)

NO

the status message

time_stamp

String(256)

YES

"20190622131804"

time stamp

version

String(32)

YES

"3.0.0"

API version

data Parameters (JSON )

appid

String(32)

YES

mch35000

Your Merchant Number. Check on how to find your appid/Merchant No.. The format is mch{Merchant No}.

mch_order_no

String(32)

YES

generated by merchant self, it must be unique on the merchant side, same as the input.

nonce_str

String(32)

YES

Random string

result

string(16)

YES

SUCCESS

Value range: SUCCESS

Example 14. SUCCESS Response Example
{
    "code": 0,
    "data": {
        "appid": "mch36591",
        "mch_order_no": "test3",
        "nonce_str": "7a57e84495bfe7abff4ff23591516511",
        "result": "SUCCESS"
    },
    "msg": "ok",
    "sign": "61805f39c7c484d936cbf40c864b11b9fec0b93205fdbc4efe5b71c9c7dfd98152e1ebc9af5866dd54cf58008418b52ea6122e7994f1d3fe5e6d559a8b022e5f",
    "status_code": "",
    "status_msg": "",
    "time_stamp": "2020-12-25T17:44:54.226116+08:00",
    "version": "3.0.0"
}

Order Query Fail Response Parameters

Parameter Type Required Example Description

code

int

YES

0

Value Range:

  • 0: it only shows the calling of the API is successful, not meaning the target business operation succeed.

  • Non 0: Calling of the API failed, merchant can use the same parameters to launch the request again.

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

Digital signature for verifying the authenticity of digital messages. Please check how to got Signature Algorithm page

msg

String(32)

YES

the response message.

status_code

int

YES

  • 0: it only shows the calling of the API is successful, not meaning the target business operation succeed.

  • Non 0: Calling of the API failed, merchant can use the same parameters to launch the request again.

status_msg

String(256)

NO

the status message

time_stamp

String(256)

YES

"20190622131804"

time stamp

version

String(32)

YES

"3.0.0"

API version

data Parameters (JSON )

result

string(16)

YES

FAIL

Value range: FAIL, NOTSURE.

  • FAIL : failed to close,in this case, merchant should re-launch the close request.

  • NOTSURE: it is not sure if the close operation succeed.

err_code

String(32)

YES

SYSTEMERROR

Refer to the error list for the details

err_msg

String(128)

YES

system error

the detailed description of the error

nonce_str

String(32)

YES

Random string

Example 15. Fail Response Example
{
    "code": 0,
    "data": {
        "err_code": "KSHER_INVALID_ORDER_NO",
        "err_msg": "failed to find this order no ('mch_order_no:test33,ksher_order_no:,channel_order_no:',).",
        "nonce_str": "7a57e84495bfe7abff4ff23591516511",
        "result": "FAIL"
    },
    "msg": "ok",
    "sign": "01d2436ef5ed44cb77d3594adccc2c92e2a6a8b39cad2bd1abc3dcd9d64b7c00a303355fc47cb61c3862fb116ed7f67b9db73634da95e91a1fcfc6b12a96da59",
    "status_code": "",
    "status_msg": "",
    "time_stamp": "2020-12-25T17:55:25.248752+08:00",
    "version": "3.0.0"
}

Order Reverse

Only WeChat Pay E-Wallet is supported

order reverse will support only quick_pay API pay over wechat

  • if customer notpay, status will change to order close.

  • If customer paid successfully, status will change to refund.

API method

URL

http://api.mch.ksher.net/KsherPay/order_reverse

Method

POST

Parameter organization format

application/x-www-form-urlencoded

Order Reverse Request Parameters

Parameter Type Required Example Description

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

Digital signature for verifying the authenticity of digital messages. Please check how to got Signature Algorithm page

appid

String(32)

YES

mch35000

Your Merchant Number. Check on how to find your appid/Merchant No.. The format is mch{Merchant No}.

nonce_str

String(32)

YES

Random string

mch_order_no

String(32)

YES

generated by merchant self, it must be unique on the merchant side.

ksher_order_no

String(32)

YES

Order no. generated by Ksher.

channel_order_no

String(32)

YES

Order no. generated by payment channel(wechat, alipay etc.) Note: Not all these three parameters(mch_order_no, ksher_order_no, channel_order_no) are needed to provide at one time, but at least one should be provided.

channel

String(32)

YES

wechat

Value range: wechat

product

String(512)

NO

NO

attach

String(127)

NO

any extra information can be added here.

device_id

String(32)

NO

POS001

terminal id from which the request is sent, assigned by merchant.

operator_id

String(32)

NO

41234

operator_id number at cashier, using for merchant have muti level account or Cashier. For more information please check at Muti level account or Cashier

Example 16. Request Example
{
    "appid": "mch20163",
    "channel": "wechat",
    "channel_order_no": "",
    "ksher_order_no": "",
    "mch_order_no": "1496287229",
    "nonce_str": "YbMwF8WjGJlwRsx6fvUVVanYzbaUwGqS",
    "sign": "0e24408a357d14cdd1ddad8c1b6c78e1be2b9fdb1a01cc9caf50b336d50fd313b6308710c5f7e57c7cd90bfaa70da1010830be3dfcbb9cbd844f6d3c2226ab73",
    "time_stamp": "20170601102216",
    "version": "1.0.0"
}

Order Reverse SUCCESS Response Parameters

Parameter Type Required Example Description

code

int

YES

0

Value Range:

  • 0: it only shows the calling of the API is successful, not meaning the target business operation succeed.

  • Non 0: Calling of the API failed, merchant can use the same parameter to launch the request again.

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

Digital signature for verifying the authenticity of digital messages. Please check how to got Signature Algorithm page

msg

String(32)

YES

the response message.

status_code

reserved for future use

status_msg

reserved for future use

time_stamp

time stamp of the response

version

version

data Parameters (JSON )

appid

String(32)

YES

mch35000

Your Merchant Number. Check on how to find your appid/Merchant No.. The format is mch{Merchant No}.

mch_order_no

String(32)

YES

generated by merchant self, it must be unique on the merchant side, same as the input.

nonce_str

String(32)

YES

Random string

result

string(16)

YES

SUCCESS

SUCCESS

Example 17. SUCCESS Response Example
{
    "code": 0,
    "data": {
        "appid": "mch20163",
        "mch_order_no": "1496287229",
        "nonce_str": "YbMwF8WjGJlwRsx6fvUVVanYzbaUwGqS",
        "result": "SUCCESS"
    },
    "msg": "ok",
    "sign": "95fd51e0092118d2049522b03baf1d5a05e2d37d32cc6065ef851d72772bb12df625ee032e180f066446f3fe4aa8ec298fba62501597d8ea54b9935bb2d7e58c",
    "status_code": "",
    "status_msg": "",
    "time_stamp": "",
    "version": "2.0.0"
}

Order Reverse FAIL Response Parameters

Parameter Type Required Example Description

code

int

YES

0

Value Range:

  • 0: it only shows the calling of the API is successful, not meaning the target business operation succeed.

  • Non 0: Calling of the API failed, merchant can use the same parameter to launch the request again.

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

Digital signature for verifying the authenticity of digital messages. Please check how to got Signature Algorithm page

msg

String(32)

YES

the response message.

status_code

reserved for future use

status_code

reserved for future use

status_msg

reserved for future use

time_stamp

String(32)

YES

2020042015374848S

the time stamp of request order

version

version of the API

data Parameters (JSON )

err_code

String(32)

YES

SYSTEMERROR

refer to the error list for the details

err_msg

String(128

YES

system error

the detailed description of the error

nonce_str

String(32)

YES

Random string

result

string(16)

YES

FAIL

FAIL

Example 18. FAIL Response Example
{
    "code": 0,
    "data": {
        "err_code": "KSHER_INVALID_ORDER_NO",
        "err_msg": "failed to find this order no ('mch_order_no:14957735877,ksher_order_no:,channel_order_no:',).",
        "nonce_str": "p7hJ4T8mHNDNWhQX1yFwgDn3IUd3nohg",
        "result": "FAIL"
    },
    "msg": "ok",
    "sign": "52271285fec6ed13fbe30762e77f32cbde77745c7ea5398b5ea6f2d3ff6d2d6b38014eb34afad6b09bd95aabcd70ce8aea1937b090233368a8a85115e55c7a51",
    "status_code": "",
    "status_msg": "",
    "time_stamp": "",
    "version": "2.0.0"
}

Refund Query

Note: Promptpay and Aliapy not support this feature.

API method

URL

https://api.mch.ksher.net/KsherPay/refund_query

Method

POST

Parameter organization format

application/x-www-form-urlencoded

Refund Query Request Parameters

Parameter Type Required Example Description

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

Digital signature for verifying the authenticity of digital messages. Please check how to got Signature Algorithm page

appid

String(32)

YES

mch12345

Your Merchant Number. Check on merchant ksher. The format is mch{Merchant No}.

nonce_str

String(32)

YES

ae0e6jm55qlq1o7

Random string, must be unique for signature.

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

Digital signature for verifying the authenticity of digital messages. Please check how to got Signature Algorithm page

mch_order_no

String(32)

YES (mch_order_no, ksher_order_no, channel_order_no not needed to provide all, you can select at least one parameters to to sending.)

order number on merchant side, must be unique

ksher_order_no

String(32)

YES (mch_order_no, ksher_order_no, channel_order_no not needed to provide all, you can select at least one parameters to to sending.)

Order no. generated by Ksher.

channel_order_no

String(32)

YES (mch_order_no, ksher_order_no, channel_order_no not needed to provide all, you can select at least one parameters to to sending.)

Order no. generated by payment channel(wechat, alipay etc.)

channel

String(32)

NO

wechat

Value range: wechat/alipay/linepay/airpay/promptpay/truemoney

total_fee

Int

YES

total amount of the order and it must be an integer, the unit is cent

fee_type

String(16)

YES

THB

Currency code for total_fee. refer to with ISO 4217. Value range:

THB: Thailand

MYR: Malaysia

JPY: Japan

AED: United Arab Emirates dirham (UAE)

mch_refund_no

String(32)

YES

generated by merchant self, each refund no. can be used once only.

refund_fee

Int

YES

100

amount to refund, unit is cent, it must be an integer. refund partly is permitted.

attach

String(127)

NO

any extra information can be added here.

device_id

String(32)

NO

POS001

terminal id from which the request is sent, assigned by merchant.

operator_id

String(32)

NO

41234

operator_id number at cashier, using for merchant have muti level account or Cashier. For more information please check at Muti level account or Cashier

time_stamp

String(256)

YES

time stamp example: "time_stamp": "20190622131804"

version

String(32)

NO

"3.0.0"

API version

Example 19. Request Example
{
    "appid": "mch20163",
    "channel": "wechat",
    "fee_type": "THB",
    "ksher_order_no": "",
    "mch_order_no": "1495773587",
    "nonce_str": "IeYrVB93dq8JbJbHJq1oZAW4d7PEb4jU",
    "sign":     "14bc865f1d360210ef9b7551304faa905f2240e1f7eca2ddaadcdc1287cda90f3149dac8aab7163084be4fdf56fe12bdc95ae87a6b4187b94e4118e435f0db23",
    "time_stamp": "20170516125822",
    "version": "3.0.0"
}

or

 {
    "appid": "mch28321",
    "ksher_order_no": "70020200714124058662887",
    "mch_refund_no": "refund1594708697",
    "nonce_str": "a42e75d0f3859e31f93146aaf4cf4f48",
    "sign": "78f93882b5456bcd3bba29704c820f93f0863c633697322147f60b32eaeb78f4f99b79d65ff48cd1118c1955a05b674fb496b38e29692064608bf511f09141bc",
    "time_stamp": "2020071417093939S"
}

Refund Query SUCCESS Response Parameters

Parameter Type Required Example Description

code

int

YES

0

Value Range :

  • 0: it only shows the calling of the API is successful, not meaning the target business operation succeed.

  • Non 0: Calling of the API failed, merchant can use the same parameter to launch the request again.

msg

String(32)

YES

the response message.

status_code

reserved for future use

status_code

int

YES

1: it only shows the calling of the API is successful, not meaning the target business operation succeed.

Non 0: Calling of the API failed, merchant can use the same parameters to launch the request again.

status_msg

String(256)

NO

the status message

time_stamp

String(32)

YES

2020042015374848S

the time stamp of request order

version

String(32)

NO

"3.0.0"

API version

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

Digital signature for verifying the authenticity of digital messages. Please check how to got Signature Algorithm page

data Parameters (JSON )

cash_fee

int

YES

CNY

specifies the total cash payment amount of a transaction.

cash_fee_type

string(16)

YES

CNY

the currency buyer paid, comply with ISO 4217, CNY by default.

channel_order_no

String(32)

YES

Order no. generated by payment channel(wechat, alipay etc.) Note: Not all these three parameters(mch_order_no, ksher_order_no, channel_order_no) are needed to provide at one time, but at least one should be provided.

channel_state

string(16)

YES

SUCCESS

the response state from e-wallet

fee_type

String(16)

YES

THB

Currency code for total_fee. refer to with ISO 4217. Value range:

THB: Thailand

MYR: Malaysia

JPY: Japan

AED: United Arab Emirates dirham (UAE)

ksher_order_no

String(32)

YES

Order no. generated by Ksher.

mch_order_no

String(32)

YES

generated by merchant self, it must be unique on the merchant side.

nonce_str

String(32)

YES

"sQ8gfSpeeV5Ld8ulW9q7JxUnXSOiZ90Y"

Random string

refund_count

int

YES

Total times of refund for this order.

refund_fee

Int

YES

100

amount to refund, unit is cent, it must be an integer. refund partly is permitted.

refund_orders Parameters (JSON )

channel_refund_no

String(32)

YES

generated by channel(wechat), each refund no. can be used once only.

ksher_refund_no

String(32)

YES

generated by Ksher, each refund no. can be used once only.

mch_refund_fee

String(32)

YES

100

amount to refund, unit is cent, it must be an integer. refund partly is permitted.

mch_refund_no

String(32)

YES

generated by merchant self, each refund no. can be used once only.

refund_state

String(32)

YES

SUCCESS

refund status:

  • REFUNDSUCCESS—succeeded to refund,

  • FAIL—failed to refund, PROCESSING—the refund application is being processed,

  • NOTSURE—not sure(merchant needs to submit refund application again with the same refund no.),

  • CHANGE—change to the merchant paying(the bank card of the consumer is already unavailable or frozen, which lead to the failure of refunding back into the bank card and funds flew back to the cash account, in this case, merchant needs to refund consumer offline or through transfer )

refund_time

String(14)

YES

When the refund was made.

Example 20. SUCCESS Response Example
 {
    "code": 0,
    "data": {
        "appid": "mch28321",
        "cash_fee": 204,
        "cash_fee_type": "THB",
        "channel_order_no": "509366",
        "fee_type": "THB",
        "ksher_order_no": "70020200714124058662887",
        "mch_order_no": "2007141140508182",
        "nonce_str": "a42e75d0f3859e31f93146aaf4cf4f48",
        "refund_count": 1,
        "refund_fee": 0,
        "refund_orders": [
            {
                "channel_refund_no": "",
                "ksher_refund_no": "70020200714143818745766",
                "mch_refund_fee": 100,
                "mch_refund_no": "refund1594708697",
                "refund_state": "FAIL",
                "refund_time": "2020-07-14 13:38:18"
            }
        ],
        "result": "SUCCESS",
        "time_end": "2020-07-14 13:38:18",
        "total_fee": 204
    },
    "msg": "ok",
    "sign": "01bc29db4a5d01c0d2a414dd1fc7e8ab122ce48934fd2f9c63e748e9a6b2a2dc52f35bedffda2a42a1eea686dad3fc5af8c481d28bd76fff8870e029094aac76",
    "status_code": "",
    "status_msg": "",
    "time_stamp": "2020-07-14T17:09:40.730470+08:00",
    "version": "3.0.0"
}

Refund Query FAIL Response Parameters

Parameter Type Required Example Description

code

int

YES

0

Value Rangne:

  • 0: it only shows the calling of the API is successful, not meaning the target business operation succeed.

  • Non 0: Calling of the API failed, merchant can use the same parameters to launch the request again.

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

Digital signature for verifying the authenticity of digital messages. Please check how to got Signature Algorithm page

msg

String(32)

YES

the response message.

status_code

int

YES

Value Range:

  • 0: it only shows the calling of the API is successful, not meaning the target business operation succeed.

  • Non 0: Calling of the API failed, merchant can use the same parameters to launch the request again.

status_msg

String(256)

NO

the status message

time_stamp

String(256)

YES

"20190622131804"

time stamp

version

String(32)

YES

"3.0.0"

API version

data Parameters (JSON )

result

string(16)

YES

FAIL

Value range:

  • FAIL, NOTSURE .

  • FAIL : failed to close,in this case, merchant should re-launch the close request.

  • NOTSURE: it is not sure if the close operation succeed.

nonce_str

String(32)

YES

"sQ8gfSpeeV5Ld8ulW9q7JxUnXSOiZ90Y"

Random string

err_code

String(32)

YES

SYSTEMERROR

Refer to the error list for the details

err_msg

String(128)

YES

system error

the detailed description of the error

Example 21. FAIL Response Example
 {
    "code": 0,
    "data": {
        "err_code": "KSHER_INVALID_ORDER_NO",
        "err_msg": "failed to find this order no ('mch_refund_no:refund1594708697i' ).",
        "nonce_str": "4d4309ac8556d17238a297ea917b7b81",
        "result": "FAIL"
    },
    "msg": "ok",
    "sign": "012cc8f39b1b41857ed2511066ad76c4045c87a98b94e3574064b9ac130e5b56b4a572c96a37644a8b53a7ca25ee5bae051c9b89a8323852e2eb805484a4d399",
    "status_code": "",
    "status_msg": "",
    "time_stamp": "2020-07-14T17:13:32.181825+08:00",
    "version": "3.0.0"
}

ERROR CODES

Name Description Reason Solution

APPID_NOT_EXIST

APPID not exist

APPID was absent in parameters.

Please check if the APPID is correct.

APPID_MCHID_NOT_MATCH

APPID and MCHID not match

APPID and MCHID not match

please check if the APPID and mchid match.

INVALID_ORDER_NO

invalid order no.

order no. passed in is not correct.

parameter error, please check if the original order no. passed in exist or if the original order is failed.

KSHER_SIGN_ERROR

signature error

merchant signature is not correct

check the signature parameter

KSHER_SYSTEMERROR

Error occurred during handling the request.

Error occurred during handling the request.

Issue the refund request again.

KSHER_VERSION_ERROR

API version used by merchant is not compatible with the API of the vendor

API version used does not match

contact the vendor to confirm current API version

KSHER_ERROR_ORDER_NO

Missing order no parameter

Missing order no parameter

Check the order no.(mch_order_no, ksher_order_no, channel_order_no)

KSHER_REFUND_EXPIRE

Refund can not be made via API by merchant after the order already settled.

Refund can not be made via API by merchant after the order already settled.

Please submit refund request on the Ksher merchant platform.

KSHER_INVALID_MCHINFO

merchant information is not correct

the appid passed in does not exist in the vendor’s system

confirm if the appid passed in is correct, contact the vendor if needed.

KSHER_INVALID_ORDER_NO

order no. does not exist

the order no. passed in cannot be found in vendor’s system

check if the order no. passed in is correct

KSHER_INVALID_REFUND_FEE

invalid amount to refund

amount to refund is greater than the available amount

check if the amount to refund is correct

KSHER_INVALID_REFUND_AMOUNT

Partially refund is not allowed

Partially refund is not allowed

refund completely is allowed.

KSHER_INVALID_REFUND_BALANCE

The balance amount of this order(price fee minus amount already refunded.) is not enough for the amount to refund.

The balance amount of this order(price fee minus amount already refunded.) is not enough for the amount to refund.

Check the amount to refund.

KSHER_INVALID_REFUND_ORDER_NO

invalid refund order no.

the refund order no. passed already used.

check if the refund order no. passed in, use a new one.

KSHER_INVALID_REFUND_FEE_OR_TYPE

Refund currency or amount invalid

Refund currency or amount invalid

Check the currcency or amount to refund.

KSHER_PARAM_OVERLENGTH

Some parameters are too long.

Some paramters are too long

Check the parameters.

KSHER_INVALID_PARAM

Missing parameter(s)

Some parameter(s) invalid

Check parameter(s) is correct

KSHER_DUPLICATED_ORDERNO

The merchant order no already used.

The merchant order no already used.

Use a new order no to make the order again.

KSHER_EXCEED_AMOUNT_LIMIT

the amount to pay exceeds the amount limit configured

the amount to pay exceeds the amount limit configured

make sure if the amount to pay exceeds the limit.

KSHER_FEETYPE_NOT_MATCH

fee type does not match

pricing fee type does not match the registered fee type

merchant needs to modify the program, if merchant is sure that the fee type passed in is correct, contact the vendor.

KSHER_DUPLICATED_ORDERNO

The merchant order no already used.

The merchant order no already used.

Use a new order no to make the order again.

KSHER_DUPLICATED_REFUND_ORDERNO

invalid refund order no

the refund order no. passed already used.

check if the refund order no. passed in, use a new one.

KSHER_AMOUNT_IS_TOO_SMALL

The amount is too small.

The amount is too small

Pass in a larger amount

KSHER_CHANNEL_RESPONSE_ERROR

Error occurred during query operation

Error occurred during query operation

Make an order query again.

LACK_PARAMS

parameter absent

mandatory parameter(s) was absent

please check if the parameters were sufficient

MCHID_NOT_EXIST

MCHID not exist

MCHID was absent in parameters.

please check if the MCHID is correct.

NOAUTH

the merchant has no access to this interface.

the merchant has not yet got the access to this interface.

contact the vendor(Ksher)

NOT_UTF8

coding format error

required coding format was not used.

please use UTF-8 coding

NOTENOUGH

Not enough unsettled fund for refund

There is not enough unsettled fund for refund

This error code means refund request failed due to not enough unsettled fund for refund.Merchants need to contact Ksher to authorise credit for this kind of situation. If unsettled fund is enough ,please call the refund API once there is enough unsettled fund, or retry it continuously.

ORDERPAID

order closed already

the order closed already.

the order no. is already closed, please launch a new order.

ORDERNOTEXISTR

the order no. does not exist

the order does not exist in the system

merchant need to check if the order no. is correct.

OUT_TRADE_NO_USED

repetitive out_trade_no

the same order cannot be submitted for multi times.

please verify whether the out_trade_no. was submitted repetitively

PARAM_ERROR

parameters error

parameters requested are not correct

check the application according to the information returned, contact the vendor if needed.

POST_DATA_EMPTY

post parameters are empty

post parameters should not be empty

please check the paremeters posted in the http request.

REQUIRE_POST_METHOD

please use POST method

the method used to pass the parameters was not POST.

please check if the parameters was passed by POST method

SYSTEMERROR

system error

system timeout

call the order query API immediately to check order status, and decide next step according to the status of the order

SIGNERROR

signature error

the signature parameter is not correct

please check if the signature parameter and method meet the requirements of signature algorithm

TRADE_STATE_ERROR

order state error

there will be latency for the result for refund application, please query later(20 minutes for balance payment, 3 workdays for card payment)

USER_ACCOUNT_ABNORMALE

refund failed

user account is exceptional or unregistered.

this status stands for the failure of the refund operation, merchant can handle the refund by himself.

XML_FORMAT_ERROR

XML format error

XML format error

please check whether the format of XML parameters is correct.

SHOP_ID_ERROR

Invalid merchant information

Invalid merchant information

Please check if the APPID is correct.

CANCEL_ERROR

The cancellation failed

The cancellation failed

Order cannot cancel because of wallet not support or already paid

ORDER_NOT_EXIST

This order does not exist.

Not found this order

Check mch order no is correct or not

USER_NOT_EXIST

This user does not exist.

Not found this order

Check mch order no is correct or not

ORDER_NOT_PAY

This order has not been paid.

This order has not been paid.

Order still not paid

ORDER_ALREADY_REFUND

This order has been refunded.

This order has been refunded.

order has been refunded.

REFUND_FAILED

Refund failed.

Refund failed.

check value is correct

EXPIIRE_ORDER

The order has timed out

The order has timed out

expired time set in order is timeout

ORDER_ERROT

Order number must be unique

Order number must be unique

Check order should be not duplicate or create before

SHOP_NOT_EXIST

This shop does not exist

This shop does not exist

Please check if the APPID is correct.

PRICE_NOT_EXIST

Invalid price

Invalid price

Check amount should be not 0 or create this order before

MCH_ORDER_ERROR

Duplicate order number

Duplicate order number

Check order should be not duplicate or create before

RADIS_DOES_NOT_EXIST

Redis does not exist

Check url is correct

QUERY_ORDER_ERROR

Search for failed not completed transaction

Search for failed not completed transaction

check your value is correct

ORDER_PAYMENT_ERROR

Your payment failed

Your payment failed

Retry to paid again

SMS_CODE_ERROR

Failed to receive OTP code

Failed to receive OTP code

check you mobile phone is correct

CHANNEL_LIST_ERROR

You have not apply for any ewallets nor credit card payment services

You have not apply for any ewallets nor credit card payment services

check your channel value is correct or support

MEMBER_ID_ERROR

member_id cannot be number only

member_id cannot be number only

Please check your member_id not use Real number like 1,1200,00001, but can use string with number like ABC1234.

SAVE_CARD_ERROR

Failed to save card

Failed to save card

Check Bank card channel can support save card function

MEMBER_CARD_ERROR

This card cannot be used

This card cannot be used

This card is not available, please change card to paid

EMPTY_CARD_NO

Card information is incorrect

Card information is incorrect

Check your card input information

DELETE_MEMBER_CARD_ERROR

Failed to delete card

Failed to delete card

Refresh page and try to delete again

MEMBER_CARD_NOT_EXIST

This card does not exists

This card does not exists

check your member_id is correct

MEMBER_ID_LENGTH_OUT_OF_LIMIT

member_id cannot be more than 32 characters

member_id cannot be more than 32 characters

Please check your member_id not use Real number like 1,1200,00001, but can use string with number like ABC1234.

and member_id cannot be more than 32 characters

ORDER_ALREADY_CANCEL

The order has been canceled

The order has been canceled

This order already cancel, Please try to create the new order.

ORDER_ALREADY_CANCEL_OPERATION_CANNOT_BE_PERFORMED

The order has been canceled, this action cannot proceed

The order has been canceled, this action cannot proceed

This order already cancel, Please try to create the new order.

ORDER_ALREADY_PAY_OPERATION_CANNOT_BE_PERFORMED

This order has already been paid, this action cannot proceed

This order has already been paid, this action cannot proceed

This order already paid, Please try to create the new order.

ORDER_ALREADY_PAYMENT_SUCCESS

Order has been completed

Order has been completed

This order already paid, Please try to create the new order.

INSTAL_FEE_PAYER_ERROR

Failed to apply setting of interest-bearing

Failed to apply setting of interest-bearing

check at instal_fee_payer_merchant_channel_list or instal_fee_payer is correct

TRUEMONEY_OPT_CODE_ERROR

Wrong OTP code

Wrong OTP code

check OTP is correct

MANY_OPEN

Someone is paying this bill. DO NOT pay twice.

Someone is paying this bill. DO NOT pay twice.

check on exclusive is turn on or not. if have another person open payment page

LANG_REPEAT_SUBMIT

Repetitive submission

Repetitive submission

order already create before, create the new one.