API Reference

🏦 Debit Payment API - Integration Guide

This document outlines the structure and usage of the Debit Payment API for processing Thai QR debit payments.


βœ… API Overview

This API is used by merchants to initiate Thai debit payments using QR-based payment methods. The system will return a redirect URL for the user to complete the payment.


πŸ”’ Endpoint

POST /transaction/s2s
Content-Type: application/json


πŸ“₯ Request Payload

FieldTypeRequiredDescription
merchantidstringYesUnique Merchant ID issued by the gateway
passwordstringYesAPI password or secret key
payment_method.typestringYesPayment type, use "THAI_DEBIT"
trackidstringYesUnique transaction reference from the merchant
bill_currencycodestringYesCurrency code, e.g., "THB"
bill_amountstringYesAmount to be billed Min 100
bill_countrystringYesCountry code (ISO Alpha-2), e.g., "MU"
bill_customeripstringYesIP address of the customer
bill_emailstringYesCustomer email address
returnUrlstringYesURL to redirect customer after payment
serverUrlstringYesURL to receive payment result as webhook
payer_account_nostringYesCustomer’s debit account number
payer_account_namestringYesName associated with the payer's account
payer_bank_codestringYesBank code of the payer

πŸ“¦ Sample Request

{
  "merchantid": "TEST001",
  "password": "*",
  "payment_method": {
    "type": "THAI_DEBIT"
  },
  "trackid": "10012024",
  "bill_currencycode": "THB",
  "bill_amount": 1,
  "bill_country": "MU",
  "bill_customerip": "102.119.15.157",
  "bill_email": "[email protected]",
  "returnUrl": "https://webhook.site/7590c003-5bec-441e-b1d5-993d87bb35b6",
  "serverUrl": "https://webhook.site/8d5db35a-ef94-4d7f-8c31-cc996c13b833",
  "payer_account_no": "123456789012",
  "payer_account_name": "Vivek N",
  "payer_bank_code": "014"
}

πŸ“€ Response Payload

FieldTypeDescription
typestringStatus of request (valid or error)
resultstringResult of the transaction initialization
responsecodestringNumeric response code (9 means success)
trackidstringSame track ID provided in request
merchantidstringEcho of the merchant ID
redirectUrlstringURL to redirect the customer to complete payment
tokenstringTransaction token
error_code_tagstringError code (if any)
error_textstringError description (if any)
transactionidstringUnique ID generated by payment gateway

πŸ“¦ Sample Success Response

{
  "type": "valid",
  "result": "Processing",
  "responsecode": "9",
  "trackid": "123455",
  "merchantid": "TEST001",
  "redirectUrl": "https://api.key2payment.com/transaction/Redirect?ID=8913bfff-33be-4b87-b920-23a78d5ec8d2",
  "token": "1d85ca154e754b4596128b00a5b21d1c",
  "error_code_tag": null,
  "error_text": null,
  "transactionid": "1001547"
}

πŸ” Webhook Notification (serverUrl)

After the transaction is processed, the system will POST a JSON payload to the provided serverUrl.

Make sure your server handles this notification to update the order/payment status.


🚦Response Code Meaning

Response CodeMeaning
9Processing
0Success
6Failed
Other valuesAs defined in error messages


πŸ§ͺ Testing Details

To simulate real-world success/failure flows in a sandbox/test environment:

ConditionSimulated Outcome
bill_amount ≀ 10000 THBβœ… Success β€” transaction completes normally
bill_amount > 10000 THB❌ Failure β€” transaction will be rejected

Use amounts like 1000, 5000, or 9999.99 to simulate successful transactions.

Use amounts like 10000.01, 15000, etc., to trigger failure responses.