Skip to main content

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):

APICloudFront 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​

RouteAuthFunctionPurpose
POST /checkout/linksstaff key (x-api-key)CheckoutPayment link for 1-50 orders (CHECKOUT_API.md)
GET, DELETE /checkout/links/{sessionId}staff keyCheckoutSee / cancel a link
POST /checkout/sessionsCognitoCheckoutThe signed-in customer pays their own order(s)
/checkout/pay/{token}..., /checkout/return/..., /checkout/status/..., /checkout/assets/...the link tokenCheckoutThe hosted payment page and its steps
POST /cardpayment (and /cardtoken)noneCardPaymentK Bank card charge from the storefront's K Bank form (card-payments)
POST /kbank/ordernoneKBankCreateOrderK Bank QR order for a storefront order (qr-payments)
GET /kbank/usernoneKbankGetUserK Bank customer of the signed-in user
POST /stripe/applepayCognitoStripeApplePayConfirmStorefront Apple Pay: quote, then server-side confirm (STRIPE_APPLE_PAY.md)
POST /stripepaymentintentCognitoStripePaymentIntentOlder client-confirmed Apple Pay flow (kept for pages built on it)
POST /stripe/webhookStripe signatureStripeWebhookStripe events
POST /stripe/canaryStripe signatureStripeCanaryStripe delivery heartbeat
POST /stripe/testorderCognitoStripeStagingTestOrderTest order for Apple Pay (not on master)
POST /calculatecostnoneCalculateCostPrice an order
POST /send_confirmation_emailnoneSendPaymentConfirmationSend an order's confirmation e-mail
GET /tablesCognitoTableListLambdaList 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.

RouteCalled byFunctionPurpose
POST /callbackthe payer's browser, after K Bank 3-D SecureCallbackCard result; verified with a K Bank charge inquiry (callback)
POST /notifyK Bank, server to serverNotifyCard result; checksum, then fast acknowledgement and DelayedNotify
POST /thaiqr/notifyK BankQRNotifyThai QR result
POST /qrcallbackthe storefront after a QR paymentQRCallbackThai QR result (verified with K Bank)
POST /amex/callbackvillaWalletBackend2 (signed)AmexCallbackAmex result; MPGS confirms before the order is marked paid
POST /wallet/callbackvillaWalletBackend2WalletCallbackWallet payments
POST /bankapp/callbackbank app flowBankAppCallbackBank-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).