ข้ามไปยังเนื้อหา
เบต้าแบบปิด · ยังไม่เปิดให้บริการแก่บุคคลทั่วไป เปิดบัญชีได้เฉพาะผู้ที่ได้รับคำเชิญเท่านั้น ขอสิทธิ์เข้าใช้งาน →
AywaPay

นักพัฒนา

เอกสาร API

ทุกสิ่งที่ต้องใช้เพื่อรับชำระเงินคริปโตกับ AywaPay: สร้างใบแจ้งหนี้ ส่งเงิน และตรวจสอบ Callback

เริ่มต้นใช้งาน

  1. ขอสิทธิ์เข้าใช้งาน (ขณะนี้เราอยู่ในช่วงเบต้าแบบปิด บัญชีจะเปิดผ่านคำเชิญของคุณ) แล้วสร้างร้านค้า จากนั้นเปิดใช้การยืนยันตัวตนสองขั้นตอน (2FA)
  2. เปิดแท็บ API ของร้านค้าแล้วสร้างคีย์ลับ (Secret key) หากต้องการ สามารถอนุญาตเฉพาะ IP ของเซิร์ฟเวอร์คุณได้
  3. ตั้งค่า Status URL ของร้านค้า: เราจะส่ง POST ไปยัง URL นี้ทุกครั้งที่ใบแจ้งหนี้มีการเปลี่ยนแปลง
  4. สร้างใบแจ้งหนี้จากเซิร์ฟเวอร์ของคุณ แล้วพาลูกค้าไปยัง invoice_url ที่ได้รับกลับมา

Base URL

https://api.aywapay.com/api/v1

การยืนยันตัวตน

api_key เป็นพารามิเตอร์ query ที่ต้องส่งในทุกคำขอ ห้ามใส่ไว้ในเบราว์เซอร์หรือแอปโดยเด็ดขาด

ทุกการตอบกลับอยู่ในรูปแบบ JSON: { "status": "success", "data": { … } } หรือ { "status": "error", "data": { "code": 103, "message": "…" } }

Invoices

Create an invoice

GET/api/v1/invoices/new

Creates a payment request and returns the link of the hosted payment page. Price it in fiat (the customer picks the coin) or in one coin.

