Gateway Pay

API method

URL

https://gateway.ksher.com/api/gateway_pay

URL (to be used if your client wants to make a payment in Mainland China)

https://gateway.ksher.cn/api/gateway_pay

Method

POST

Parameter organization format

application/x-www-form-urlencoded

Order Applying 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.

channel_list

String(128)

YES

alipay,wechat,linepay,airpay,promptpay,truemoney,card,ktccard,ktc_instal

Payment Merchant list support. Value range:

alipay: Alipay Wallet.

alipayplus: Alipay+ Wallet. Country support only Japan.

wechat: Wechat Wallet.

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

airpay: Shopeepay Wallet. Country support only Thailand.

truemoney: TrueMoney Wallet. Country support only Thailand.

atome: Atome Buy now pay later. minimum of 20 Baht. Country support only Thailand.

promptpay: PromptPay QR code (Thailand standard bank transfer QR code). Country support only Thailand.

scb_easy: SCB EASY Mobile App. minimum of 20 Baht. (only support on mobile). Country support only Thailand.

bbl_deeplink: Bualuang mBanking Mobile App. minimum of 20 Baht. (only support on mobile). Country support only Thailand.

baybank_deeplink: KMA Krungsri Mobile App. minimum of 20 Baht. (only support on mobile). Country support only Thailand.

kplus: KPLUS. minimum of 20 Baht. (only support on mobile). Country support only Thailand.

card: Card Gateway. support Visa Card, Master Card, Union Pay Card, TPN Card. Country support only Thailand.

ktc_instal: KTC Installment. support only KTC Card. minimum of 3,000 Baht. Country support only Thailand.

kbank_instal: KBANK Installment. support only KBANK Card. minimum of 3,000 Baht. Country support only Thailand.

kcc_instal: Krungsri Installment. support only Krungsri Card. minimum of 3,000 Baht.(5,000 Baht. for 10 months or more than). Country support only Thailand.

kfc_instal: First Choice Installment. support only Krungsri First Choice Card. minimum of 3,000 Baht. Country support only Thailand.

scb_qrcard: QR Card. Country support only Thailand.

If multiple e-payment method required,a string made up by required e-wallets ,which seperated by "," without space, for example:"promptpay,linepay,airpay,truemoney,atome,card,ktc_instal,kbank_instal,kcc_instal,kfc_instal,scb_easy,bbl_deeplink,baybank_deeplink,kplus,alipay,wechat,scb_qrcard". will open all of channel your merchant you have. It will send Ksher checkout page to select your wallet want to paid.

If you send only one channel, it will be redirected to each wallet you send.

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

To verify the accuracy of the request message, please refer to the signature creation method in the section Signature Creation.

mch_code

String(256)

YES

123456acb

Order No. It will be display to customer.

mch_redirect_url

String(256)

YES

http://www.yourweb.com/gateway_pay/success/

After the payment is succeed, the web page is redirected to this URL. If merchant leaves this field blank, the web page will stay on payment page after payment succeed.

mch_redirect_url_fail

String(256)

YES

http://www.yourweb.com/gateway_pay/fail/

After the payment is failed, the web page is redirected to this URL. If merchant leaves this field blank, the web page will stay on payment page after payment failed.

mch_notify_url

String(256)

NO

http://www.yourweb.com/gateway_pay/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.

mch_order_no

String(32)

YES

123456acb

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

don’t use name like 01,02,100,200

product_name

String(512)

YES

Demo

Name or description of your product.

Precautions when using "product_name"

please use General English characters. Avoid using special characters such as +&/$%

Because in some wallets, product_name will be shown to the product that the customer purchases. and wallet does not support special characters.

refer_url

String(256)

YES

The URL of the merchant website homepage. If the merchant doesn’t have a website, the merchant app download address can be used for this field.

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: Thai Baht use for Thailand.

MYR: Malaysia

JPY: Japan

AED: United Arab Emirates dirham use for UAE.

device

String( )

NO

H5

Value Range:PC, H5;

If you leave this blank, Ksher will determine user device automatically and will return an adaptive page.

member_id

String(32)

NO

ABC12345

User ID, support ktb storage card function when user ID is transmitted.

Can’t use Real number like 1,1200,00001, but can use string with number like ABC1234.

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

20190622131804

Time of create the request.the format is '%Y%m%d%H%M%S%SS'

color

String(32)

NO

#FF5C72

The color code of banner on payment page, which can be DIY by merchant.

payment_color

String

NO

#FF5C72

The color code of payment button, which can be DIY by merchant.

ksher_explain

String(256)

NO

Copyright information on payment page, which can be DIY by merchant.

hide_explain

Integer

NO

0

Value range:0,1;

1: to display an expiration timer.

0: to hide expire time information.

Default is "1".

expire_time

Integer

NO

30

How long the payment is valid to pay, the unit is minute. If merchant leave this blank, there will be no time limit.

