Ksher will shut down the API connection via .vip.ksher.net. That make new register merchant will unable to use system over .vip.ksher.net.
Merchants are currently connected, Please change the API to connection http://api.ksher.net.
This is java sdk for integrating your java application with Ksher Payment Gateway. Please refer to our official api document here
-
Java 11
- this has been tested and run on java 11.
-
Ksher Payment API Account
- Requesting sandbox account please contact support@ksher.com
-
API_URL
- Along with a sandbox accout, you will be receiving a API_URL in this format: s[UNIQUE_NAME].vip.ksher.net
-
API_TOKEN
- Log in into API_URL using given sandbox account and get the token. see (How to get API Token)[https://doc.vip.ksher.net/docs/howto/api_token]
The Payment SDK for accessing *.vip.ksher.net
please see the dependency tag that need to be add in your project's pom.xml file here
if after adding the tag and you got error saying it cannot find the package, you probably didn't config your project settings.xml to check github package. please follow this guide here on how to update settings.xml
you need to first init the payment object, then you can use it to;
- Init Payment Object
- Create New Order
- Query Order Status
- Refund the Order
ksherpay have multiple api (apiType) such as;
- redirect API is for Website and Mobile App integration.
- settlement API is for checking the settlement information.
- miniapp API is for WeChat and Alipay Mini-Program integration.
- event API is for checking the events deliveried.
- C scan B API is for C scan B(merchant present QR code) or Kiosk integration.
- B scan C API is for B scan C(customer present QR code) or POS integration.
you can read about it here
Currently, this python sdk support only two api; 'redirect api' and 'c scan b api'
String gateway_domain = "https://sandboxbkk.vip.ksher.net";
String token = "testtoken1234";
KsherPay ksherPay = new KsherPay(gateway_domain, token, KsherPay.ApiType.REDIRECT);
String gateway_domain = "https://sandboxbkk.vip.ksher.net";
String token = "testtoken1234";
KsherPay ksherPay = new KsherPay(gateway_domain, token, KsherPay.ApiType.CSCANB);
merchant_order_id need to be unique or else the request will end with error
to create new order, each apiType has slightly different required parameters
HashMap<String, String> data = new HashMap<>();
Date date = Calendar.getInstance().getTime();
DateFormat dateFormat = new SimpleDateFormat("yyyyMMddhhmmss");
String orderId = "OrderAt_" + dateFormat.format(date);
data.put("amount", "100");
data.put("redirect_url", "https://www.google.com");
data.put("redirect_url_fail", "https://www.yahoo.com");
data.put("merchant_order_id", orderId);
KsherPay ksherPay = new KsherPay(gateway_domain, token, KsherPay.ApiType.REDIRECT);
HashMap<String, String> resp = ksherPay.create(data);
System.out.println("create order's resp : " + resp);
for 'C_Scan_B API', redirect_url is not needed and you can specified one channel at a time.
HashMap<String, String> data = new HashMap<>();
Date date = Calendar.getInstance().getTime();
DateFormat dateFormat = new SimpleDateFormat("yyyyMMddhhmmss");
String orderId = "OrderAt_" + dateFormat.format(date);
data.put("amount", "100");
data.put("channel", "truemoney");
data.put("merchant_order_id", orderId);
KsherPay ksherPay = new KsherPay(gateway_domain, token, KsherPay.ApiType.CSCANB);
HashMap<String, String> resp = ksherPay.create(data);
System.out.println("create order's resp : " + resp);
resp = ksherPay.query(orderId);
Refund_id need to be unique or else the request will end with error
Sting amount = "100"; // this mean refund 1 bath
resp = ksherPay.refund(orderId,"refund_" + orderId, data.get("amount"));