SDK

To make the integration easier, there are several SDK packages can be used by developer.

SDK Support

You can find all the SDK packages here following:

NodeJs

ksher

  1. The SDK package takes care of the signature calculation and all the details of RESTFUL API communication.

  2. You still need to get merchant private KEY to use the SDK package for each programming language.

How to use

  • include SDK to your code

  • setting your private key and your parameters

Example request to create payment on website with Python SDK

from ksher.ksher_pay_sdk import KsherPay

appid = "mch35000"
privatekey = "/Users/yourpath/repo/ksher_sdk_python/mch_privkey.pem"
pubkey = "/Users/yourpath/repo/ksher_sdk_python/ksher_pubkey.pem"

payment_handle = KsherPay(appid, privatekey, pubkey)
data = {
    "total_fee": "100",
    "fee_type": "THB",
    "mch_code": "",
    "refer_url": "http://www.baidu.com",
    "mch_redirect_url":"http://www.baidu.com/api/gateway_pay/success",
    "mch_redirect_url_fail":"http://www.baidu.com/api/gateway_pay/fail",
    "mch_notify_url":"http://www.baidu.com/api/gateway_pay/notify_url/",
    "product_name":"",
    "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['mch_order_no'] = "HelloWebsite"
resp = payment_handle.gateway_pay(data)

Example request to create payment on website with NodeJs SDK

const appid = "mch35000";  // setup your appid at here
const path = "/Users/example/ksher_sdk_nodejs/Mch35000_PrivateKey.pem"; // setup your private key path at here

const KsherPay = require('@kshersolution/ksher');
const sdk = new KsherPay(appid, path)

const mch_order_no = Date.now().toString();
const gateway_payRequestData = {
  "mch_order_no": mch_order_no,
  "total_fee": "100",
  "fee_type": "THB",
  "mch_code": mch_order_no,
  "refer_url": "https://www.google.com",
  "mch_redirect_url":"https://www.google.com/api/gateway_pay/success",
  "mch_redirect_url_fail":"https://www.google.comapi/gateway_pay/fail",
  "mch_notify_url":"https://www.google.com/api/gateway_pay/notify_url/",
  "product_name": mch_order_no,
  "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",
  "lang":"en"
};
await sdk.gateway_pay(gateway_payRequestData)
  .then(response => {
    console.log("body: ",response);
  });
.catch(error => {
    console.log(error);
  });