Build a sales channel
A sales channel is anything that sells Villa Market goods and has to take money: the web shop, the iOS and Android apps, site.villamarket.ai, the staff payment-link tool, and whatever comes next (a LINE mini-app, a kiosk, a partner site).
villaPayment3 is the one payment backend for all of them. These pages tell a developer, or a coding agent, how to plug a new channel in, and where the customer and the confirmation go after K Bank, MPGS (American Express) or Stripe (Apple Pay) answers.
Open the channel demo: pick a channel, a method and an outcome, then watch every hop, the exact return URL your channel receives, and the code to send. It is a simulation: nothing leaves your browser.
The model in five lines
- Your channel creates the order, then asks villaPayment3 to take the money. For a Villa order the amount is the
server's (
calculate-cost). Only a channel that keeps its own orders (bypass_order) names the amount itself. - The customer pays at the gateway: K Bank (card, Thai QR), MPGS (Amex), Stripe (Apple Pay only).
- The gateway answers on up to two roads: through the customer's browser, and server to server.
- What arrives is a claim. Before an order is marked paid, villaPayment3 has the gateway's own word for it, and then sends the customer back.
- Your channel shows its confirmation screen after checking the result on its own server. The redirect is a hint, never proof.
Where the confirmation goes
This is the routing table. Each row is one way to take a payment, and where the customer's browser ends up.
| Payment | Channel starts it with | Customer lands on | Back on your channel? | Runs on |
|---|---|---|---|---|
| Card · K Bank | POST /cardpayment + callback | {callback}/thankyou?… | Yes: any https URL or app scheme | production, dev (on the current dev stack the bank's return does not arrive: gap 9) |
| Thai QR · K Bank | POST /kbank/order | shop.villamarket.com/thankyou?… | No: always the shop | production, dev |
| Amex · MPGS | villaWalletBackend2 | the wallet backend decides | Not by villaPayment3 | production, dev |
| Apple Pay for Villa orders · Stripe | POST /stripe/applepay | Your Villa checkout page | The page handles confirmation. Redirect fallback is limited to Villa web origins | Live on the Villa shop and available on dev |
| Apple Pay for site orders · Stripe | POST /stripe/applepay/site | Your site's confirmation page | Yes, for the configured HTTPS origin | Current dev stack only, with Stripe test keys |
| All four · hosted checkout | POST /checkout/sessions | /checkout/return/{sessionId} | Yes, on the current dev stack (registry on since 1 Dec 2026): to the registered channel's own page, see Return to the channel. Not on production | dev branch |
What decides "paid" is never what the browser posts. It is the gateway's own word: K Bank's charge answer, its
inquiry or its checksummed notify; MPGS RETRIEVE ORDER; Stripe's PaymentIntent or signed webhook.
Confirmation routing has every hop, method by method.
Availability as of 2 Dec 2026. For rollout gates and known issues, see Gaps and what is next.
Pick your integration
| Your channel | Use | Why |
|---|---|---|
| Sells Villa orders, wants card today, on production | Direct card with callback | The only path that is live on production and returns the customer to you |
| Sells Villa orders, wants every method with one integration | Hosted checkout | One call, four methods, bulk payments; villaPayment3 owns the page. Dev branch only |
| Staff sends a customer a link | Hosted checkout link (POST /checkout/links) | No order id in the link, expires, cancellable |
| A partner (a hotel, say) wants its own shop served by Villa | Launch a shop on the hosted checkout | One build registers the channel, gives it a return page and checks it. Two test shops launched and paid through on dev (1 Dec 2026); none on production |
| Keeps its own orders (not in Villa's order table) | Direct card or site Apple Pay, with the signed server callback | Card callbacks are on for the configured production site. Site Apple Pay is test-only on current dev |
| Already has a Villa web page and wants Apple Pay only | POST /stripe/applepay (Apple Pay guide) | Stripe is Apple Pay only |
Base URLs
Every stack has two APIs behind CloudFront.
| Stack | MainApi: your channel calls it |
|---|---|
Production (master) | https://shop.villamarket.com/api/payment3api |
| Staging (older dev stack, see below) | https://villa.kitchen/api/payment3devapi |
| Development (the same older dev stack) | https://dev.villamarket.net/api/payment3devapi |
Current dev stack (dev) | https://rj1mf23lu0.execute-api.ap-southeast-1.amazonaws.com/Prod |
The gateways call CallbackApi on the same hosts: /api/payment3 on production, /api/payment3dev on dev.
Older pages also show https://shop.villamarket.com/api/payment3devapi for dev; it reaches the same stack as the
two dev rows above.
All three dev addresses reach an older dev stack, last deployed on 4 Oct 2026. It has the direct card, Thai QR,
Amex and Apple Pay flows as they were then and no hosted checkout: /checkout/... answers 403
(Missing Authentication Token) on every one of them.
The current dev stack has hosted checkout, the channel registry, the signed server callback and site Apple Pay
with test keys. It uses the API Gateway address above, not the older CloudFront addresses.
After 3-D Secure, K Bank sends the customer's browser to the older stack
(gap 9): a hosted checkout payment is confirmed all the same (open /checkout/return/{sessionId}), a
direct card payment does not finish by itself.
So today: test the direct card flow on the addresses above; for anything under /checkout, replace
https://villa.kitchen/api/payment3devapi in the examples with the current dev stack's MainApi address.
The pages in this section
| Page | Read it when |
|---|---|
| Quickstart | You want a channel paying in an hour |
| Confirmation routing | You need the exact hops for one gateway |
| The return contract | You are writing the screen the customer comes back to |
| Return to the channel | You want the hosted checkout to send the customer back to you (the channel registry) |
| Launch a shop | A new shop needs a channel id and a return page, in one step |
| Signed server callback | Your channel keeps its own orders |
| Apple Pay (Stripe) | You need to distinguish Villa-order and site-order Apple Pay |
| Testing a channel | Before you ask for a production go-ahead |
| For coding agents | You are an agent, or you are briefing one |
| Gaps and what is next | Something in the table above says "No" |
Machine-readable copy of this contract: /channels/channel-contract.json.
Short index for language models: /llms.txt.