Payment
Payment บันทึกธุรกรรมทางการเงินของบัญชี โดยข้อมูลการชำระเงินอาจซิงก์มาจาก Stripe หรือบันทึกด้วยตนเอง
สคีมา
interface Payment {
id: string; // "pay..." - ตัวระบุที่ไม่ซ้ำ
account_id: string;
amount_cents: number;
currency: string;
status: "pending" | "succeeded" | "failed" | "canceled" | "refunded";
paid_at: string | null;
payment_method: string | null;
external_id: string | null;
external_customer_id: string | null;
external_data: unknown | null;
}
คุณสมบัติ
| Property | Type | คำอธิบาย |
|---|
id | string | KSUID ที่ขึ้นต้นด้วย pay |
account_id | string | บัญชีเจ้าของ |
amount_cents | number | จำนวนเงินหน่วยย่อย (เซ็นต์) |
currency | string | รหัสสกุลเงิน ISO 4217 |
status | enum | สถานะตามวงจรชีวิตการชำระเงิน |
paid_at | string? | เวลาที่ชำระสำเร็จ |
payment_method | string? | ประเภทวิธีชำระเงิน |
external_id | string? | รหัสการชำระเงินจากผู้ให้บริการ |
external_customer_id | string? | รหัสลูกค้าจากผู้ให้บริการ |
external_data | object? | snapshot ดิบจากผู้ให้บริการ |
ค่าสถานะ
| Status | คำอธิบาย |
|---|
pending | รอการประมวลผล |
succeeded | ชำระสำเร็จ |
failed | ชำระไม่สำเร็จ |
canceled | ยกเลิกการชำระเงิน |
refunded | คืนเงินให้ลูกค้าแล้ว |
ตัวอย่าง
{
"id": "pay123",
"account_id": "acc456",
"amount_cents": 9900,
"currency": "usd",
"status": "succeeded",
"paid_at": "2026-01-15T10:30:00Z",
"payment_method": "card",
"external_id": "pi_abc123",
"external_customer_id": "cus_xyz789"
}
ที่เกี่ยวข้อง