Complete instructions for integrating with our payment processing system
This guide provides instructions for integrating with KBank's K Payment Gateway using the Create Charge API. The payment gateway supports credit card and debit card payments through a secure, PCI-DSS compliant system.
Before you can process payments, you'll need to:
The Create Charge API is used to process payment transactions through KBank's payment gateway.
Use this endpoint to create and process a payment charge.
POST https://kpaymentgateway.kasikornbank.com/api/v1/charges
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"amount": 10000,
"currency": "THB",
"description": "Order #12345",
"source": {
"type": "card",
"token": "tok_xxxxx"
},
"metadata": {
"orderId": "ORD-12345",
"customerId": "cust_12345"
}
}
KBank K Payment Gateway supports the following payment methods:
| Method | Type | Description | Status |
|---|---|---|---|
| Credit Card | card |
Visa, Mastercard credit cards | โ Active |
| Debit Card | card |
Visa, Mastercard debit cards | โ Active |
Use the KBank Payment UI to collect card information securely. The UI handles tokenization and 3D Secure authentication.
// Load KBank Payment Gateway script
<script
src="https://dev-kpaymentgateway.kasikornbank.com/ui/v2/kpayment.min.js"
data-apikey="YOUR_API_KEY"
data-amount="10000"
data-currency="THB"
data-payment-methods="card"
data-name="Your Shop Name"
data-mid="YOUR_MERCHANT_ID"
data-customer-id="CUSTOMER_ID"
></script>
After the payment UI collects the card token, create a charge using the Create Charge API:
POST https://kpaymentgateway.kasikornbank.com/api/v1/charges
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"amount": 10000,
"currency": "THB",
"description": "Order #12345",
"source": {
"type": "card",
"token": "tok_xxxxx"
},
"metadata": {
"orderId": "ORD-12345",
"customerId": "cust_12345"
}
}
The API will return a charge object with the payment status:
{
"id": "chg_xxxxx",
"amount": 10000,
"currency": "THB",
"status": "succeeded",
"description": "Order #12345",
"created": 1234567890,
"metadata": {
"orderId": "ORD-12345",
"customerId": "cust_12345"
}
}
If 3D Secure authentication is required, the response will include a redirect URL:
{
"id": "chg_xxxxx",
"status": "pending",
"redirect": {
"url": "https://3ds.kasikornbank.com/authenticate/xxxxx",
"returnUrl": "https://yoursite.com/payment/return"
}
}
Redirect the customer to the authentication URL, then handle the return callback.
KBank Create Charge API returns the following status values:
| Status | Description |
|---|---|
pending |
Charge is pending (e.g., waiting for 3D Secure authentication) |
succeeded |
Charge completed successfully |
failed |
Charge failed or was declined |
Always handle payment errors gracefully:
{
"error": {
"code": "card_declined",
"message": "Your card was declined.",
"type": "card_error",
"decline_code": "generic_decline"
}
}
Use KBank's sandbox environment to test your integration:
https://dev-kpaymentgateway.kasikornbank.com/ui/v2/kpayment.min.jshttps://dev-kpaymentgateway.kasikornbank.com/api/v1/chargesFor complete API documentation, including request parameters, response formats, error codes, and webhook configuration, refer to the official KBank API Portal:
The official documentation includes:
Enter your payment parameters below and launch the KBank payment UI with one click:
Need help? Check out these resources: