Package: ksherpay
Payment_sdk_pythonKsher 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 connectionhttp://api.ksher.net.This is python sdk for integrating your python application with Ksher Payment Gateway. Please refers to our official api documenthereRequirementPython 3.7other python3 version should also work, but python package version might cause some conflict and minor change might need to be done.Ksher Payment API AccountRequesting sandbox account please contactsupport@ksher.comAPI_URLAlong with a sandbox account, you will be receiving a API_URL in this format: s[UNIQUE_NAME].vip.ksher.netAPI_TOKENLog in into API_URL using given sandbox account and get the token. seeHow to get API TokenThe Payment SDK for accessing *.vip.ksher.netHow to Installthere are two option two install this package;Pip Install This packageClone this repositoryOption 1: Pip Install This packagepip install ksherpayOption 2: Clone this repositoryStep1: clone this repositorygitclonehttps://github.com/ksher-solutions/payment_sdk_pythonStep2: cd into cloned source code and pip install all the requriements and the package itselfcdpayment_sdk_python
pipinstall-rrequirements.txt
pipinstall.or if you want to pip install from local please usepip install ./payment_sdk_python --userHow to Useyou need to first init the payment object and that you can use it to;Init Payment ObjectCreate New OrderQuery Order StatusRefund the OrderInit Payment Objectksherpay 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 itherecurrently this python sdk support only two api; 'redirect api' and 'c scan b api'Redirect APIthe default api is redirect api you can just init it like thisfromksherpayimportPaymentAPI_URL='https://sandboxbkk.vip.ksher.net'API_TOKEN=testtoken1234payment_handle=Payment(base_url=API_URL,token=API_TOKEN)C_Scan_B APIto use 'C_Scan_B API', you need to specified it when init the objectas shown in the code, please use ksherpay package's provided value to specified the apiType valuefromksherpayimportPayment,API_TYPEAPI_URL='https://sandboxbkk.vip.ksher.net'API_TOKEN=testtoken1234payment_handle=Payment(base_url=API_URL,apiType=API_TYPE.CSCANB,token=API_TOKEN)B_Scan_C APIto use 'B_Scan_C API', you need to specified it when init the objectas shown in the code, please use ksherpay package's provided value to specified the apiType valuefromksherpayimportPayment,API_TYPEAPI_URL='https://sandboxbkk.vip.ksher.net'API_TOKEN=testtoken1234payment_handle=Payment(base_url=API_URL,apiType=API_TYPE.BSCANC,token=API_TOKEN)Finance APIto use 'Finance API', you need to specified it when init the objectas shown in the code, please use ksherpay package's provided value to specified the apiType valuefromksherpayimportPayment,API_TYPEAPI_URL='https://sandboxbkk.vip.ksher.net'API_TOKEN=testtoken1234payment_handle=Payment(base_url=API_URL,apiType=API_TYPE.FINANCE,token=API_TOKEN)data={"mid":"35618","signature":"string","timestamp":"string"}resp=payment_handle.settlements.channels(params=data)Disable Sign VerificationIn early phase of implementation. You might want to disable Sign Verification to debug on other thing without the need to worry if the bug is coming for signature.*** for Security purpose, don't forget to enable this sign verification back first before going on Production environment.to disable sign you simply do this;fromksherpayimportPaymentAPI_URL='https://sandboxbkk.vip.ksher.net'API_TOKEN=testtoken1234payment_handle=Payment(base_url=API_URL,token=API_TOKEN,verify=False)Create New Ordermerchant_order_id need to be unique or else the request will end with errorto create new order, each apiType has slightly different required parametersRedirect APIdata={"amount":100,"merchant_order_id":"OrderId000001","channel":"linepay,airpay,wechat,bbl_promptpay,truemoney,ktbcard","note":"string","redirect_url":"http://www.baidu.com","redirect_url_fail":"http://www.baidu.com"}resp=payment_handle.order.create(data)print(resp.status_code)# this should return 200C_Scan_B APIfor 'C_Scan_B API', redirect_url is not needed and you can specified one channel at a time.data={"amount":100,"merchant_order_id":"OrderId000001","channel":"truemoney","note":"string",}resp=payment_handle.order.create(data)print(resp.status_code)# this should return 200Query order statusmerchant_order_id='OrderId000001'resp=payment_handle.order.query(merchant_order_id)print(resp.status_code)# this should return 200RefundRefund_id need to be unique or else the request will end with errormerchant_order_id='OrderId000001'refund_id="Refund_"+merchant_order_iddata={'refund_amount':100,'refund_order_id':refund_id}resp=payment_handle.order.refund(merchant_order_id,params=data)print(resp.status_code)# this should return 200