ParameterDescription
api_key*Your store's secret key (Stores & API → API). Keep it on your server.
order_number*Your order id. Unique per store; repeating it is refused unless return_existing=1.
order_name*What the customer pays for, shown on the payment page.
source_currency + source_amountFiat price, e.g. USD and 49.99. Converted at the current rate.
currency + amountOr a crypto price in one coin, e.g. BTC and 0.001. currency alone fixes the coin of a fiat invoice.
allowed_psys_cidsComma list of coins the customer may choose, e.g. BTC,USDT_TRX. Coins whose minimum the order does not reach are left out.
callback_urlWhere status changes are POSTed (default: the store's Status URL). Add ?json=true for a JSON body.
success_callback_url / fail_callback_urlExtra callbacks for paid and failed invoices.
success_invoice_url / fail_invoice_urlWhere the payment page's "Back to store" button goes.
emailCustomer email: the payment link and receipt are sent there.
descriptionShown under the order name.
expire_minMinutes before the invoice expires (default: the store's setting, else 60).
return_existing1 = an existing order_number returns that invoice instead of an error.
Request
curl -G "https://api.aywapay.com/api/v1/invoices/new" \
  -d source_currency=USD -d source_amount=49.99 \
  -d order_number=1042 --data-urlencode "order_name=Pro plan" \
  --data-urlencode "callback_url=https://yourshop.com/callback?json=true" \
  -d api_key=$AYWAPAY_SECRET_KEY
Response data
{
  "txn_id": "65f1c0ffee00000000000001",
  "invoice_url": "https://pay.aywapay.com/invoice/65f1c0ffee00000000000001",
  "invoice_total_sum": "0.5512"
}

Get an invoice

GET/api/v1/invoices/:id

Full invoice: status, coin, address, amounts, confirmations and transactions.

ParameterDescription
api_key*Your store's secret key (Stores & API → API). Keep it on your server.
Request
curl -G "https://api.aywapay.com/api/v1/invoices/:id" -d api_key=$AYWAPAY_SECRET_KEY
Response data
{
  "invoice": { "txn_id": "…", "status": "completed", "psys_cid": "LTC",
    "amount": "0.5512", "received_amount": "0.5512",
    "remaining_amount": "0", "wallet_hash": "ltc1q…",
    "expected_confirmations": 6, "tx_url": ["…"], "tx_id": ["…"] },
  "active_invoice_id": "…"
}

Withdrawals & payouts

Send a withdrawal or a mass payout

GET/api/v1/operations/withdraw

Sends crypto from your balance. The network (gas) fee is taken in the same coin. Can be turned off per store (Stores & API → API).

ParameterDescription
api_key*Your store's secret key (Stores & API → API). Keep it on your server.
psys_cid*Coin, e.g. USDT_TRX.
type*cash_out (one address) or mass_cash_out (many).
to*Address, or comma list for mass_cash_out.
amount*Amount, or comma list in the same order as to.
feePlannormal (default) or priority.
Request
curl -G "https://api.aywapay.com/api/v1/operations/withdraw" -d api_key=$AYWAPAY_SECRET_KEY
Response data
{ "id": "65f1c0ffee00000000000002", "type": "cash_out", "status": "pending",
  "psys_cid": "USDT_TRX", "currency": "USDT", "amount": "25.00", "fee": "1.25",
  "wallet_hash": "T…", "tx_url": "", "tx_id": [] }

Estimate the network fee

GET/api/v1/operations/fee/:psys_cid

Fee of a withdrawal before you send it.

ParameterDescription
api_key*Your store's secret key (Stores & API → API). Keep it on your server.
addresses*Comma list of recipients.
amounts*Comma list of amounts.
feePlannormal or priority.
Request
curl -G "https://api.aywapay.com/api/v1/operations/fee/:psys_cid" -d api_key=$AYWAPAY_SECRET_KEY
Response data
{ "fee": "0.0000021", "psys_cid": "LTC", "currency": "LTC", "plan": "normal" }

Fee and commission of a withdrawal

GET/api/v1/operations/commission/:psys_cid

What the withdrawal costs in total: network fee plus any commission.

ParameterDescription
api_key*Your store's secret key (Stores & API → API). Keep it on your server.
addressesComma list of recipients.
amountsComma list of amounts.
typecash_out or mass_cash_out.
Request
curl -G "https://api.aywapay.com/api/v1/operations/commission/:psys_cid" -d api_key=$AYWAPAY_SECRET_KEY
Response data
{ "commission": "0", "fee": "0.0000021", "feeUnit": "LTC", "plan": "normal",
  "plans": { "normal": { "value": "0.0000021" }, "priority": { "value": "0.0000042" } } }

Fee plans of a coin

GET/api/v1/operations/fee-plan/:psys_cid

Details of the normal and priority plans.

ParameterDescription
api_key*Your store's secret key (Stores & API → API). Keep it on your server.
Request
curl -G "https://api.aywapay.com/api/v1/operations/fee-plan/:psys_cid" -d api_key=$AYWAPAY_SECRET_KEY
Response data
{ "normal": { … }, "priority": { … } }

Balances, operations & coins

Balance of one coin

GET/api/v1/balances/:psys_cid

Available balance of your account in that coin.

ParameterDescription
api_key*Your store's secret key (Stores & API → API). Keep it on your server.
Request
curl -G "https://api.aywapay.com/api/v1/balances/:psys_cid" -d api_key=$AYWAPAY_SECRET_KEY
Response data
{ "psys_cid": "LTC", "currency": "LTC", "balance": "0.0510" }

List operations

GET/api/v1/operations

Invoices, deposits and withdrawals, newest first.

ParameterDescription
api_key*Your store's secret key (Stores & API → API). Keep it on your server.
pagePage number (default 1).
limitItems per page (default 10).
Request
curl -G "https://api.aywapay.com/api/v1/operations" -d api_key=$AYWAPAY_SECRET_KEY
Response data
{ "operations": [ … ], "_meta": { "totalCount": 3, "pageCount": 1, "currentPage": 1, "perPage": 10 } }

Get one operation

GET/api/v1/operations/:id

One invoice, deposit or withdrawal by id.

ParameterDescription
api_key*Your store's secret key (Stores & API → API). Keep it on your server.
Request
curl -G "https://api.aywapay.com/api/v1/operations/:id" -d api_key=$AYWAPAY_SECRET_KEY
Response data
{ "id": "…", "type": "invoice", "status": "completed", … }

Coins and rates

GET/api/v1/currencies/:fiat

Every coin you can accept, with its rate in a fiat currency (default USD) and minimum invoice.

ParameterDescription
api_key*Your store's secret key (Stores & API → API). Keep it on your server.
Request
curl -G "https://api.aywapay.com/api/v1/currencies/:fiat" -d api_key=$AYWAPAY_SECRET_KEY
Response data
[ { "cid": "BTC", "name": "Bitcoin", "rate_usd": "0.0000125", "min_sum_in": "0.0001", "min_withdraw": "0.0002", … } ]

Your store

GET/api/v1/shops

The store the key belongs to.

ParameterDescription
api_key*Your store's secret key (Stores & API → API). Keep it on your server.
Request
curl -G "https://api.aywapay.com/api/v1/shops" -d api_key=$AYWAPAY_SECRET_KEY
Response data
{ "id": "…", "name": "My Shop", "plan": "api", … }

Deposit addresses (White Label)

Permanent address for one of your users

GET/api/v1/shops/deposit/new

A fixed address per user and coin. Every payment to it is credited to you and reported with a pay_in callback. White Label plan.

ParameterDescription
api_key*Your store's secret key (Stores & API → API). Keep it on your server.
psys_cid*Coin, or a comma list for several.
uid*Your id of the user.
Request
curl -G "https://api.aywapay.com/api/v1/shops/deposit/new" -d api_key=$AYWAPAY_SECRET_KEY
Response data
{ "psys_cid": "USDT_TRX", "uid": "user-17", "hash": "T…" }

List deposit addresses

GET/api/v1/shops/deposit

Addresses already given out.

ParameterDescription
api_key*Your store's secret key (Stores & API → API). Keep it on your server.
uidOnly this user.
psys_cidOnly this coin.
Request
curl -G "https://api.aywapay.com/api/v1/shops/deposit" -d api_key=$AYWAPAY_SECRET_KEY
Response data
[ { "psys_cid": "BTC", "uid": "user-17", "hash": "bc1q…" } ]

Callback (Webhook)

On every invoice status change we POST the invoice to its callback_url (or the store's Status URL). Withdrawals made with your API key are reported to the Status URL too, when they are sent, completed, fail or are cancelled. Add ?json=true to the URL to get JSON instead of a form post.

  • Answer with HTTP 200. Anything else is retried 8 more times over about two days, then shown as Failed in your dashboard.
  • Always check verify_hash before trusting a callback.
  • Stores & API → Webhooks shows every attempt, lets you resend one, and sends a signed test.
Invoice callback
{
  "txn_id": "65f1c0ffee00000000000001",
  "ipn_type": "invoice",
  "merchant": "My Shop",
  "merchant_id": "3f2a9c1e-…",
  "status": "completed",
  "amount": "0.5512",
  "currency": "LTC",
  "order_number": "1042",
  "order_name": "Pro plan",
  "confirmations": "6",
  "source_currency": "USD",
  "source_amount": "49.99",
  "invoice_total_sum": "0.5512",
  "verify_hash": "…"
}
Withdrawal callback
{
  "txn_id": "65f1c0ffee00000000000002",
  "ipn_type": "cash_out",
  "merchant": "My Shop",
  "merchant_id": "3f2a9c1e-…",
  "status": "completed",          // pending | completed | error | cancelled
  "psys_cid": "USDT_TRX",
  "currency": "USDT",
  "amount": "25.00",
  "fee": "1.25",
  "to": "T…",
  "tx_id": "a1b2…",
  "comment": "",
  "verify_hash": "…"
}

ตรวจสอบลายเซ็น

verify_hash is an HMAC-SHA1 with your store's secret key: of PHP's serialize() of the key-sorted fields for form posts, or of JSON.stringify of the body without verify_hash for JSON.

PHP (form post)
<?php
// Your store's secret key (Stores & API → API)
$secretKey = getenv('AYWAPAY_SECRET_KEY');

$post = $_POST;                       // form-encoded callback
$received = $post['verify_hash'] ?? '';
unset($post['verify_hash']);
ksort($post);
$expected = hash_hmac('sha1', serialize($post), $secretKey);

if (!hash_equals($expected, $received)) {
    http_response_code(400);
    exit('bad signature');
}
if ($post['status'] === 'completed' || $post['status'] === 'mismatch') {
    // mark order $post['order_number'] as paid
}
http_response_code(200);
Node.js (JSON)
import crypto from "node:crypto";

// callback_url ends with ?json=true, so the body is JSON
app.post("/callback", express.json(), (req, res) => {
  const { verify_hash, ...body } = req.body;
  const expected = crypto
    .createHmac("sha1", process.env.AYWAPAY_SECRET_KEY)
    .update(JSON.stringify(body))
    .digest("hex");
  const given = Buffer.from(String(verify_hash ?? ""));
  const wanted = Buffer.from(expected);
  if (given.length !== wanted.length || !crypto.timingSafeEqual(given, wanted)) {
    return res.status(400).send("bad signature");
  }

  if (body.status === "completed" || body.status === "mismatch") {
    // mark order body.order_number as paid
  }
  res.sendStatus(200);
});

โหมดทดสอบ (Sandbox)

Every store can have a test key next to its live key (Stores & API → API → Test key). It works with the same endpoints, with no real money:

  • Invoices made with the test key are test invoices: no deposit address, nothing on a blockchain.
  • Their payment page has Simulate buttons: paid, overpaid, underpaid, expire. Each fires your normal callback, with test=true and signed with the test key.
  • Test invoices never touch your balance. Withdrawals and deposit addresses need the live key (error 229); balances read 0.
  • Order numbers are separate: a test order never blocks a live one with the same number.
Create a test invoice
curl -G "https://api.aywapay.com/api/v1/invoices/new" \
  -d source_currency=USD -d source_amount=10 \
  -d order_number=test-1 -d order_name=Test \
  -d api_key=$AYWAPAY_TEST_KEY

โดเมนชำระเงินของคุณเอง (ไวท์เลเบล)

ในแพ็กเกจไวท์เลเบล ใบแจ้งหนี้ ลิงก์ชำระเงิน หน้ารับบริจาค และปุ่มชำระเงินของคุณสามารถเปิดบนที่อยู่ของคุณเอง เช่น pay.yourshop.com แทนที่อยู่ของเรา ลูกค้าจะเห็นเฉพาะโดเมนและแบรนด์ของคุณ ใช้เพียงเรคคอร์ด DNS เดียวและเวลาประมาณสิบนาที โดยไม่ต้องใช้นักพัฒนา

วิธีตั้งค่า

  1. เปลี่ยนร้านค้าเป็นแพ็กเกจไวท์เลเบล (ร้านค้า → ทั่วไป)
  2. เปิดแท็บหน้าชำระเงินของร้านค้า ในส่วน “ลิงก์ชำระเงินเปิดที่ใด” ให้เลือกโดเมนของฉันเอง
  3. พิมพ์ซับโดเมนที่คุณเป็นเจ้าของ เช่น pay.yourshop.com (ไม่ใช่ yourshop.com เอง) หากมีค่าธรรมเนียมแสดงอยู่ ให้อ่านก่อน แล้วกดบันทึก
  4. คัดลอกเรคคอร์ดที่แสดงบนหน้าจอ แล้วเพิ่มในที่ที่คุณจัดการ DNS ของโดเมน (Cloudflare, GoDaddy, Namecheap, Hostinger และอื่น ๆ) แดชบอร์ดมีคู่มือสั้น ๆ สำหรับแต่ละที่
  5. รอสักครู่ เราตรวจสอบทุกนาที: DNS → ใบรับรอง HTTPS → ใช้งานได้ โดยปกติใช้เวลา 5 ถึง 30 นาที แต่เรคคอร์ด DNS ใหม่อาจใช้เวลาหลายชั่วโมง เราจะส่งอีเมลแจ้งเมื่อใช้งานได้

เรคคอร์ด DNS

ประเภทชื่อค่า
CNAMEpay<your-code>.domains.aywapay.com

คัดลอกปลายทางที่ถูกต้องจากแดชบอร์ดของคุณ เพราะเป็นค่าเฉพาะของร้านค้าคุณ ผู้ให้บริการส่วนใหญ่ต้องการแค่ส่วนแรก (pay) เป็นชื่อ

ใช้ Cloudflare อยู่ใช่ไหม?

ตั้งเรคคอร์ดเป็น “DNS only” (เมฆสีเทา) หากเปิดเมฆสีส้มไว้ จะออกใบรับรองไม่ได้ และผลการตรวจสอบจะแจ้งว่าเรคคอร์ดผ่านพร็อกซี

หากการตรวจสอบไม่ผ่าน

  • ไม่พบเรคคอร์ด: ยังไม่มี CNAME หรือ DNS ยังกระจายไม่ทั่ว ตรวจสอบชื่อแล้วรอสักครู่
  • ชี้ไปที่อื่น: มีเรคคอร์ดอื่น (A, AAAA หรือ CNAME เก่า) ใช้ชื่อเดียวกัน ให้ลบออกและเหลือไว้เฉพาะ CNAME
  • ผ่านพร็อกซี: เมฆสีส้มของ Cloudflare เปิดอยู่ ให้เปลี่ยนเรคคอร์ดเป็น “DNS only”
  • รอใบรับรอง: DNS ถูกต้องแล้ว และใบรับรอง HTTPS มักจะตามมาภายในไม่กี่นาที

เมื่อใช้งานได้แล้ว

  • ลิงก์ใหม่และลิงก์เดิมจะเปิดบนโดเมนของคุณ ลิงก์ที่ส่งไปแล้วด้วยที่อยู่ของเรายังใช้งานได้ตามปกติ
  • คุณกลับไปใช้ลิงก์ AywaPay ได้ทุกเมื่อด้วยคลิกเดียว และโดเมนของคุณจะยังบันทึกไว้
  • หาก DNS ของคุณไม่ได้ชี้มาที่เรานาน 24 ชั่วโมง ลิงก์จะกลับไปใช้ที่อยู่ของเราเองโดยอัตโนมัติ และเราจะส่งอีเมลแจ้งคุณ จึงไม่มีการชำระเงินใดสูญหาย
  • หากบัญชีของคุณมีค่าธรรมเนียมสำหรับโดเมนของคุณเอง ค่าธรรมเนียมจะแสดงก่อนบันทึก และหักจากยอดคงเหลือของคุณ

ไม่เห็นตัวเลือกนี้ใช่ไหม? ต้องใช้แพ็กเกจไวท์เลเบล หากร้านค้าของคุณใช้แพ็กเกจนี้อยู่แล้ว โปรดเขียนถึง [email protected].

สถานะใบแจ้งหนี้

newCreated, nothing received yet.
pendingPayment seen on the blockchain, waiting for confirmations.
completedPaid in full and confirmed. Ship the order.
mismatchOverpaid and confirmed: paid, the extra is in your balance too.
expiredTime ran out. With some money received it stays open for the rest of the payment.
cancelledCancelled before payment.
cancelled duplicateThe customer switched to another coin; the new copy carries on.
errorSomething went wrong; contact support.

ข้อผิดพลาด

CodeHTTPMeaning
101401Wrong or missing api_key.
103400A parameter is missing or invalid (the message names it).
105422Coin not available for this store.
111404No such invoice or operation.
116422Balance too low for amount plus fee.
202429Too many requests; slow down.
210422Below the coin's minimum.
211422order_number already used.
213422Invalid address for this coin's network.
218422Saved addresses only is on and the address is not saved.
224422The address is blocked for compliance reasons (sanctions list).
225422Over a withdrawal limit. Check your own limits in Settings → Security, or contact support.
229422Not possible with the test key (withdrawals, deposit addresses): use the live key.
303403Request from an IP not in the store's allowed IPs.

มีคำถาม? เขียนถึงเราที่ [email protected]