ก๊อปไปสั่ง AI agent
สร้างหน้า pricing สำหรับ SaaS ด้วย Next.js ที่เก็บเงินรายเดือนผ่าน Heysub (ตลาดไทย, PromptPay/บัตร).
ข้อกำหนด:
- 3 แพ็ก: Free, Pro (490 THB/เดือน = 49000 satang), Team (990 THB/เดือน).
- ปุ่ม Subscribe ของแพ็กที่เสียเงิน ให้เรียก API ฝั่ง server:
1) POST /products {name, product_type:"membership", status:"published"}
2) POST /prices {product, type:"recurring", interval:"month", amount_satang, collection_methods:["invoice"], allowed_methods:["promptpay","card"]}
3) POST /checkout_sessions {customer_email, line_items:[{price, quantity:1}], success_url, cancel_url}
— checkout ที่มี recurring line item จะเริ่ม invoice-collected subscription ให้อัตโนมัติ (PromptPay ต่ออายุด้วยการออกบิล)
- redirect ผู้ใช้ไป response.url (หน้า hosted checkout ของ Heysub)
- เก็บ HEYSUB_API_KEY (sk_test_/sk_live_) ไว้ฝั่ง server เท่านั้น, ส่ง header Authorization: Bearer + Heysub-Version: 2026-09-01, และ Idempotency-Key ในทุก POST
- base URL: https://api.heysub.co/v1 (หรือ Supabase function URL สำหรับ staging)
ใช้ @heysub/sdk (HeysubClient) ถ้ามี