Ksher SDK for Python
Ksher payment SDK for Python.
📄 Documentation: API Reference
Available SDKs
Ksher SDK is available in multiple languages:
- Java: Ksher SDK (Java)
- Python: Ksher SDK (Python)
- Go: Ksher SDK (Go)
- PHP: Ksher SDK (PHP)
- .NET Core: Ksher SDK (.NET Core)
- Node.js: Ksher SDK (Node.js)
📦 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, andpubkeyare correctly set. - Replace URLs with your actual endpoint URLs.
pubkeyinside SDK, The file name isksher_pubkey.pem. This value is optional, you not need to pass with it.- Use the correct
channel_listbased on your integration.
📖 For full documentation, visit Ksher API Docs.
Metadata
Release files for ksher 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ksher-1.0.2.tar.gz | 3.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ksher-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.2 kB
Release files / ksher-1.0.2.tar.gz
| Download URL | ksher-1.0.2.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c032c453f301475dae95865048c89033598e7efe316aafaae853edb43a81429c
|
|
BLAKE2b-256 checksum How to use checksums |
e2e889cb718d3959c8d77e4489c117c3d394c0fc4c769b4731c0f1a01e6528eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / ksher-1.0.2-py3-none-any.whl
| Download URL | ksher-1.0.2-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3589764a12907db15a334cd4bfc38a9898ac51d56cbc5bd5ed397ac2daab88a1
|
|
BLAKE2b-256 checksum How to use checksums |
a6a8869bd4e5da0ae81f11f235ac76cfd145a9cace0dc1ac0bd051af565c56f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Security for ksher 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.