hide_exp_time

Integer

NO

1

Value range:0,1;

1: to display an expiration timer. 0: to hide expire time information.

Default is "1".

logo

String

NO

https://file.ksher.cn/ksherbd/h5/2020325/201654.png

The url of logo picture on payment page, which can be DIY by merchant.

lang

String

NO

en

The display language. Value range:

en for English,

cn for Chinese,

th for Thai.

Default is en.

shop_name

String

NO

The Remark or description

attach

String

NO

The Remark or description

If you want data to display merchant platform at table data "consumer remark" and "merchants remark" Please send data by using this format

"attach": "{"consumer_remark": "remark from customer", "merchants_remark": "remark from merchant"}"

instal_fee_payer

String

NO

Parameters Related to Installment Payments.

Determines who is responsible for the installment payment fee. Value range:1, 2.

1 : The customer is responsible for the installment payment fee.

2 : The merchant is responsible for the installment payment fee.

Default value 1

If the responsibility for interest charges depends on the payment channel, use the “instal_fee_payer_merchant_channel_list” parameter instead.

exclusive

Integer

NO

Limit to open link only one person. Value Range:1, 2

1: Limit people who click on the link to only one person.

2: not limit.

The default value is 1

instal_fee_payer_merchant_channel_list

String

NO

"ktc_instal,kbank_instal"

Parameters Related to Installment Payments.

Specifies the payment channels for which the merchant will bear the interest rate. Multiple channels can be specified.

Example: "instal_fee_payer_merchant_channel_list":"kbank_instal"

This means that for installment payments made via KBANK cards, the merchant will cover the interest charges, while for other channels, the customer will bear the interest as usual.

channel_instal_times_list

String

NO

"{\"ktc_instal\": [3,4,5], \"kbank_instal\": [4,5,6,7,8]}"

Parameters Related to Installment Payments.

Defines the available installment periods for different payment channels. Multiple channels can be specified.

Example:"channel_instal_times_list": "{\"ktc_instal\": [3,4,5], \"kbank_instal\": [4,5,6,7,8]}"

This means:

For installment payments via KTC cards, available installment periods are 3, 4, or 5 months.

For installment payments via KBANK cards, available installment periods are 4, 5, 6, 7, or 8 months.

Please send this value in JSON Objects convert to string format, don’t send in JSON Objects, because it will error signature.

Example 1. Request Example
{
    "appid": "mch28321",
    "channel_list": "wechat,alipay,linepay,promptpay,truemoney,card",
    "device": "",
    "fee_type": "THB",
    "mch_code": "233114471",
    "mch_order_no": "233114471",
    "mch_redirect_url": "https://www.yourweb.com/",
    "mch_redirect_url_fail": "https://www.yourweb.com/fail",
    "mch_notify_url": "https://www.yourweb.com/notify",
    "nonce_str": "8d22a1335bc893fe6e90a236a93ca3c5",
    "product_name": "sdd",
    "refer_url": "https://www.yourweb.com/",
    "sign": "5f01d9fe632bcf7d07deedcd3b419d37c653c571e7ea8759ad8cd4e44594b73776ab23720a7238e1a4442fb13e63d7a4b0e80695eedf50bd65d7c8e4a80c6d21",
    "time_stamp": "2020041414150505S",
    "total_fee": 13000
}
Example 2. Request Example by use cURL
curl --location 'https://gateway.ksher.com/api/gateway_pay' \
--data-urlencode 'appid=mch35005' \
--data-urlencode 'channel_list=promptpay,linepay,airpay,truemoney,atome,card,ktc_instal,kbank_instal,kcc_instal,kfc_instal,scb_easy,bbl_deeplink,baybank_deeplink,kplus,alipay,wechat,card,ktc_instal,kbank_instal,kcc_instal,kfc_instal' \
--data-urlencode 'fee_type=THB' \
--data-urlencode 'lang=en' \
--data-urlencode 'mch_code=2023-02-22-17-11-00' \
--data-urlencode 'mch_notify_url=https://www.yourweb.com/api/gateway_pay/notify_url/' \
--data-urlencode 'mch_order_no=2023-02-22-17-11-00' \
--data-urlencode 'mch_redirect_url=https://www.yourweb.com/api/gateway_pay/success' \
--data-urlencode 'mch_redirect_url_fail=https://www.yourweb.com/api/gateway_pay/fail' \
--data-urlencode 'nonce_str=a2de1d78127dd837e648ef0c28773fcb' \
--data-urlencode 'product_name=2023-02-20-17-27-00' \
--data-urlencode 'refer_url=https://www.yourweb.com' \
--data-urlencode 'sign=5a665ecc4e1a94f01de579a9dd1c4850984066a7d4b479bb3bc3d8872c5ac871a3e868efdf9da0b8baaac1cd3f3ce789f7e6e677fb8ff25ea1b872c387980161db485ed84e28c9ae064dacae877d8855deb4bb3332499e9a5f73675377e0fa7baf66f8129299c4e505439501e2088abfed1558a9a2bff39a582dcf36b364a049' \
--data-urlencode 'time_stamp=2023030317445454S' \
--data-urlencode 'total_fee=100'

