Checkout API
API for managing payments and subscriptions
Endpoints
Create Checkout Session
Create a checkout session
http
POST /api/rpc/checkout/createBody
json
{
"bookingId": "booking_123",
"paymentMethod": "card",
"amount": 500,
"currency": "THB"
}Response
json
{
"sessionId": "cs_123",
"url": "https://checkout.stripe.com/cs_123"
}Payment Cards
Manage credit cards
http
GET /api/rpc/user/payments/list
POST /api/rpc/user/payments/add
DELETE /api/rpc/user/payments/:idSubscriptions
Manage subscriptions
http
GET /api/rpc/user/paymentsSubscriptions/list
POST /api/rpc/user/paymentsSubscriptions/create
DELETE /api/rpc/user/paymentsSubscriptions/cancelStripe Webhook
Receive notifications from Stripe
http
POST /api/stripe-webhookExample Code
typescript
// Create checkout session
const session = await fetch('/api/rpc/checkout/create', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
bookingId: 'booking_123',
paymentMethod: 'card',
amount: 500,
currency: 'THB',
}),
});
// Add credit card
await fetch('/api/rpc/user/payments/add', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
token: 'tok_visa',
setDefault: true,
}),
});