💳 Yaakdai Payment Stub Test

A testing stub for payment provider integration. Simulates various payment methods for development and testing.

🎯 Supported Payment Methods

🔲 QR Payment (PromptPay) 💳 Credit Card 💰 PayPal 📅 Buy Now Pay Later

📚 API Endpoints

POST /api/create

Create a new payment session

{
  "provider": "qr" | "creditcard" | "paypal" | "bnpl",
  "amount": 1000.00,
  "currency": "THB",
  "callback_url": "https://your-shop.com/payment/callback",
  "metadata": { "order_id": "12345" },
  // BNPL specific (optional):
  "customer_name": "John Doe",
  "customer_email": "john@example.com",
  "customer_phone": "+66123456789"
}

Response:

{
  "success": true,
  "session_id": "sess_...",
  "checkout_url": "https://payment-stub.yaakdai.net/checkout?session_id=sess_...",
  "expires_at": 1234567890000
}

GET /api/status?session_id=sess_...

Get payment session status (server-side polling)

{
  "success": true,
  "session_id": "sess_...",
  "status": "pending" | "completed" | "failed" | "expired",
  "provider": "qr",
  "amount": 1000.00,
  "currency": "THB",
  "approval_status": "pending" | "approved" | "denied" // BNPL only
}

POST /api/complete

Complete payment (called by checkout page, not by your backend)

{
  "session_id": "sess_...",
  "success": true | false
}

🔧 Admin Panel

For BNPL transactions, use the admin panel to manually approve/deny requests:

https://payment-stub.yaakdai.net/admin

Admin Token: Check your wrangler.toml configuration

🔄 Payment Flow

  1. Your backend calls POST /api/create to create a session
  2. Redirect user to checkout_url (opens in popup/new window)
  3. User interacts with payment page (clicks Success/Fail)
  4. User is redirected back to your callback_url with status
  5. Your backend calls GET /api/status to verify server-side

📝 Example Integration

// 1. Create session
const response = await fetch('https://payment-stub.yaakdai.net/api/create', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    provider: 'qr',
    amount: 1000.00,
    currency: 'THB',
    callback_url: 'https://your-shop.com/payment/callback'
  })
});

const { checkout_url, session_id } = await response.json();

// 2. Open checkout in popup
window.open(checkout_url, 'payment', 'width=600,height=800');

// 3. In your callback handler, verify status
const status = await fetch('https://payment-stub.yaakdai.net/api/status?session_id=' + session_id);
const { status } = await status.json();

if (status === 'completed') {
  // Payment successful!
}

Yaakdai Payment Stub Test • For Development & Testing Only