Skip to main content

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.

See it move first

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​

  1. 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.
  2. The customer pays at the gateway: K Bank (card, Thai QR), MPGS (Amex), Stripe (Apple Pay only).
  3. The gateway answers on up to two roads: through the customer's browser, and server to server.
  4. 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.
  5. 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.

PaymentChannel starts it withCustomer lands onBack on your channel?Runs on
Card · K BankPOST /cardpayment + callback{callback}/thankyou?…Yes: any https URL or app schemeproduction, dev (on the current dev stack the bank's return does not arrive: gap 9)
Thai QR · K BankPOST /kbank/ordershop.villamarket.com/thankyou?…No: always the shopproduction, dev
Amex · MPGSvillaWalletBackend2the wallet backend decidesNot by villaPayment3production, dev
Apple Pay for Villa orders · StripePOST /stripe/applepayYour Villa checkout pageThe page handles confirmation. Redirect fallback is limited to Villa web originsLive on the Villa shop and available on dev
Apple Pay for site orders · StripePOST /stripe/applepay/siteYour site's confirmation pageYes, for the configured HTTPS originCurrent dev stack only, with Stripe test keys
All four · hosted checkoutPOST /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 productiondev 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 channelUseWhy
Sells Villa orders, wants card today, on productionDirect card with callbackThe only path that is live on production and returns the customer to you
Sells Villa orders, wants every method with one integrationHosted checkoutOne call, four methods, bulk payments; villaPayment3 owns the page. Dev branch only
Staff sends a customer a linkHosted checkout link (POST /checkout/links)No order id in the link, expires, cancellable
A partner (a hotel, say) wants its own shop served by VillaLaunch a shop on the hosted checkoutOne 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 callbackCard 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 onlyPOST /stripe/applepay (Apple Pay guide)Stripe is Apple Pay only

Base URLs​

Every stack has two APIs behind CloudFront.

StackMainApi: 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.

Two dev stacks: which one answers (measured 1 Dec 2026)

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​

PageRead it when
QuickstartYou want a channel paying in an hour
Confirmation routingYou need the exact hops for one gateway
The return contractYou are writing the screen the customer comes back to
Return to the channelYou want the hosted checkout to send the customer back to you (the channel registry)
Launch a shopA new shop needs a channel id and a return page, in one step
Signed server callbackYour channel keeps its own orders
Apple Pay (Stripe)You need to distinguish Villa-order and site-order Apple Pay
Testing a channelBefore you ask for a production go-ahead
For coding agentsYou are an agent, or you are briefing one
Gaps and what is nextSomething in the table above says "No"

Machine-readable copy of this contract: /channels/channel-contract.json. Short index for language models: /llms.txt.