TUNGKAO ឯកសារ API

ភ្ជាប់ជាមួយ TUNGKAO

របៀប API តែមួយសម្រាប់គ្រប់សេវា — Base URL៖ https://api.tungkao.com

🕒 បច្ចុប្បន្នភាព API ចុងក្រោយតាមឆានែល

ប្រព័ន្ធទាំងមូលធ្វើបច្ចុប្បន្នភាពចុងក្រោយ: ម៉ោងប្រទេសថៃ (UTC+07:00) — 📘 The TrueMoney Wallet docs page is now fully translated into all 10 languages (steps, examples, case table, notes)

✅ កូដចាស់នៅដំណើរការ មិនចាំបាច់កែ · /changelog.json (ទិន្នន័យម៉ាស៊ីនអានបាន)

Paste it into the AI that maintains your site's code (ChatGPT / Claude / Gemini); it checks and changes only what is needed
🧾ពិនិត្យវិក្កយបត្រធនាគារ ម៉ោងប្រទេសថៃ (UTC+07:00)Duplicate-slip protection between keys is now configurable: this key only / group A–E / whole account — for several sites that receive into the same accountពិនិត្យវិក្កយបត្រ TrueMoney Wallet ម៉ោងប្រទេសថៃ (UTC+07:00)📘 The TrueMoney Wallet docs page is now fully translated into all 10 languages (steps, examples, case table, notes)🏦បញ្ចូលប្រាក់តាមវិក្កយបត្រ ម៉ោងប្រទេសថៃ (UTC+07:00)បើកការបញ្ចូលប្រាក់តាមវិក្កយបត្រ + webhook₿ការទូទាត់គ្រីបតូ ម៉ោងប្រទេសថៃ (UTC+07:00)បន្ថែមបណ្ដាញ Ethereum, Polygon, Arbitrum, Base, Optimism, Avalanche និង USDCការជូនដំណឹងតាម Telegram ម៉ោងប្រទេសថៃ (UTC+07:00)Telegram / Discord notifications: step-by-step setup guide on the key card and in the docs (Telegram connect link, add a Discord channel webhook)ការជូនដំណឹងតាម Discord ម៉ោងប្រទេសថៃ (UTC+07:00)Telegram / Discord notifications: step-by-step setup guide on the key card and in the docs (Telegram connect link, add a Discord channel webhook)📧ផ្ញើអ៊ីមែល + OTP + SMTP ម៉ោងប្រទេសថៃ (UTC+07:00)បើកសេវាអ៊ីមែល៖ API + SMTP + OTPចូលតាម Google ម៉ោងប្រទេសថៃ (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.ចូលតាម LINE ម៉ោងប្រទេសថៃ (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.ចូលតាម Facebook ម៉ោងប្រទេសថៃ (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.ចូលតាម TikTok ម៉ោងប្រទេសថៃ (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.ចូលតាម Discord ម៉ោងប្រទេសថៃ (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.ចូលតាម Telegram ម៉ោងប្រទេសថៃ (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.ចូលតាម X (Twitter) ម៉ោងប្រទេសថៃ (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.ចូលតាម Microsoft ម៉ោងប្រទេសថៃ (UTC+07:00)Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their groupចូលតាម GitHub ម៉ោងប្រទេសថៃ (UTC+07:00)Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their groupចូលតាម Apple ម៉ោងប្រទេសថៃ (UTC+07:00)Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their groupចូលតាម Steam ម៉ោងប្រទេសថៃ (UTC+07:00)Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their groupចូលតាម Twitch ម៉ោងប្រទេសថៃ (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.ចូលតាម LinkedIn ម៉ោងប្រទេសថៃ (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.ចូលតាម Kakao ម៉ោងប្រទេសថៃ (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.ចូលតាម NAVER ម៉ោងប្រទេសថៃ (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.ចូលតាម Zalo ម៉ោងប្រទេសថៃ (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.ចូលតាម Spotify ម៉ោងប្រទេសថៃ (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.ចូលតាម Reddit ម៉ោងប្រទេសថៃ (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.ចូលតាម GitLab ម៉ោងប្រទេសថៃ (UTC+07:00)Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their groupចូលតាម Roblox ម៉ោងប្រទេសថៃ (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.ចូលតាម Epic Games ម៉ោងប្រទេសថៃ (UTC+07:00)Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their groupចូលតាម Yahoo ម៉ោងប្រទេសថៃ (UTC+07:00)Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their groupចូលតាម Slack ម៉ោងប្រទេសថៃ (UTC+07:00)Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their groupចូលតាម Amazon ម៉ោងប្រទេសថៃ (UTC+07:00)Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their group
🚀

ចាប់ផ្ដើមប្រើ

គ្រប់សេវាប្រើដូចគ្នា៖ បង្កើត API key នៅផតថលអាជីវករ (key មួយក្នុងមួយសេវា) ហើយផ្ញើក្នុង header Authorization គ្រប់សំណើ

របៀបដំណើរការ

  1. ចូល app.tungkao.com ដោយ Gmail ហើយបញ្ចូលក្រេឌីត (1 បាត = 100 ក្រេឌីត)
  2. API key → ជ្រើសកាតសេវា → ជ្រើសរយៈពេល key → បង្កើត → ចម្លង key (បង្ហាញតែម្ដង)
  3. ទុក key នៅម៉ាស៊ីនមេ (អថេរ TUNGKAO_KEY) កុំដាក់ក្នុងទំព័រវេប ឬកម្មវិធីទូរស័ព្ទ
  4. ចាប់ផ្ដើមដោយ key test (tk_test_…) — មិនកាត់ក្រេឌីត — រួចប្ដូរទៅ live
GET/v1/account — សាកល្បង key៖ ក្រេឌីតនៅសល់
curl -X GET https://api.tungkao.com/v1/account \
  -H "Authorization: Bearer $TUNGKAO_KEY"

ចុះហត្ថលេខាសំណើ (ពេលបើក)

import crypto from "node:crypto";
async function tungkao(method, path, body) {
  const raw = body ? JSON.stringify(body) : "";
  const ts = Math.floor(Date.now() / 1000).toString();
  const hash = crypto.createHash("sha256").update(raw).digest("hex");
  const sig = crypto.createHmac("sha256", process.env.TUNGKAO_SIGNING_SECRET).update(`${ts}.${method}.${path}.${hash}`).digest("hex");
  const r = await fetch("https://api.tungkao.com" + path, { method, body: raw || undefined, headers: {
    Authorization: `Bearer ${process.env.TUNGKAO_KEY}`, "Content-Type": "application/json",
    "X-Tungkao-Timestamp": ts, "X-Tungkao-Signature": sig } });
  return r.json();
}
console.log(await tungkao("GET", "/v1/account"));
  • គ្រប់ចម្លើយជា JSON មាន success និង request_id កំហុសមាន error.code (ឧ. KEY_EXPIRED, INSUFFICIENT_CREDITS) — មើល /errors
  • error.user_message is the text to show your own end users (“The system cannot connect to the tungkao.com API. Please contact the administrator.”). It comes with errors an end user cannot fix: HTTP 5xx, SERVICE_PAUSED, INSUFFICIENT_CREDITS and key problems, in the Accept-Language language. Keys with white-label enabled get a message without the tungkao.com name. If the API cannot be reached at all (timeout/network down), show the same text from your own code.
  • key ផុតកំណត់តាមការជ្រើស (1–24 ខែ ឬគ្មាន) ជូនដំណឹងមុន 30/7/1 ថ្ងៃតាម webhook api_key.expiring បន្តនៅផតថល — key ដដែល
  • ផ្ទៀងផ្ទាត់ domain៖ key live នីមួយៗភ្ជាប់គេហទំព័រមួយ API key → 'ផ្ទៀងផ្ទាត់ domain' → បញ្ចូល domain បង្ហោះ tungkao-verify-….html ទៅ https://domain-អ្នក/ (ឬ DNS TXT _tungkao-verify.domain) ហើយចុចផ្ទៀងផ្ទាត់ — key មិនទាន់ផ្ទៀងផ្ទាត់បាន DOMAIN_NOT_VERIFIED domain ដែលបានផ្ទៀងផ្ទាត់មិនអាចប្ដូរ ហើយគណនីផ្សេងប្រើមិនបាន
  • key សម្ងាត់លេចធ្លាយ? ចុច 'ប្ដូរ key ឥឡូវ' — មិនកំណត់ key ចាស់ឈប់ភ្លាម key ប្រើបានតែសេវារបស់វា (មិនដូច្នោះ WRONG_PRODUCT)
  • កម្រិតខ្ពស់ (ជម្រើស)៖ បើក 'ចុះហត្ថលេខាសំណើ' លើ key ដើម្បីទទួល tksign_… បន្ទាប់មកគ្រប់សំណើត្រូវការ X-Tungkao-Timestamp និង X-Tungkao-Signature = HMAC-SHA256(សម្ងាត់, ts.METHOD.path.sha256(body)) — key លេចធ្លាយតែមួយគ្មានប្រយោជន៍
  • 🧪 Test mode (tk_test_… keys) is free and limited to 2 calls per service per day (non-GET requests only; resets at midnight Bangkok time). Beyond that you get HTTP 429 RATE_LIMITED with a message — use a live key for unlimited calls.
  • ផ្ញើ Accept-Language (th, en, lo, my, zh-CN, ko, ja, vi, km, id) ដើម្បីជ្រើសភាសាសារ
🧾

ពិនិត្យវិក្កយបត្រធនាគារ

slip_verify

ពិនិត្យថាវិក្កយបត្រពិត ចំនួនត្រូវ ផ្ទេរមកអ្នក និងមិនទាន់ប្រើ — សម្រាប់ហាងដែលអតិថិជនភ្ជាប់វិក្កយបត្រ

របៀបដំណើរការ

  1. អតិថិជនបង្ហោះវិក្កយបត្រ គេហទំព័រអានអត្ថបទ QR (ចាប់ផ្ដើម 0041…)
  2. ផ្ញើ qr_payload ចំនួនរំពឹង និងគណនីទទួលទៅ API
  3. ទទួលការបញ្ជាទិញតែពេល status = VALID
POST/v1/slip/verify
curl -X POST https://api.tungkao.com/v1/slip/verify \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"qr_payload":"0041000600000101030040220014…","expected_amount":"500.00","receivers":[{"bank":"KBANK","account_number":"1234567890"}]}'

📖 សង្ខេប៖ ប្រើ key ជាមួយគេហទំព័រច្រើន លទ្ធផលយ៉ាងដូចម្ដេច

ករណីការកំណត់ key (ទំព័រ API Keys)លទ្ធផល
គេហទំព័រ ២ (aaa.com, bbb.com) ទទួលប្រាក់ចូលគណនីតែមួយkey ទាំងពីរ៖ ក្រុម A (ឬ គណនីទាំងមូល)វិក្កយបត្រដែលឆ្លងនៅ aaa.com នឹងទទួល DUPLICATE នៅ bbb.com — ប្រើបានតែគេហទំព័រមួយ ✅
គេហទំព័រ ២ គណនីតែមួយ ប៉ុន្តែ key ដាច់ដោយឡែក (លំនាំដើម)key ទាំងពីរ៖ តែ key នេះវិក្កយបត្រមួយឆ្លងទាំងពីរគេហទំព័រ ⚠️ អតិថិជនអាចបញ្ចូលពីរដង — សូមភ្ជាប់ key
គេហទំព័រ ២ មានគណនីទទួលប្រាក់ខុសគ្នាតែ key នេះ (លំនាំដើម)វិក្កយបត្ររបស់គេហទំព័រមួយ នៅគេហទំព័រមួយទៀតទទួល RECEIVER_MISMATCH រួចហើយ ✅
គេហទំព័រ ២ នៅគណនី tungkao ខុសគ្នា (ម្ចាស់ខុសគ្នា) ប៉ុន្តែគណនីទទួលប្រាក់ដូចគ្នាមិនអាចភ្ជាប់ key ឆ្លងគណនី tungkao បានទេវិក្កយបត្រមួយឆ្លងទាំងពីរ ⚠️ — ទិញ key ទាំងពីរពីគណនី tungkao តែមួយ ហើយភ្ជាប់
គេហទំព័រមួយប្រើ key ២ (ឧ. គេហទំព័រ + កម្មវិធី)key ទាំងពីរ៖ ក្រុមដូចគ្នាវិក្កយបត្រប្រើបានម្ដង មិនថាផ្ញើពីគេហទំព័រ ឬកម្មវិធី ✅

DUPLICATE ត្រូវបានរកឃើញភ្លាមពីលេខយោងក្នុង QR។ កំណត់នៅកាត “ការពារវិក្កយបត្រស្ទួនរវាង key” ក្នុងទំព័រ API Keys (key ថ្មីលំនាំដើម៖ តែ key នេះ)

📚 ឧទាហរណ៍ការប្រើ

ឧទាហរណ៍ 1

Customer tops up with a matching slip (passes)

ស្ថានការណ៍: A customer transfers 500 THB to your account and uploads the slip on your top-up page

សំណើ
POST /v1/slip/verify
{
  "image_base64": "<base64 of the slip image>",
  "expected_amount": "500.00"
}
ឧទាហរណ៍ចម្លើយ
{
  "success": true,
  "status": "VALID",
  "data": {
    "trans_ref": "2025111612345678",
    "amount": "500.00",
    "currency": "THB"
  },
  "billing": {
    "credits_charged": 250
  }
}

➡️ VALID → credit the customer now; the slip is marked as used

ឧទាហរណ៍ 2

Send the QR text instead of the image (faster)

ស្ថានការណ៍: Your app reads the QR on the slip itself and sends only the QR text

សំណើ
POST /v1/slip/verify
{
  "qr_payload": "0041000600000101030040220014242082547BPM04988…",
  "expected_amount": "500.00"
}

➡️ Same result as sending the image, smaller and faster. If you have the image, send it: some backup providers verify from the image

ឧទាហរណ៍ 3

The customer sends the same slip again

ស្ថានការណ៍: The customer attaches the same 500 THB slip again to top up twice

សំណើ
POST /v1/slip/verify
{
  "image_base64": "<base64 of the slip image>",
  "expected_amount": "500.00"
}
ឧទាហរណ៍ចម្លើយ
{
  "success": false,
  "status": "DUPLICATE",
  "message": "This slip has already been used"
}

➡️ DUPLICATE → do not credit; tell the customer the slip was already used

ឧទាហរណ៍ 4

Wrong amount or wrong account

ស្ថានការណ៍: The customer paid 300 THB for a 500 THB order, or paid another account

សំណើ
POST /v1/slip/verify
{
  "image_base64": "<base64 of the slip image>",
  "expected_amount": "500.00",
  "receivers": [
    {
      "bank": "KBANK",
      "account_number": "123-4-56789-0"
    }
  ]
}
ឧទាហរណ៍ចម្លើយ
{
  "success": false,
  "status": "AMOUNT_MISMATCH"
}

➡️ AMOUNT_MISMATCH = wrong amount · RECEIVER_MISMATCH = other account. The slip is not marked as used, so the customer can retry with the right one

ឧទាហរណ៍ 5

Slip is too old

ស្ថានការណ៍: You only accept slips paid within the last 30 minutes

សំណើ
POST /v1/slip/verify
{
  "image_base64": "<base64 of the slip image>",
  "expected_amount": "500.00",
  "max_age_minutes": 30
}
ឧទាហរណ៍ចម្លើយ
{
  "success": false,
  "status": "DATE_MISMATCH"
}

➡️ DATE_MISMATCH when the slip is older than allowed

ឧទាហរណ៍ 6

Two sites, one receiving account

ស្ថានការណ៍: aaa.com and bbb.com use different keys but receive into the same account

➡️ Put both keys in one group on the “Duplicate-slip protection between keys” card → a slip that passed on aaa.com returns DUPLICATE on bbb.com

ឧទាហរណ៍ 7

Every verifier is down

ស្ថានការណ៍: All upstream verifiers fail at once (rare; backups are tried first)

ឧទាហរណ៍ចម្លើយ
{
  "success": false,
  "status": "SERVICE_UNAVAILABLE"
}

➡️ HTTP 503 and nothing is charged. Ask the customer to retry later, or queue it for manual review

  • ផ្ញើ header Idempotency-Key (ឧ. លេខបញ្ជាទិញ)៖ ផ្ញើឡើងវិញនឹងមិនគិតប្រាក់ពីរដង
  • វិក្កយបត្រ VALID តែម្ដងក្នុងមួយ key (លើកទីពីរ DUPLICATE)
  • Several sites receiving into the same account? Put their keys in the same group under “Duplicate-slip protection between keys” on the API Keys page. A slip that passed on one key then returns DUPLICATE on every key in the group (default: this key only).

ពិនិត្យវិក្កយបត្រ TrueMoney Wallet

truewallet_verify

ពិនិត្យថាវិក្កយបត្រផ្ទេរប្រាក់ TrueMoney Wallet ពិត ចំនួនត្រូវ ផ្ទេរចូលលេខកាបូបរបស់អ្នក ហើយមិនទាន់ប្រើ

របៀបដំណើរការ

  1. កំណត់កាបូបទទួលប្រាក់ម្ដង (PUT /v1/truewallet/profile ឬលើកាត key ក្នុងផតថល)៖ លេខទូរសព្ទ ឬ e-Wallet ID ឈ្មោះថៃ/អង់គ្លេស និងរូប QR ទទួលប្រាក់
  2. បង្ហាញរូប QR (qr_image_url) ឱ្យអតិថិជនបង់ ហើយឱ្យគាត់ផ្ទុករូបវិក្កយបត្រ
  3. ផ្ញើរូបវិក្កយបត្រ (image_base64) និងចំនួនដែលរំពឹងទៅ API។ លេខ និងឈ្មោះយកពីព័ត៌មានដែលបានរក្សាទុក (ឬផ្ញើ wallet_number / ewallet_id ក្នុងសំណើ)
  4. ទទួលការបញ្ជាទិញតែពេល status = VALID
PUT/v1/truewallet/profile
curl -X PUT https://api.tungkao.com/v1/truewallet/profile \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"wallet_number":"0812345678","ewallet_id":"140000812345678","name_en":"Somchai Jaidee","qr_image_base64":"<base64 QR image>"}'
GET/v1/truewallet/profile
curl -X GET https://api.tungkao.com/v1/truewallet/profile \
  -H "Authorization: Bearer $TUNGKAO_KEY"
POST/v1/truewallet/verify
curl -X POST https://api.tungkao.com/v1/truewallet/verify \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image_base64":"<base64 slip image>","expected_amount":"500.00"}'

📖 សង្ខេប៖ ប្រើ key ជាមួយគេហទំព័រច្រើន លទ្ធផលយ៉ាងដូចម្ដេច

ករណីការកំណត់ key (ទំព័រ API Keys)លទ្ធផល
គេហទំព័រ ២ (aaa.com, bbb.com) ទទួលប្រាក់ចូលគណនីតែមួយkey ទាំងពីរ៖ ក្រុម A (ឬ គណនីទាំងមូល)វិក្កយបត្រដែលឆ្លងនៅ aaa.com នឹងទទួល DUPLICATE នៅ bbb.com — ប្រើបានតែគេហទំព័រមួយ ✅
គេហទំព័រ ២ គណនីតែមួយ ប៉ុន្តែ key ដាច់ដោយឡែក (លំនាំដើម)key ទាំងពីរ៖ តែ key នេះវិក្កយបត្រមួយឆ្លងទាំងពីរគេហទំព័រ ⚠️ អតិថិជនអាចបញ្ចូលពីរដង — សូមភ្ជាប់ key
គេហទំព័រ ២ មានគណនីទទួលប្រាក់ខុសគ្នាតែ key នេះ (លំនាំដើម)វិក្កយបត្ររបស់គេហទំព័រមួយ នៅគេហទំព័រមួយទៀតទទួល RECEIVER_MISMATCH រួចហើយ ✅
គេហទំព័រ ២ នៅគណនី tungkao ខុសគ្នា (ម្ចាស់ខុសគ្នា) ប៉ុន្តែគណនីទទួលប្រាក់ដូចគ្នាមិនអាចភ្ជាប់ key ឆ្លងគណនី tungkao បានទេវិក្កយបត្រមួយឆ្លងទាំងពីរ ⚠️ — ទិញ key ទាំងពីរពីគណនី tungkao តែមួយ ហើយភ្ជាប់
គេហទំព័រមួយប្រើ key ២ (ឧ. គេហទំព័រ + កម្មវិធី)key ទាំងពីរ៖ ក្រុមដូចគ្នាវិក្កយបត្រប្រើបានម្ដង មិនថាផ្ញើពីគេហទំព័រ ឬកម្មវិធី ✅

DUPLICATE ត្រូវបានរកឃើញភ្លាមពីលេខយោងក្នុង QR។ កំណត់នៅកាត “ការពារវិក្កយបត្រស្ទួនរវាង key” ក្នុងទំព័រ API Keys (key ថ្មីលំនាំដើម៖ តែ key នេះ)

📚 ឧទាហរណ៍ការប្រើ

ឧទាហរណ៍ 1

កំណត់កាបូបទទួលប្រាក់ម្ដង

ស្ថានការណ៍: ហាងទទួលប្រាក់ចូល TrueMoney 081-234-5678 (Somchai) ហើយមាន QR ទទួលប្រាក់

សំណើ
PUT /v1/truewallet/profile
{
  "receive_by": "wallet_number",
  "wallet_number": "0812345678",
  "name_en": "Somchai Jaidee",
  "qr_image_base64": "<base64 of the QR image>"
}
ឧទាហរណ៍ចម្លើយ
{
  "success": true,
  "data": {
    "receive_by": "wallet_number",
    "wallet_number": "0812345678",
    "qr_image_url": "https://api.tungkao.com/v1/truewallet/qr/…"
  }
}

➡️ បង្ហាញ qr_image_url លើទំព័របង់ប្រាក់ឱ្យអតិថិជនស្កេន

ឧទាហរណ៍ 2

ផ្ទៀងផ្ទាត់ដោយកាបូបដែលបានរក្សាទុក

ស្ថានការណ៍: អតិថិជនផ្ទេរ 300 បាត ចូលកាបូប TrueMoney របស់អ្នក ហើយភ្ជាប់វិក្កយបត្រ

សំណើ
POST /v1/truewallet/verify
{
  "image_base64": "<base64 of the slip image>",
  "expected_amount": "300.00"
}
ឧទាហរណ៍ចម្លើយ
{
  "success": true,
  "status": "VALID",
  "data": {
    "amount": "300.00",
    "currency": "THB"
  }
}

➡️ មិនចាំបាច់ផ្ញើលេខម្ដងទៀត ប្រើកាបូបដែលរក្សាទុកក្នុង key

ឧទាហរណ៍ 3

ទទួលប្រាក់ដោយ e-Wallet ID តែប៉ុណ្ណោះ

ស្ថានការណ៍: អតិថិជនបង់តាម e-Wallet ID ១៥ ខ្ទង់ អ្នកមិនចាំបាច់បង្ហាញលេខទូរសព្ទ

សំណើ
PUT /v1/truewallet/profile
{
  "receive_by": "ewallet_id",
  "ewallet_id": "140000812345678"
}

➡️ វិក្កយបត្រដែលផ្ទេរចូលលេខទូរសព្ទទទួល RECEIVER_MISMATCH ទទួលតែ e-Wallet ID

ឧទាហរណ៍ 4

ផ្ញើអ្នកទទួលក្នុងសំណើ (កាបូបច្រើន)

ស្ថានការណ៍: អ្នកប្ដូរវេនកាបូបច្រើនតាមសាខា

សំណើ
POST /v1/truewallet/verify
{
  "image_base64": "<base64 of the slip image>",
  "expected_amount": "300.00",
  "wallet_numbers": [
    "0812345678",
    "0898765432"
  ],
  "wallet_name_en": "Somchai Jaidee"
}

➡️ ឆ្លង បើវិក្កយបត្រផ្ទេរចូលកាបូបណាមួយក្នុងបញ្ជី ហើយឈ្មោះត្រូវ

ឧទាហរណ៍ 5

អ្នកផ្ដល់សេវាចម្បងខូច អ្នកបម្រុងជំនួស

ស្ថានការណ៍: អ្នកផ្ទៀងផ្ទាត់ចម្បងបរាជ័យពេលអតិថិជនកំពុងផ្ញើ

សំណើ
POST /v1/truewallet/verify
{
  "image_base64": "<base64 of the slip image>",
  "expected_amount": "300.00"
}

➡️ អ្នកបម្រុងផ្ទៀងផ្ទាត់ក្នុងសំណើតែមួយ។ ផ្ញើ image_base64៖ អ្នកបម្រុងផ្ទៀងផ្ទាត់ពីរូបភាព

ឧទាហរណ៍ 6

ស្ទួន ឬចំនួនខុស

ស្ថានការណ៍: អតិថិជនផ្ញើវិក្កយបត្រម្ដងទៀត ឬផ្ទេរមិនគ្រប់

ឧទាហរណ៍ចម្លើយ
{
  "success": false,
  "status": "DUPLICATE"
}

➡️ DUPLICATE = ប្រើរួច · AMOUNT_MISMATCH = ចំនួនខុស។ កុំបញ្ចូលក្រេឌីតទាំងពីរករណី

  • កំណត់អ្នកទទួលដោយវិធីណាមួយ ឬទាំងពីរ៖ wallet_number (លេខទូរសព្ទ ១០ ខ្ទង់) ឬ ewallet_id (e-Wallet ID ១៥ ខ្ទង់)។ វិក្កយបត្រត្រូវនឹងមួយណាក៏ឆ្លង
  • ជ្រើសវិធីទទួលដោយ receive_by៖ wallet_number (តែលេខ) ewallet_id (តែ e-Wallet ID) ឬ any (លំនាំដើម មួយណាក៏បាន)។ វិក្កយបត្រត្រូវបានពិនិត្យតាមអត្តសញ្ញាណដែលបានជ្រើស
  • ឈ្មោះអ្នកទទួល៖ name_th, name_en ឬទាំងពីរ (wallet_name_th / wallet_name_en ក្នុងសំណើផ្ទៀងផ្ទាត់)។ បើកំណត់ វិក្កយបត្រត្រូវតែត្រូវនឹងមួយ បើមិនកំណត់ មិនពិនិត្យឈ្មោះ
  • រូប QR ទទួលប្រាក់៖ JPG/PNG មិនលើស 1 MB ដែលអាន QR បាន។ អ្នកទទួលបាន qr_image_url សម្រាប់ទំព័របង់ប្រាក់ ផ្ទុករូបថ្មី = តំណថ្មី
  • wallet_number គឺលេខទូរសព្ទ ១០ ខ្ទង់នៃកាបូបទទួល។ ផ្ញើច្រើនដោយ wallet_numbers (អតិបរមា ១០) ឬរក្សាទុកលើ key ក្នុងផតថល
  • ចម្លើយ និងស្ថានភាពដូច /v1/slip/verify។ វិក្កយបត្រមួយ VALID បានម្ដងក្នុងមួយ key (លើកទីពីរទទួល DUPLICATE)
  • ផ្ញើ header Idempotency-Key (ឧ. លេខបញ្ជាទិញ)៖ ផ្ញើឡើងវិញនឹងមិនគិតប្រាក់ពីរដង
🏦

បញ្ចូលប្រាក់តាមវិក្កយបត្រ

slip_deposit

បញ្ចូលប្រាក់សម្រាប់អ្នកប្រើ៖ ពិនិត្យវិក្កយបត្រ កត់ត្រាការបញ្ចូលរបស់អ្នកនោះ ហើយជូនដំណឹងតាម webhook

របៀបដំណើរការ

  1. កំណត់គណនីទទួល និង URL webhook លើ key នៅផតថល
  2. ផ្ញើវិក្កយបត្រជាមួយ customer_ref (លេខអ្នកប្រើរបស់អ្នក)
  3. ពេលទទួល webhook deposit.succeeded (ពិនិត្យហត្ថលេខា) បញ្ចូលប្រាក់ឱ្យអ្នកប្រើ
POST/v1/deposits/slip
curl -X POST https://api.tungkao.com/v1/deposits/slip \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"qr_payload":"0041000600000101030040220014…","customer_ref":"member-1001","expected_amount":"300.00"}'
GET/v1/deposits/dep_xxx
curl -X GET https://api.tungkao.com/v1/deposits/dep_xxx \
  -H "Authorization: Bearer $TUNGKAO_KEY"

ពិនិត្យហត្ថលេខា webhook

គ្រប់ webhook មាន X-Tungkao-Signature: t=…,v1=… ពិនិត្យមុនជឿទិន្នន័យ (សម្ងាត់ webhook បង្ហាញពេលកំណត់ URL)

import crypto from "node:crypto";
// use the raw body only — never re-JSON.stringify it
function verify(rawBody, header, secret) {
  const m = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(header || "");
  if (!m || Math.abs(Date.now() / 1000 - Number(m[1])) > 300) return false;
  const want = crypto.createHmac("sha256", secret).update(`${m[1]}.${rawBody}`).digest("hex");
  return crypto.timingSafeEqual(Buffer.from(want), Buffer.from(m[2]));
}

📚 ឧទាហរណ៍ការប្រើ

ឧទាហរណ៍ 1

Credit a member's deposit

ស្ថានការណ៍: Member member-1001 deposits 300 THB and attaches the slip

សំណើ
POST /v1/deposits/slip
{
  "image_base64": "<base64 of the slip image>",
  "customer_ref": "member-1001",
  "expected_amount": "300.00"
}
ឧទាហរណ៍ចម្លើយ
{
  "success": true,
  "status": "VALID",
  "data": {
    "deposit_id": "dep_8f2c…",
    "customer_ref": "member-1001",
    "amount": "300.00"
  }
}

➡️ Store deposit_id with the order and credit the member

ឧទាហរណ៍ 2

Attach your own data to the deposit

ស្ថានការណ៍: You want to know which promotion the deposit came from

សំណើ
POST /v1/deposits/slip
{
  "image_base64": "<base64 of the slip image>",
  "customer_ref": "member-1001",
  "metadata": {
    "promo": "NEWYEAR",
    "channel": "app"
  }
}

➡️ metadata comes back in the webhook and when you fetch the deposit

ឧទាហរណ៍ 3

Receive the result by webhook

ស្ថានការណ៍: With a webhook URL on the key, the result is pushed to your site

➡️ Verify the webhook signature before crediting and use deposit_id to avoid double credit

ឧទាហរណ៍ 4

Check a deposit later

ស្ថានការណ៍: Your site missed the webhook or wants to re-check

សំណើ
GET /v1/deposits/dep_8f2c…
ឧទាហរណ៍ចម្លើយ
{
  "success": true,
  "data": {
    "deposit_id": "dep_8f2c…",
    "status": "succeeded"
  }
}

➡️ succeeded = credit · failed = rejected · pending = wait

ឧទាហរណ៍ 5

Member resubmits the same slip

ស្ថានការណ៍: A member tries to deposit again with the same slip

ឧទាហរណ៍ចម្លើយ
{
  "success": false,
  "status": "DUPLICATE"
}

➡️ DUPLICATE; no new deposit is created

🔐

Sign-in for your website (Google, LINE, Facebook, Apple, TikTok, Discord, Telegram, X, Microsoft, GitHub + 14 more)

Add 'Sign in with …' to your site without registering with each provider. Get name, email, photo, a stable member id, and a member list with sign-in history. One service per provider: google_login, line_login, facebook_login, tiktok_login, discord_login, telegram_login, x_login, microsoft_login, github_login.

របៀបដំណើរការ

  1. បង្កើត key សម្រាប់អ្នកផ្ដល់សេវា ហើយនៅ 'សមាជិកចូល' កំណត់ឈ្មោះគេហទំព័រ និង redirect URI (https ដូចទាំងស្រុង)
  2. ប៊ូតុងចូលនាំអ្នកប្រើទៅ /oauth/authorize ជាមួយ client_id (លេខ key), redirect_uri និង state (ចៃដន្យថ្មី រក្សាក្នុង session)
  3. អ្នកប្រើត្រឡប់មក redirect_uri?code=…&state=… → ពិនិត្យ state → ម៉ាស៊ីនមេហៅ POST /v1/login/token ក្នុង 2 នាទី
  4. ប្រើ data.user (ឧ. 7F3K9QX2-yourshopcom) ជាលេខសមាជិក — មនុស្សដដែលទទួលលេខដដែលជានិច្ច
POST/v1/login/token
curl -X POST https://api.tungkao.com/v1/login/token \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"code":"from the redirect","redirect_uri":"https://yourshop.com/auth/callback"}'
GET/v1/login/users?limit=50
curl -X GET https://api.tungkao.com/v1/login/users?limit=50 \
  -H "Authorization: Bearer $TUNGKAO_KEY"

📖 Summary: using sign-in keys on several sites

ករណីការកំណត់ key (ទំព័រ API Keys)លទ្ធផល
One site, 2 keys of the same provider (e.g. website + app, both Google)Both keys: Combined (default)The same person gets the same user ID in both ✅
One site, 2 keys of the same provider, counted as separate accountsBoth keys: SeparateThe same person gets a different user ID on each key
2 sister sites sharing membersBoth keys: Group AA member has the same user ID on both sites ✅
2 unrelated sites that must not link membersBoth keys: SeparateDifferent user IDs, so the sites can't link their members ✅
A Google key and a LINE key (different providers)Any settingAlways different user IDs — they are different provider accounts
A key that already has sign-ins needs a different groupNot allowed (locked 🔒)Create a new key in the wanted group, so member IDs on your site never change

Set it on the “Sign-in user IDs between keys” card on the API Keys page before go-live (new keys default: Combined). Several keys may use the same domain.

គំរូពេញ (ប៊ូតុង + callback + ប្ដូរ code)

// npm i express express-session
import express from "express";
import session from "express-session";
import crypto from "node:crypto";

const KEY = process.env.TUNGKAO_KEY;            // API key (tk_live_…) server-side only
const CLIENT_ID = process.env.TUNGKAO_CLIENT_ID; // the key id (shown in the portal), not a secret
const REDIRECT = "https://yourshop.com/auth/callback"; // must match the registered URL exactly

const app = express();
app.use(session({ secret: process.env.SESSION_SECRET, resave: false, saveUninitialized: false, cookie: { secure: true, sameSite: "lax" } }));

// 1) your "Sign in" button links here
app.get("/auth/login", (req, res) => {
  req.session.state = crypto.randomBytes(24).toString("base64url");
  const u = new URL("https://api.tungkao.com/oauth/authorize");
  u.search = new URLSearchParams({ client_id: CLIENT_ID, redirect_uri: REDIRECT, state: req.session.state });
  res.redirect(u);
});

// 2) the user comes back with a code
app.get("/auth/callback", async (req, res) => {
  if (!req.query.state || req.query.state !== req.session.state) return res.status(400).send("state mismatch");
  delete req.session.state;
  if (req.query.error) return res.redirect("/login?cancelled=1");
  // 3) exchange the code for the user (within 2 minutes)
  const r = await fetch("https://api.tungkao.com/v1/login/token", {
    method: "POST",
    headers: { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json" },
    body: JSON.stringify({ code: req.query.code, redirect_uri: REDIRECT }),
  });
  const j = await r.json();
  if (!j.success) return res.status(400).send(j.error.message);
  req.session.user = j.data; // j.data.user = permanent member id, e.g. 7F3K9QX2-yourshopcom
  res.redirect("/");
});
app.listen(3000);
អ្នកផ្ដល់សេវាសេវាអ្នកទទួលបាន
Googlegoogle_loginឈ្មោះ អ៊ីមែលផ្ទៀងផ្ទាត់ រូប
LINEline_loginឈ្មោះ រូប អ៊ីមែលបើយល់ព្រម
Facebookfacebook_loginឈ្មោះ រូប អ៊ីមែល
TikToktiktok_loginឈ្មោះបង្ហាញ រូប (គ្មានអ៊ីមែល)
Discorddiscord_loginឈ្មោះ រូប អ៊ីមែល
Telegramtelegram_loginname, username, photo
X (Twitter)x_loginname, username, photo
Microsoftmicrosoft_loginname, email (Hotmail/Outlook)
GitHubgithub_loginname, email, avatar
Appleapple_loginpermanent member ID (no name or email in this mode)
Steamsteam_loginname, avatar and SteamID (no email)
Twitchtwitch_loginname, email, avatar
LinkedInlinkedin_loginname, email, photo
Kakaokakao_loginname, photo (email once Kakao approves it)
NAVERnaver_loginname, email, photo
Zalozalo_loginname, photo (no email)
Spotifyspotify_loginname, email, photo
Redditreddit_loginusername, avatar (no email)
GitLabgitlab_loginname, email, avatar
Robloxroblox_loginname, avatar (no email)
Epic Gamesepicgames_logindisplay name (no email)
Yahooyahoo_loginname, email, photo
Slackslack_loginname, email, photo
Amazonamazon_loginname, email

📚 ឧទាហរណ៍ការប្រើ

ឧទាហរណ៍ 1

A “Sign in with Google” button on your site

ស្ថានការណ៍: A visitor taps Sign in with Google on your site

សំណើ
GET /oauth/authorize?client_id=<CLIENT_ID>&redirect_uri=https://yourshop.com/auth/callback&state=xyz

➡️ The user signs in with Google and returns to redirect_uri with a code and the same state

ឧទាហរណ៍ 2

Exchange the code for the user (server side)

ស្ថានការណ៍: Your server receives the code on the callback page (exchange within 2 minutes)

សំណើ
POST /v1/login/token
{
  "code": "<code from the callback>",
  "redirect_uri": "https://yourshop.com/auth/callback"
}
ឧទាហរណ៍ចម្លើយ
{
  "success": true,
  "data": {
    "user": "7F3K9QX2-yourshopcom",
    "provider": "google",
    "name": "Somchai",
    "is_new_user": true
  }
}

➡️ Use user as the member id in your database (stable per person)

ឧទាហរណ៍ 3

A returning user signs in

ស្ថានការណ៍: The same person signs in with Google again

ឧទាហរណ៍ចម្លើយ
{
  "success": true,
  "data": {
    "user": "7F3K9QX2-yourshopcom",
    "is_new_user": false,
    "login_count": 5
  }
}

➡️ Same user every time → look up the member and sign them in

ឧទាហរណ៍ 4

One site, two Google keys (website + app)

ស្ថានការណ៍: Separate keys for website and app, same members

➡️ Keep both keys “Combined” (default) before go-live → same user for the same person. Choose “Separate” to keep them apart

ឧទាហរណ៍ 5

List members who signed in

ស្ថានការណ៍: You want to browse or search members of this key

សំណើ
GET /v1/login/users?q=somchai&limit=50

➡️ Returns members with last sign-in time and count

ឧទាហរណ៍ 6

The user cancels during sign-in

ស្ថានការណ៍: The user cancels on the Google screen

➡️ Returns to redirect_uri with error instead of code; show a retry button

  • User IDs between keys: new keys default to “Combined (whole account)”, so the same person signing in through keys of the same provider in one account gets the same ID. Change it to group A–E or “Separate” on the API Keys page before the first sign-in; after that the group is locked so member IDs never change.
  • គិតក្រេឌីតរាល់ការចូលជោគជ័យ និងម្ដងក្នុងមួយសមាជិកថ្មី — មើលតម្លៃលើកាតសេវា
  • key របៀប test អនុញ្ញាត redirect http://localhost ហើយឥតគិតថ្លៃ
  • កុំដាក់ API key ក្នុងតំណ ឬទំព័រ — /oauth/authorize ត្រូវការតែ client_id (លេខ key) ដែលជាសាធារណៈ
✈️

ការជូនដំណឹងតាម Telegram

telegram_notify

ផ្ញើសារ Telegram ទៅអ្នកប្រើតាមបូតរបស់ TUNGKAO — មិនចាំបាច់បូតផ្ទាល់ខ្លួន ឧ. ប្រាក់ចូល ស្ថានភាពបញ្ជាទិញ OTP

របៀបដំណើរការ

  1. ref is your own name for a recipient (use your member id, e.g. member-1001): A-Z a-z 0-9 _ . : @ - up to 128 chars. Every call refers to the recipient by this ref.
  2. Add a recipient: your server calls POST /v1/telegram/link {ref} → gets data.url (a t.me/…?start=… link) → show it as a “Connect Telegram” button on the member's profile page (valid 30 minutes, single use; request again any time).
  3. The member opens the link → presses Start in Telegram → the bot confirms (Telegram does not let a bot message someone who never pressed Start, so this step cannot be skipped).
  4. Check the connection: GET /v1/telegram/recipients (status = active) — use it to switch your button to “Connected ✓”.
  5. Send: POST /v1/telegram/send with one ref or up to 100 refs; bold text (parse_mode: HTML) and a link button are supported. Per-recipient results are in data.results: sent / not_linked / failed.
  6. Remove a recipient: DELETE /v1/telegram/recipients/{ref}. Members can also send /stop to the bot. If a member blocks the bot, that recipient is paused until they connect again.
  7. Try it without code: TUNGKAO API key page → this key's card → “Set up notifications” has a create-link button (with QR) and a send-test button.
POST/v1/telegram/link
curl -X POST https://api.tungkao.com/v1/telegram/link \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ref":"member-1001"}'
POST/v1/telegram/send
curl -X POST https://api.tungkao.com/v1/telegram/send \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ref":"member-1001","text":"<b>Payment received</b> 500 THB","parse_mode":"HTML","button":{"text":"View order","url":"https://yourshop.com/orders/1"}}'
GET/v1/telegram/messages
curl -X GET https://api.tungkao.com/v1/telegram/messages \
  -H "Authorization: Bearer $TUNGKAO_KEY"

📚 ឧទាហរណ៍ការប្រើ

ឧទាហរណ៍ 1

Let a member connect Telegram

ស្ថានការណ៍: Member member-1001 wants notifications on Telegram

សំណើ
POST /v1/telegram/link
{
  "ref": "member-1001"
}
ឧទាហរណ៍ចម្លើយ
{
  "success": true,
  "data": {
    "url": "https://t.me/…?start=…"
  }
}

➡️ Give the member the link to tap (valid 30 minutes, once)

ឧទាហរណ៍ 2

Notify a payment

ស្ថានការណ៍: 500 THB arrived and you want to notify the member

សំណើ
POST /v1/telegram/send
{
  "ref": "member-1001",
  "text": "<b>Payment received</b> 500 THB",
  "parse_mode": "HTML"
}

➡️ The member gets the message in Telegram right away

ឧទាហរណ៍ 3

Message with a link button

ស្ថានការណ៍: You want a button to open the order

សំណើ
POST /v1/telegram/send
{
  "ref": "member-1001",
  "text": "Order #1001 shipped",
  "button": {
    "text": "View order",
    "url": "https://yourshop.com/orders/1001"
  }
}

➡️ A button under the message opens the link

ឧទាហរណ៍ 4

Notify several members at once

ស្ថានការណ៍: Announce a promotion to three members

សំណើ
POST /v1/telegram/send
{
  "refs": [
    "member-1001",
    "member-1002",
    "member-1003"
  ],
  "text": "New promotion today"
}

➡️ Sent to each member; check results with GET /v1/telegram/messages

ឧទាហរណ៍ 5

A member stops notifications

ស្ថានការណ៍: The member asks to disconnect

សំណើ
DELETE /v1/telegram/recipients/member-1001

➡️ The link is removed; no more messages are sent

  • គិតតែសារដែលផ្ញើដល់ — បរាជ័យ (ឧ. អ្នកប្រើបិទបូត) សងវិញ ហើយផ្អាកអ្នកទទួលនោះ
🔔

ការជូនដំណឹងតាម Discord

discord_notify

ផ្ញើសារទៅឆានែល Discord របស់អ្នក ឬអតិថិជន — ឧ. ការបញ្ជាទិញថ្មីសម្រាប់ក្រុម

របៀបដំណើរការ

  1. Create a channel webhook in Discord (needs Manage Webhooks): desktop right-click the channel → Edit Channel → Integrations → Webhooks → New Webhook → name it → Copy Webhook URL (mobile: long-press the channel → Edit Channel).
  2. ref is your own name for the channel, e.g. orders-room (A-Z a-z 0-9 _ . : @ - up to 128 chars). One key can hold many channels, each with its own ref.
  3. Add a channel: POST /v1/discord/webhooks {ref, url} — url must start with https://discord.com/api/webhooks/…; it is stored encrypted and never returned. Posting the same ref again replaces that channel's link.
  4. Send: POST /v1/discord/send {ref, text} (up to 2000 chars; @everyone / @here are disabled automatically). Results are in data.results: sent / not_linked / failed.
  5. List channels: GET /v1/discord/recipients. Remove: DELETE /v1/discord/recipients/{ref}. If the webhook is deleted in Discord, the channel is paused and the undelivered message is refunded.
  6. Try it without code: TUNGKAO API key page → this key's card → “Set up notifications”: paste the webhook link, add the channel and send a test.
  7. Do not confuse this with the key's “Webhook URL” setting: that is your server address for receiving events from TUNGKAO, not a Discord channel link.
POST/v1/discord/webhooks
curl -X POST https://api.tungkao.com/v1/discord/webhooks \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ref":"orders-room","url":"https://discord.com/api/webhooks/123/abc…"}'
POST/v1/discord/send
curl -X POST https://api.tungkao.com/v1/discord/send \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ref":"orders-room","text":"🛒 New order #1001 — 590 THB"}'

📚 ឧទាហរណ៍ការប្រើ

ឧទាហរណ៍ 1

Register a Discord channel

ស្ថានការណ៍: You want new orders posted in #orders

សំណើ
POST /v1/discord/webhooks
{
  "ref": "orders-room",
  "url": "https://discord.com/api/webhooks/123/abc…"
}

➡️ Name it once with ref and use it forever

ឧទាហរណ៍ 2

Post a new order

ស្ថានការណ៍: Order #1001 for 590 THB comes in

សំណើ
POST /v1/discord/send
{
  "ref": "orders-room",
  "text": "🛒 New order #1001 — 590 THB"
}

➡️ The message appears in the channel right away

ឧទាហរណ៍ 3

Custom sender name

ស្ថានការណ៍: You want the sender to show as “Shop Bot”

សំណើ
POST /v1/discord/send
{
  "ref": "orders-room",
  "text": "Daily sales: 12,400 THB",
  "username": "Shop Bot"
}

➡️ The message shows Shop Bot as the sender

ឧទាហរណ៍ 4

Post to several channels

ស្ថានការណ៍: Notify both the admin and the stock channels

សំណើ
POST /v1/discord/send
{
  "refs": [
    "admin-room",
    "stock-room"
  ],
  "text": "Stock low: T-shirt size M"
}

➡️ Posted to every listed channel

ឧទាហរណ៍ 5

Check sending history

ស្ថានការណ៍: You want to see which messages failed

សំណើ
GET /v1/discord/messages

➡️ Returns each message with its status

📧

ផ្ញើអ៊ីមែល + OTP + SMTP

email

ផ្ញើអ៊ីមែលពីគេហទំព័រតាម API ឬ SMTP (WordPress បាន) និង OTP តាមអ៊ីមែល — ប្ដូរអ្នកផ្ដល់ដោយស្វ័យប្រវត្តិ

របៀបដំណើរការ

  1. បង្កើត key អ៊ីមែល (key សាកល្បងផ្ញើបានតែទៅអាសយដ្ឋានអ្នក ៥០/ថ្ងៃ)
  2. SMTP: host smtp.tungkao.com ច្រក 587 (STARTTLS) ឬ 465 (SSL) ឈ្មោះអ្នកប្រើអ្វីក៏បាន ពាក្យសម្ងាត់ = API key
  3. API: ផ្ញើអ៊ីមែល ឬស្នើ OTP ហើយផ្ទៀងផ្ទាត់ដោយ otp_id (៥ ដង ប្រើម្ដង)
POST/v1/email/send
curl -X POST https://api.tungkao.com/v1/email/send \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to":["[email protected]"],"subject":"Order #1001 confirmed","html":"<h1>Thanks for your order</h1>","text":"Thanks for your order","from_name":"My Shop","reply_to":"[email protected]"}'
POST/v1/email/otp/send
curl -X POST https://api.tungkao.com/v1/email/otp/send \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to":"[email protected]","brand":"My Shop","lang":"th","length":6,"ttl_seconds":300}'
POST/v1/email/otp/verify
curl -X POST https://api.tungkao.com/v1/email/otp/verify \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"otp_id":"8f6c2a1e-…","code":"123456"}'

📚 ឧទាហរណ៍ការប្រើ

ឧទាហរណ៍ 1

Order confirmation email

ស្ថានការណ៍: A customer completes an order

សំណើ
POST /v1/email/send
{
  "to": [
    "[email protected]"
  ],
  "subject": "Order #1001 confirmed",
  "html": "<h1>Thanks for your order</h1>",
  "text": "Thanks for your order",
  "from_name": "My Shop",
  "reply_to": "[email protected]"
}

➡️ Always send html and text; replies go to reply_to

ឧទាហរណ៍ 2

Send an email OTP

ស្ថានការណ៍: A new sign-up must confirm their email

សំណើ
POST /v1/email/otp/send
{
  "to": "[email protected]",
  "brand": "My Shop",
  "lang": "th",
  "length": 6,
  "ttl_seconds": 300
}
ឧទាហរណ៍ចម្លើយ
{
  "success": true,
  "data": {
    "otp_id": "8f6c2a1e-…"
  }
}

➡️ Keep otp_id; the code expires in 5 minutes

ឧទាហរណ៍ 3

Check the OTP

ស្ថានការណ៍: The user types the 6-digit code

សំណើ
POST /v1/email/otp/verify
{
  "otp_id": "8f6c2a1e-…",
  "code": "123456"
}

➡️ Correct = email confirmed · too many wrong tries = code locked, send a new one

ឧទាហរណ៍ 4

Send to several people

ស្ថានការណ៍: Tell three staff about a large order

សំណើ
POST /v1/email/send
{
  "to": [
    "[email protected]",
    "[email protected]",
    "[email protected]"
  ],
  "subject": "Large order #1002",
  "text": "Order #1002: 25,000 THB"
}

➡️ Everyone listed receives the email

ឧទាហរណ៍ 5

Review sent emails

ស្ថានការណ៍: A customer says the email never arrived

សំណើ
GET /v1/email/messages

➡️ Check the delivery status of each email

  • ផ្ញើពីអាសយដ្ឋាន TUNGKAO ឈ្មោះអ្នកផ្ញើ (from_name) និង reply_to ជារបស់អ្នក
  • បើអ្នកផ្ដល់ទាំងអស់បរាជ័យ ក្រេឌីតត្រូវបានសងវិញ · ឯកសារភ្ជាប់តាម SMTP មិនត្រូវបានបញ្ជូនបន្ត
₿

ការទូទាត់គ្រីបតូ (ឆាប់ៗ)

crypto

អ្នកប្រើម្នាក់ៗមានអាសយដ្ឋាន BTC / USDT / USDC ផ្ទាល់ខ្លួន (TRON, Ethereum, BNB Chain, Polygon, Arbitrum, Base, Optimism, Avalanche) ហើយជូនដំណឹងតាម webhook — ឆាប់ៗនេះ

របៀបដំណើរការ

  1. ស្នើអាសយដ្ឋានសម្រាប់អ្នកប្រើ
  2. អ្នកប្រើផ្ញើប្រាក់
  3. បញ្ចូលពេលមាន crypto.deposit.confirmed
POST/v1/crypto/addresses
curl -X POST https://api.tungkao.com/v1/crypto/addresses \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"asset":"USDT-TRC20","customer_ref":"member-1001"}'

📚 ឧទាហរណ៍ការប្រើ

ឧទាហរណ៍ 1

Get a deposit address for a customer

ស្ថានការណ៍: member-1001 will pay in USDT on TRC20

សំណើ
POST /v1/crypto/addresses
{
  "asset": "USDT-TRC20",
  "customer_ref": "member-1001"
}

➡️ You get a per-customer address to show as a QR

ឧទាហរណ៍ 2

List supported coins and networks

ស្ថានការណ៍: You want minimums and confirmations per coin

សំណើ
GET /v1/crypto/assets

➡️ Returns min_deposit and confirmations_required per asset

ឧទាហរណ៍ 3

Check incoming deposits

ស្ថានការណ៍: Waiting for the customer's payment

សំណើ
GET /v1/crypto/deposits
ឧទាហរណ៍ចម្លើយ
{
  "success": true,
  "data": [
    {
      "asset": "USDT-TRC20",
      "customer_ref": "member-1001",
      "amount": "25.00",
      "confirmations": 20,
      "confirmations_required": 20,
      "status": "confirmed"
    }
  ]
}

➡️ confirmed = credit · pending = wait · ignored = below minimum

ឧទាហរណ៍ 4

Withdraw coins

ស្ថានការណ៍: Withdraw USDT to your own wallet

សំណើ
POST /v1/crypto/withdrawals
{
  "asset": "USDT-TRC20",
  "to_address": "T…your address…",
  "amount": "100"
}

➡️ Always check the address matches the network; wrong-network transfers can't be recovered

  • 💸 Withdrawal fees: funds received through the API pay 3.5% per withdrawal; wallets you create yourself in the merchant portal pay 2.5%. Taken from the withdrawn coin, not credits; deposits are free (live rate: withdraw_fee_percent in GET /v1/crypto/assets).

🚦 ស្ថានភាពប្រព័ន្ធ (GET /status)

ពិនិត្យថា API ធម្មតាឬទេ គ្រប់ពេល — មិនត្រូវការ key

GET https://api.tungkao.com/status

  • 🟢 ok = ធម្មតា
  • 🟠 busy = អ្នកប្រើច្រើន
  • 🔴 slow = យឺតបន្តិច
  • វាស់ពីសំណើពិតក្នុង 5 នាទីចុងក្រោយ តាមសេវានីមួយៗ (services[]) — ពិនិត្យវិក្កយបត្រវាស់ពីអ្នកផ្ដល់បម្រុងទាំងអស់ និងស្ថានភាពផ្លូវនីមួយៗក្នុង routes[]
  • មិនត្រូវការ key ហៅពី browser បាន cache 15 វិនាទី
  • ពេល busy/slow សូមបង្កើន timeout ដល់ 15–20 វិនាទី ហើយសាកម្ដងទៀតដោយ Idempotency-Key ដដែល
  • បង្ហាញនៅជ្រុងស្ដាំខាងលើ tungkao.com ផងដែរ
curl https://api.tungkao.com/status
{
  "success": true,
  "data": {
    "status": "ok",
    "services": [
      { "id": "slip_verify", "status": "ok", "routes": ["ok", "ok", "busy"] },
      { "id": "slip_deposit", "status": "ok", "routes": ["ok", "ok", "busy"] },
      { "id": "login", "status": "ok" },
      { "id": "telegram", "status": "ok" },
      { "id": "discord", "status": "ok" },
      { "id": "email", "status": "busy" },
      { "id": "crypto", "status": "ok" },
      { "id": "core", "status": "ok" }
    ],
    "paused": [],
    "updated_at": "2026-11-14T12:00:00.000Z"
  }
}

🛡️ ការសន្យាស្ថិរភាព៖ ភ្ជាប់ម្ដង ប្រើបានជានិច្ច

  • API /v1 ត្រូវចាក់សោជាអចិន្ត្រៃយ៍៖ មិនលុប មិនប្ដូរឈ្មោះ មិនប្ដូរប្រភេទ — មានតែបន្ថែម ការធ្វើតេស្តស្វ័យប្រវត្តិរារាំងការ deploy ដែលធ្វើឱ្យកូដចាស់ខូច
  • ពេលអ្នកផ្ដល់សេវា (ធនាគារ LINE Google Facebook TikTok Discord Telegram blockchain) ផ្លាស់ប្ដូរ យើងកែនៅម៉ាស៊ីនមេខ្លួនឯង — កូដរបស់អ្នកដដែល ការពិនិត្យវិក្កយបត្រប្ដូររវាងអ្នកផ្ដល់ 3 ដោយស្វ័យប្រវត្តិ
  • សរសេរកូដធន់អនាគត៖ រំលងវាលមិនស្គាល់ សម្រេចតាម error.code ហើយចាត់ status ថ្មីមិនស្គាល់ថា 'មិនឆ្លង/រង់ចាំ'
  • បើត្រូវបញ្ឈប់អ្វីមួយ នឹងជូនដំណឹងមុនយ៉ាងហោចណាស់ 12 ខែ តាម header Deprecation / Sunset អ៊ីមែល និង webhook — របស់ចាស់ដំណើរការរហូតដល់ថ្ងៃនោះ
  • គ្រប់ចម្លើយមាន header X-Tungkao-Api-Version ប្រាប់កំណែ និងកាលបរិច្ឆេទចុងក្រោយ ប្រវត្តិពេញ៖ /changelog.json

🏷️ លក្ខខណ្ឌដាក់ក្រេឌីត TUNGKAO

  • គ្រប់ទំព័រដែលប្រើសេវា TUNGKAO ត្រូវបង្ហាញ “Powered by TUNGKAO” ឬ “Secured by TUNGKAO” ហើយភ្ជាប់ទៅ https://tungkao.com
  • ដាក់ជិតមុខងារ ហាមលាក់
  • ប៊ូតុងពីទំព័រ “ប៊ូតុងចូល” មានក្រេឌីតដោយស្វ័យប្រវត្តិ
  • ឧទាហរណ៍៖ <a href="https://tungkao.com">Powered by TUNGKAO</a>
  • ចង់លាក់ក្រេឌីត ត្រូវសុំការអនុម័តជាមុន

Powered by TUNGKAO