Table of Contents
ToggleBody
| Field | Type | Required | Description |
| order_id | string | TRUE | Your unique ID for the order. |
| currency_code | string | FALSE | USD (default), EUR |
| customer_ip | string | TRUE | IP address of the customer. |
| customer_lastname | string | TRUE | Customer’s last name. |
| customer_firstname | string | TRUE | Customer’s first name. |
| customer_email | string | TRUE | Customer’s email address. |
| customer_phone | string | TRUE | Customer’s phone number. |
| amount | float | TRUE | Payment amount. Max 2 decimal digits. |
| ipn_format | string | FALSE | Format for IPN body: form (default), json. |
| ipn_url | string | TRUE | URL for Instant Payment Notification (IPN). |
| return_url | string | TRUE | URL to redirect the customer after successful payment. |
| cancel_url | string | TRUE | URL to redirect the customer if payment fails or is canceled. |
| description | string | TRUE | Description of the transaction. |
Body raw (json)
{
"amount": 3.2,
"cancel_url": "https://localhost/checkout/failure",
"customer_email": "demo@test.com",
"customer_firstname": "abc",
"customer_ip": "171.251.156.58",
"customer_lastname": "xyz",
"customer_phone": "+84123456789",
"ipn_format": "json",
"ipn_url": "https://localhost/handleIpn",
"description": "Order 47",
"order_id": "47",
"return_url": "https://localhost/checkout/success"
}Token
| Ord | Step |
| 1 | Sort the payload keys alphabetically. |
| 2 | Convert payload to JSON. |
| 3 | Concatenate JSON payload with your merchant secret. |
| 4 | Compute MD5 hash of the concatenated string. |
| 5 | Construct the token as: token = {merchant_key} + ‘.’ + {hash} |
PHP example
ksort($payload);
$json = json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$hash = md5($json . $merchantSecret);
$token = $merchantKey . ‘.’ . $hash;
Tesing card
Success:
Card number: 4242424242424242
Expiry date: 12/27
CVV: 123
Redirect:
Card number: 4141414141414141
Expiry date: 12/27
CVV: 123
Failed:
Card number: 4000000000001018
Expiry date: 12/27
CVV: 123
Curl example
curl -X POST "https://api.ttrpay.net/v2/payment-links" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer d3JWyGxoVVPm0Q6k.3ed2456408f30d19fd6d1b58a48041a4" \
-d '{
"amount": 3.2,
"cancel_url": "https://localhost/checkout/failure",
"customer_email": "demo@test.com",
"customer_firstname": "abc",
"customer_ip": "171.251.156.58",
"customer_lastname": "xyz",
"customer_phone": "+84123456789",
"description": "Order 47",
"ipn_url": "https://localhost/handleIpn",
"order_id": "47",
"return_url": "https://localhost/checkout/success"
}'Sample response
Result success:
Success request a payment link
Success request a payment link
{
"status": true,
"result": {
"code": "00",
"message": "Create payment link successfully.",
"payment_link": "https://pay.ttrpay.net/pay/DxT0a1UNzfj4KlTrpH3tkGQ98paX7y65AGFEDCHEBF"
}
} Result failed:
Signature mismatch
Signature mismatch
{
"status": false,
"result": {
"code": "E012",
"message": "Signature miss match."
}
} IPN request
IPN POST body (ipn_format=json)
{
"cs_ref_code": "202512-176559703092",
"status": "1",
"merchant_ref_code": "48",
"transaction_id": "TD20251213113711188339",
"currency": "USD",
"amount": "3.20",
"true_amount": "3.20",
"datetime": "2025-12-13 03:37:11"
}