API reference
Every route the stack deploys, from template.yaml. How the routes work
together: ../PAYMENTS.md.
There are two API Gateway REST APIs per stack (stage Prod), both reached
through CloudFront on shop.villamarket.com (production) and
villa.kitchen / dev.villamarket.net (dev):
| API | CloudFront path (master / dev) | Default auth |
|---|---|---|
| MainApi: storefront, checkout, Stripe | /api/payment3api/* / /api/payment3devapi/* | Cognito (the customer's ID token in Authorization) |
| CallbackApi: gateways calling us | /api/payment3/* / /api/payment3dev/* | none (each handler verifies the gateway) |
There is no API-key authentication, no SDK and no /qrpayment route; an
earlier version of this page described ones that never existed.
MainApi
| Route | Auth | Function | Purpose |
|---|---|---|---|
POST /checkout/links | staff key (x-api-key) | Checkout | Payment link for 1-50 orders (CHECKOUT_API.md) |
GET, DELETE /checkout/links/{sessionId} | staff key | Checkout | See / cancel a link |
POST /checkout/sessions | Cognito | Checkout | The signed-in customer pays their own order(s) |
/checkout/pay/{token}..., /checkout/return/..., /checkout/status/..., /checkout/assets/... | the link token | Checkout | The hosted payment page and its steps |
POST /cardpayment (and /cardtoken) | none | CardPayment | K Bank card charge from the storefront's K Bank form (card-payments) |
POST /kbank/order | none | KBankCreateOrder | K Bank QR order for a storefront order (qr-payments) |
GET /kbank/user | none | KbankGetUser | K Bank customer of the signed-in user |
POST /stripe/applepay | Cognito | StripeApplePayConfirm | Storefront Apple Pay: quote, then server-side confirm (STRIPE_APPLE_PAY.md) |
POST /stripepaymentintent | Cognito | StripePaymentIntent | Older client-confirmed Apple Pay flow (kept for pages built on it) |
POST /stripe/webhook | Stripe signature | StripeWebhook | Stripe events |
POST /stripe/canary | Stripe signature | StripeCanary | Stripe delivery heartbeat |
POST /stripe/testorder | Cognito | StripeStagingTestOrder | Test order for Apple Pay (not on master) |
POST /calculatecost | none | CalculateCost | Price an order |
POST /send_confirmation_email | none | SendPaymentConfirmation | Send an order's confirmation e-mail |
GET /tables | Cognito | TableListLambda | List the stack's DynamoDB tables |
CallbackApi
Called by the gateways, not by browsers of ours. Every handler confirms with the gateway before anything is marked paid.
| Route | Called by | Function | Purpose |
|---|---|---|---|
POST /callback | the payer's browser, after K Bank 3-D Secure | Callback | Card result; verified with a K Bank charge inquiry (callback) |
POST /notify | K Bank, server to server | Notify | Card result; checksum, then fast acknowledgement and DelayedNotify |
POST /thaiqr/notify | K Bank | QRNotify | Thai QR result |
POST /qrcallback | the storefront after a QR payment | QRCallback | Thai QR result (verified with K Bank) |
POST /amex/callback | villaWalletBackend2 (signed) | AmexCallback | Amex result; MPGS confirms before the order is marked paid |
POST /wallet/callback | villaWalletBackend2 | WalletCallback | Wallet payments |
POST /bankapp/callback | bank app flow | BankAppCallback | Bank-app payments |
Checkout payments reach /callback, /notify and /thaiqr/notify too (K Bank
uses one set of URLs per merchant); those handlers hand them to the checkout.
Errors
Each function answers in its own shape; the checkout's is documented in
CHECKOUT_API.md. Browser-facing card routes
(/cardpayment, /callback) answer with an HTML redirect to
{callback}/thankyou?orderId=…&status=success|failure… rather than an error
status (callback-url-app-integration).