Order Applying SUCCESS Response Parameters

Parameter Type Required Example Description

code

Integer

YES

0

Value range:

0: The request data was received successfully but it does not mean the process is succeeded.

Not 0: The API request failed. Please check response’s message first. You can try to send a new request with the same parameters again.

lang

String

NO

en

The display language. Value range:

en for English cn for Chinese th for Thai.

Default is en.

message

String(256)

YES

ok

Detailed description of result. If fail it will be show in detail error in here.

sign

String(256)

YES

b000e9b6ec3fbda482d96a3d7c75c6956a5864336c3098462525e7229e8e046e490939a3e8b320a6c68eb63795a25b79d8c74f042f0972039bb5fe9b861cefb4

To verify the accuracy of this response, please refer to the method outlined in the section Verify Signature.

msg

String(256)

YES

SUCCESS

Hint message of result

data

JSON

YES

{"pay_content": "https://gateway.ksher.com/page?order_uuid=49ba030e7e1711ea97e652540075451d"}

Gateway payment data, refered to data parameters

Gateway payment data parameters

Parameter Type Required Example Description

pay_content

String(256)

YES

https://gateway.ksher.com/page?order_uuid=49ba030e7e1711ea97e652540075451d

Ksher Payment Page URL. You can use this to redirect the buyer to payment page.

Example 3. SUCCESS Response Example
{
    "code": 0,
    "msg": "SUCCESS",
    "data": {
        "pay_content": "https://gateway.ksher.com/ua?order_uuid=f624f098b8d111edacef525400962f26&lang=en"
    },
    "sign": "7b2159b7f2ec4bff350322b5cdef55bfe4265c03023390ccf8e98292c559a29d79c34ad2eaceaeb5b7d5c6ab9e13afb8c85b0bf267046ea0c5b3d24bf53c09d6",
    "message": "SUCCESS"
}

Order Applying FAIL Response Parameters

Parameter Type Required Example Description

code

Integer

YES

-4

Value Range:

0: The request data was received successfully but it does not mean the process is succeeded.

Not 0: The API request failed. Please check response’s message first. You can try to send a new request with the same parameters again.

-1: {'cn': '商户信息错误', 'th': 'ข้อมูลร้านค้าผิดพลาด', 'en': 'Invalid merchant information'}

-2: {'cn': '验证商户签名失败', 'th': 'การตรวจสอบลายเซ็นของร้านค้าล้มเหลว', 'en': 'The verification of merchant signature failed'}

-101: {'cn': '验证商户签名失败', 'th': 'การตรวจสอบลายเซ็นของร้านค้าล้มเหลว', 'en': 'The verification of merchant signature failed'}

-102: {'cn': 'member_id 不能是纯数字', 'th': 'member_id ไม่สามารถเป็นตัวเลขอย่างเดียวได้', 'en': 'member_id cannot be number only'}

-103: {'cn': 'member_id 长度不能超过32位', 'th': 'member_id ต้องไม่เกิน 32 ตัว', 'en': 'member_id cannot be more than 32 characters'}

-1000: {'cn': '参数校验失败: mch_order_no', 'th': 'ข้อมูลไม่ถูกต้อง: mch_order_no', 'en': 'Paramter invalid: mch_order_no'}

-1001: {'cn': '您没有开通任何钱包或银行卡', 'th': 'คุณไม่ได้เปิดใช้บริการกระเป๋าเงินหรือบัตรเครดิต', 'en': 'You have not apply for any ewallets nor credit card payment services'}

-4: {'cn': '订单号必须唯一', 'th': 'หมายเลขรายการซื้อขายต้องไม่ซ้ำ', 'en': 'Order number must be unique'}

-41: {'cn': '订单已被取消', 'th': 'ออเดอร์ดังกล่าวถูกยกเลิก', 'en': 'The order has been canceled'}

-201: {'cn': '创建支付订单失败', 'th': 'การสร้างรายการชำระเงินล้มเหลว', 'en': 'Transaction creation failed'}

1: {'cn': '订单已支付成功', 'th': 'ออเดอร์ถูกจ่ายสำเร็จแล้ว', 'en': 'Order has been completed'}

lang

String

YES

The display language. Value range:

en for English

cn for Chinese

th for Thai.

Default is en.

message

String(256)

YES

Detailed description of result

msg

String(256)

YES

Hint message of result

Example 4. Failed Response Example
{
    "lang": "",
    "code": -4,
    "msg": "订单号不唯一",
    "message": "订单号不唯一"
}