Apple Pay (Stripe)
Apple Pay is the only payment Villa takes through Stripe. Every other card still goes through K Bank. Status as of 2 Dec 2026.
What is live
| Shop (shop.villamarket.com) | Site with its own orders (site.villamarket.ai) | |
|---|---|---|
| Apple Pay offered | Live since 2 Dec 2026. The Apple Pay button fix is pending | API enabled on current dev with test keys (PR #259). Production is off (PR #258) |
| Who prices the order | villaPayment3, from the Villa order | The site (same trust model as bypass_order cards) |
| How the order becomes paid | Stripe webhook, then villaPayment3 marks the Villa order paid | Signed server callback to the site (Signed server callback) |
| Stripe mode | Live, THB | Test only, THB |
The first live Apple Pay payment on the shop was 12 THB on 2 Dec 2026, about 08:19 Bangkok time. It was charged, recorded by the webhook, and the order was marked paid about 5 seconds later.
Rules every client must follow
- 10 baht minimum. Stripe refuses a THB payment under 1000 satang: the Apple Pay button never loads. Hide Apple Pay, or say "Apple Pay needs an order of at least 10 baht", below that amount.
- Card-only Elements. Create Stripe Elements with
{ mode: "payment", amount, currency: "thb", paymentMethodTypes: ["card"] }. Apple Pay is a card wallet, and the server creates the PaymentIntent withpayment_method_types: ["card"]. (The server also accepts a token collected in automatic mode, so a page built before this rule still works.) - Only Apple Pay. The Express Checkout element shows Apple Pay only (
applePay: "always", every other wallet"never"). The server refuses any token that is not an Apple Pay card. - The order read back is the only proof. A 200 from the confirm call is not proof of payment. After Apple Pay closes, read the order every 2 seconds for up to about 60 seconds and continue to the thank-you page as soon as it reads paid. Never tell the shopper to pay again while the outcome is unknown.
- Browsers. Safari on iPhone, iPad and Mac pays directly. Chrome or another browser on a computer can pay too: Stripe shows a QR code to finish on an iPhone. Android cannot use Apple Pay.
Shop flow
browser villaPayment3 (/stripe/applepay, Cognito) Stripe
| POST {orderId} | |
|------------------------------------->| prices the Villa order |
|<-------------- {publishableKey, amount, currency} |
| Elements + Apple Pay sheet ------------------------------------------------------>| confirmation token
| POST {orderId, confirmationTokenId, expectedAmount} |
|------------------------------------->| claim order, check Apple Pay, create+confirm PaymentIntent
| |------------------------------------------>|
| |<---------- webhook payment_intent.succeeded
| | mark the Villa order paid |
| read the order until paid, then /thankyou |
Codes the confirm call can answer: 200 (submitted: still read the order), 402 card_declined,
402 action_unsupported, 409 price_changed (get a new quote), 409 payment_attempt_exists or
order_already_paid (read the order), 400 not_apple_pay, 400 token_invalid, 502 payment_outcome_unknown
(read the order, do not pay again), 503 apple_pay_unavailable.
Sites with their own orders
Use POST /stripe/applepay/site if your site owns its orders. This route does not use Villa sign-in.
Your server authorizes the order and signs the request details. The browser only forwards the ticket.
| Environment | Base URL and availability |
|---|---|
| Current dev | https://rj1mf23lu0.execute-api.ap-southeast-1.amazonaws.com/Prod. Uses Stripe test keys. /Prod is the API stage name, not the payment mode. |
| Production | Not yet enabled. End-to-end testing and an approved live change window are still required. |
Use your exact configured HTTPS origin with no trailing slash. If the browser sends an Origin header,
it must equal callbackOrigin. CORS allows configured origins only. Request bodies are limited to 4096 bytes.
Quote
Send the order ID, the total in integer satang (1000–99999999), lowercase thb, your origin and the issued
siteTicket. Do not send a token yet.
{
"orderId": "ORDER-1234",
"amountSatang": 7400,
"currency": "thb",
"callbackOrigin": "https://staging.site.villamarket.ai",
"siteTicket": "<site-signed ticket>"
}
A successful quote returns {"publishableKey":"pk_test_...","amount":7400,"currency":"thb"}.
Use it to initialize Stripe Elements. The quote does not create a PaymentIntent or read a Villa order.
Confirm
Post the same fields to the same endpoint with the Stripe ConfirmationToken from Apple Pay.
Do not send expectedAmount or expect a client secret.
{
"orderId": "ORDER-1234",
"amountSatang": 7400,
"currency": "thb",
"callbackOrigin": "https://staging.site.villamarket.ai",
"siteTicket": "<site-signed ticket>",
"confirmationTokenId": "ctoken_..."
}
A successful submission returns {"status":"succeeded","paymentIntentId":"pi_...","orderId":"ORDER-1234"}.
It can also return "status":"processing". Neither status marks the site's order paid.
Stripe's only redirect target is <callbackOrigin>/thankyou?orderId=<URL-encoded id>.
Read payment state from your own order API. Your server receives the verified result through the
signed server callback.
Sign the pay ticket
Authorize the order on your server. Read its ID and total from your persisted order.
Sign with the shared callback hmacSecret for that exact configured origin. Do not send the secret to the browser.
Both quote and confirm require a ticket. There is no legacy mode without one.
- Make compact UTF-8 JSON with exactly seven keys.
vis the integer1.amountSatangandexpare integers.orderId,currency,originandattemptare strings. Use uppercaseTHBin the ticket, even though the POST body uses lowercasethb. The order ID, amount and origin must match the POST. - Set
expin Unix seconds. Issue tickets withinnow < exp <= now + 3600. With clock skew, the verifier acceptsnow - 60 < exp <= now + 3660. - Encode the JSON as unpadded base64url
B. ComputeSas lowercase hex HMAC-SHA256 with the UTF-8 secret as the key and"site-pay-ticket.v1." + Bas the message. SendB + "." + SassiteTicket(at most 1024 characters).
attempt is for audit only. The Stripe claim is keyed by branch, origin and order ID. A new ticket does not
bypass an active or paid claim. An earlier Stripe intent can be replaced only after zero-capture cancellation
is proven. This claim does not lock payments on other providers.
Test vector with the dummy key test-secret-do-not-use and verifier time 1700000000. Encode this exact
payload without a trailing newline:
{"v":1,"orderId":"ORDER-1","amountSatang":7400,"currency":"THB","origin":"https://site.example.com","attempt":"attempt-1","exp":1700000300}
Expected siteTicket:
eyJ2IjoxLCJvcmRlcklkIjoiT1JERVItMSIsImFtb3VudFNhdGFuZyI6NzQwMCwiY3VycmVuY3kiOiJUSEIiLCJvcmlnaW4iOiJodHRwczovL3NpdGUuZXhhbXBsZS5jb20iLCJhdHRlbXB0IjoiYXR0ZW1wdC0xIiwiZXhwIjoxNzAwMDAwMzAwfQ.1e194eedc46d71b380897327cdc9edbe2e25df90aeb5ae30803c03f0285b1bf1
Site endpoint errors
| HTTP | Code | What to do |
|---|---|---|
| 400 | invalid_request | Check the JSON and fields. |
| 400 | amount_below_minimum | Do not offer Apple Pay under THB 10. |
| 400 | not_apple_pay, token_invalid | Collect a valid Apple Pay token. |
| 402 | card_declined, action_unsupported, attempt_not_sent | The response has status: declined. A fresh ticket, quote and token are allowed. |
| 403 | site_ticket_invalid | The ticket is missing, invalid or for an unconfigured origin. The response is only {"code":"site_ticket_invalid"}. No Stripe call or claim access happens. |
| 403 | origin_not_configured | Check the configured origin and the browser Origin header. |
| 405 | method_not_allowed | Use POST. |
| 409 | payment_attempt_exists | An attempt is active or already paid. Read the order and wait for the callback or ask staff to reconcile. |
| 413 | request_too_large | Keep the body to 4096 bytes or less. |
| 502 | payment_outcome_unknown, payment_service_unavailable | Read the order and wait for the callback or ask staff to reconcile. |
| 503 | apple_pay_unavailable, claim_unavailable | Apple Pay setup or the claim store is unavailable. |
After any 409 payment_attempt_exists or any 502, do not start another attempt, even with a different
payment method. Never ask the shopper to pay again while the outcome is unknown.