Skip to main content

python implementation for Khser Payment API.

Project description

Ksher SDK for Python

Python Package Version

Ksher payment SDK for Python.

📄 Documentation: API Reference

Available SDKs

Ksher SDK is available in multiple languages:


📦 Installation

There are two ways to install this package:

Option 1: Install via Pip

pip install ksher

Option 2: Clone and Install Manually

Step 1: Clone the Repository

git clone https://github.com/ksher-api/ksher_sdk_python.git

Step 2: Navigate and Install Dependencies

cd ksher_sdk_python
pip install -r requirements.txt
pip install .

Alternatively, install locally with:

pip install ./ksher_sdk_python --user

🚀 How to Use

First, initialize the payment object to perform various payment actions:

  • Initialize Payment Object
  • Create New Order
  • Query Order Status
  • Refund an Order

🔹 Redirect API (Default)

To use the Redirect API, initialize as follows:

from ksher.ksher_pay_sdk import KsherPay

appid = "mch35000"
privatekey = "/path/to/mch_privkey.pem"
pubkey = "/path/to/ksher_pubkey.pem"

payment_handle = KsherPay(appid, privatekey, pubkey)
data = {
    "total_fee": "100",
    "fee_type": "THB",
    "mch_code": "",
    "refer_url": "http://www.example.com",
    "mch_redirect_url": "http://www.example.com/success",
    "mch_redirect_url_fail": "http://www.example.com/fail",
    "mch_notify_url": "http://www.example.com/notify",
    "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)

🔹 C_Scan_B API (QR Code Payment)

To use the C_Scan_B API, specify the API type when initializing:

from ksher.ksher_pay_sdk import KsherPay

appid = "mch35000"
privatekey = "/path/to/mch_privkey.pem"
pubkey = "/path/to/ksher_pubkey.pem"

payment_handle = KsherPay(appid, privatekey, pubkey)
data = {
    "mch_order_no": "202208101150",
    "total_fee": "100",
    "fee_type": "THB",
    "channel": "promptpay",
    "notify_url": "http://www.example.com/notify"
}
data['mch_order_no'] = "HelloKiosk"
resp = payment_handle.native_pay(data)

📌 Notes

  • Ensure that the appid, privatekey, and pubkey are correctly set.
  • Replace URLs with your actual endpoint URLs.
  • pubkey inside SDK, The file name is ksher_pubkey.pem. This value is optional, you not need to pass with it.
  • Use the correct channel_list based on your integration.

📖 For full documentation, visit Ksher API Docs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ksher-1.0.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ksher-1.0.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file ksher-1.0.1.tar.gz.

File metadata

  • Download URL: ksher-1.0.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for ksher-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f442a4d0884d1ec81816caa224a67f949470499ac98e507575ffcdf1585333d9
MD5 c6e41749c45d1fef02ef8441c2943a18
BLAKE2b-256 252a5e071e4bc80d895977f5b8500ff19c4411161aeae6ae0fc5c8f410d562d5

See more details on using hashes here.

File details

Details for the file ksher-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ksher-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for ksher-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dd41399c754d3a048a1e67a7b5ba2344d5de52a8ea484131e8bee46f8a4853e3
MD5 bd4698d742f4bd8dc092767e8990d656
BLAKE2b-256 e6a4b9102350fd10e31d296e2d43b44cd66b8449c8db2ef98084411fdd0666c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page