## Hosted checkout pages

A hosted checkout page sells one dashboard product. The merchant creates the
product in the dashboard (**Payment Links**) and shares its URL; no server
code, no API key and no Payment Intent are involved. Do not try to create or
drive a hosted product payment from code.

### `GET https://checkout.securepayapi.com/<productId>`

#### The URL

| Part | Rule |
| --- | --- |
| `<productId>` | The product id shown by the dashboard: 24–32 characters, lower-case letters and digits. Any other shape answers `404`. |
| Query string | Ignored for money. Price, currency, coupons and live/sandbox come from the product on the server. `?mode=sandbox` (which the dashboard's **Open checkout** link adds for sandbox products) changes nothing. |

- Never build a checkout URL that tries to set an amount, currency, discount or
  mode. Nothing in the URL can change what is charged.
- Share the URL exactly as the dashboard gives it.

#### When the page answers 404

- The id is malformed or unknown.
- The product is **archived** or was **deleted**.
- The merchant account is not active.

The page is rendered fresh on every request (never cached): archiving or
re-activating a product takes effect on the next load.

#### What the shopper sees

| Element | Source and limit |
| --- | --- |
| Store name | The merchant's registered business name (up to 120 characters), else "Store" |
| Website, support email | From the merchant's account profile, each shown only when set |
| Product name | Up to 200 characters |
| Description | The first 2,000 characters |
| Image | The **first** product image only; also the link-preview image |
| Features | Up to 20 lines; a line longer than 200 characters is dropped |
| Price | The product price in the product currency |
| Discount-code field | Only when the product has at least one coupon |
| Test-mode banner | "Test mode — sandbox · no real charge" on a sandbox product |

The page title for link previews is `<product name> · <store name> · securepayAPI`;
the preview description is the product description, else
`Pay for <product name> at <store name>.`

#### The payment form

| Field | Rule |
| --- | --- |
| Email | Required for a card payment: a valid address, up to 254 characters. Optional for Apple Pay. |
| Cardholder name | 1–64 characters: letters, digits, spaces, `'`, `.`, `:`, `-` |
| Card number, expiry (`MM/YY`), CVC | Entered in the page; never reach the merchant |
| Billing address | Optional. Street, house number, city, 2-letter state, postal code (up to 10 characters), 2-letter country. A malformed field is dropped, not refused. |
| Discount code | Optional; see [Coupons](#coupons) |

#### Pricing — decided on the server

1. `subtotal` = the product price.
2. The typed code is trimmed and upper-cased and looked up in the product's
   coupons. Unknown or empty → no discount, no error.
3. Known code with `p` percent → `discount = round(subtotal × p / 100, 2)`.
4. `total = max(0, subtotal − discount)`, two decimals. No tax is ever added.

The total is recomputed on the server when the payment starts, from the
product as stored at that moment. The browser cannot change it.

#### Wallets

| Wallet | On product pages |
| --- | --- |
| Apple Pay | Offered on a device that can open an Apple Pay sheet, when the payment can be prepared. The sheet shows the same server total; applying or removing a code, or changing the email, prepares the payment again. |
| Google Pay | **Not offered.** Google Pay exists in the embedded widget and, where enabled, on hosted invoices. |

The card form is always present. Only one payment runs per page: while Apple
Pay or a card attempt is running, the other cannot start.

#### Outcomes on the page

| What the shopper sees | Meaning | Merchant action |
| --- | --- | --- |
| "Thank you — your payment went through." | Captured | Fulfil from the webhook or the transaction, not from the shopper's word |
| An error message with the form still available | Declined or refused before capture; nothing charged | None; the shopper may retry |
| "Being confirmed … Do not pay again", with a reference | Outcome not known yet; money may have moved | Look the reference up before asking for any new payment |

The uncertain state is remembered in that browser: a reload does not bring the
pay button back. There is no redirect and no success URL after payment.

#### How the merchant learns the outcome

- **Webhooks.** Each status change of the payment's transaction is sent to the
  merchant's webhook endpoint. For a hosted product payment, `externalid` and
  `externalReference` are the **product id**. Fulfil on status `1` (`PAID`) or
  `20` (`SETTLED`), whichever arrives first.
  Treat `16` (`PAYING`) as "capture sent, not final": neither paid nor unpaid.
  `3` (`FAILED`) ends that attempt.
- **Transaction lookup.** `GET https://app.securepayapi.com/api/v1/transactions/{id}`
  with the secret key, using the webhook's `id`, returns the amount, currency,
  status and card details. Read it before fulfilling when in doubt.
- **Dashboard.** The payment appears under **Transactions** in the cabinet of
  the product.

There is no Payment Intent for a hosted product payment: do not call
`GET /api/v1/payment-intents/{id}` for it, and do not expect `notify_url`.

#### Sandbox

A product created while the dashboard is in **Sandbox** is a sandbox product: it
charges through the test processor, shows the test-mode banner and takes no
real money. A live product always charges live. The URL cannot move a product
between the two. Use the sandbox test cards on a sandbox product.

#### Do not

- Do not call the page's own internal endpoints (price quote, card
  submission). They are not an API, are protected against cross-site use, and
  change without notice.
- Do not embed the product page in an iframe on another site; use the embedded
  widget for checkout inside your own page.
- Do not promise customisation of the hosted page (logo, colours): it shows
  the store name and the product only.

## Products and coupons

Products are created and managed in the dashboard (**Payment Links**). There is
no public API for products: do not generate code that creates, edits or lists
them.

### Product fields

A product is created in the dashboard's current cabinet (**Live** or
**Sandbox**) and stays there; each cabinet lists only its own products.

| Field | Required | Dashboard accepts | What the checkout does | Effective rule |
| --- | --- | --- | --- | --- |
| Name | yes | 1–200 characters (trimmed) | Shows up to 200 | ≤ 200 |
| Description | no | up to 5,000 characters | Shows the first 2,000 | ≤ 2,000 to be fully visible |
| Price | yes | a number from 1.00 to 1,000,000,000, rounded to 2 decimals | Charges it (minus a coupon) | 1.00 – 1,000,000,000 |
| Currency | yes | `USD`, `EUR` or `GBP` | Charges in that currency | as accepted; confirm non-USD processing with support before use |
| Images | no | up to 5 uploads; JPEG, PNG or WEBP; ≤ 2 MB each | Shows the first only | first image matters |
| Features | no | up to 20 lines, each up to 300 characters | Drops any line over 200 characters | ≤ 20 lines × 200 characters |
| Coupons | no | up to 5 codes | Applies one per payment | see [Coupons](#coupons) |
| Category | no | `digital`, `physical`, `service`, `other` | Not used | informational |
| Unit label | no | up to 50 characters | Not shown | informational |
| Tax behavior | no | `auto`, `inclusive`, `exclusive` | **No tax is applied** | no effect |
| Metadata | no | up to 20 string pairs; key ≤ 80, value ≤ 500 characters | Not used | informational |

Dashboard errors on create: `Name is required`; `Amount must be at least 1.00`
(also shown for a price above 1,000,000,000); `Currency is required`. Image
upload errors: `Unsupported image type. Use JPEG, PNG, or WEBP.`;
`Image is larger than 2 MB.`

### Coupons

A coupon maps a **code** to a **whole percentage off**.

| Rule | Value |
| --- | --- |
| Percentage | Integer 1–100. Outside the range → the coupon is dropped on save. A fraction is truncated (`20.5` → `20`). |
| Characters | `A–Z`, `0–9`, `_`, `-`. Stored upper-cased; any other character (space, `%`, `.`) is **removed** on save, so `SUMMER 20` becomes `SUMMER20`. |
| Length | **≤ 32 characters.** The dashboard accepts up to 50, but the checkout refuses a code longer than 32 when the payment starts: the page shows the discount, then the payment is rejected. Never create a code longer than 32. |
| Count | ≤ 5 per product. Extra codes are dropped on save. |
| Matching | Case-insensitive; surrounding spaces ignored. An unknown code gives no discount and no error. |
| Stacking | One code per payment. |
| 100 % | Brings the total to `0.00`, but the checkout still runs a payment for that total, which is not guaranteed to complete. Do not use 100 % codes to give products away. |

### Status and lifecycle

| Action | Effect |
| --- | --- |
| Create | Status `active`; the checkout URL works immediately. |
| Archive | Status `archived`; the checkout URL answers `404`. |
| Re-activate | Status `active`; the same URL works again. |
| Delete | Permanent; the product and its images are removed and the URL answers `404` forever. |
| Edit | **Not available.** Only the status can change after creation. To change price, currency, coupons or content, create a new product and share its new URL. |

## Hosted invoices: bank and USDC pay-ins

A hosted invoice is paid on
`https://checkout.securepayapi.com/?invoice=<invoice-id>`. The invoice id is a
UUID; the link is issued when the invoice's payment link is enabled. This
chapter covers what the shopper sees and what the merchant must rely on.
Creating invoices from a server, and reading their bank or USDC state, belongs
to the private direct-integration contract; do not invent public endpoints for
it.

### The invoice link

- Share the link exactly as issued. Add nothing to it: the amount, currency and
  payable state come from the invoice on the server.
- `?lang=` (or the browser language) chooses the page language.
- A malformed invoice id shows "Invalid invoice link".
- The page never shows the merchant's credentials and needs none from the
  shopper.

#### What the page shows

| Invoice state | Page |
| --- | --- |
| open, link enabled, not expired | Payable: the enabled payment methods |
| open, link expired | "Expired" — not payable |
| open, link disabled | Not payable |
| open, a bank attempt pending / submitted / held | That attempt's status and instructions instead of payment methods |
| paid | Paid summary (for USDC: sender address, transaction hash, explorer link) |
| void, superseded | Not payable |

#### Payment methods per invoice

| Method | Offered when |
| --- | --- |
| Card | The invoice is payable (a USDC-only merchant setup offers no card) |
| Apple Pay, Google Pay | The platform reports them available for this invoice |
| ACH debit | USD invoice, and ACH debit is enabled for the merchant and environment |
| ACH transfer, wire | USD invoice, and the rail is enabled for the merchant and environment |
| USDC | USD or USDC invoice created with USDC enabled, and USDC pay-ins are available for the merchant |

Invoices created in the dashboard can be in `USD`, `EUR`, `GBP`, `CAD` or `AUD`
(amount up to 9 digits with up to 2 decimals, description up to 200
characters), have their payment link on by default, and never have USDC
enabled — the dashboard form has no USDC option.

Only one payment method can be in progress per invoice. Never prompt a shopper
for a second method while one is pending.

### Bank pay-ins

#### ACH debit

1. The shopper enters the account holder name (1–80 characters), account
   number (4–17 digits), routing number (exactly 9 digits), account type
   (`checking` or `savings`) and holder type (`personal` or `business`).
2. The page shows a **one-time debit authorization** naming the merchant, the
   amount and a contact email. The shopper must accept it explicitly.
3. The debit is submitted. Only the last four digits of the account are kept.

A debit cannot be cancelled from the page. If it is declined, the attempt is
`failed` and the invoice is payable again.

#### ACH transfer and wire

The page shows the instructions to send from the shopper's own bank:

| Instruction | Meaning |
| --- | --- |
| Account name, bank name, account number, routing number | The receiving account |
| Reference | Put it in the transfer memo; it identifies the payment |
| Amount | The total to send |
| Recipient address, bank address | Wire only |

Amount rules — must be correct everywhere:

- The amount to send **equals the invoice amount**. No fee is added for the
  payer on either rail: the pass-through fee is always `0.00`.
- Any incoming bank fee is borne by the merchant: it may reduce the credit the
  merchant receives, never the amount the shopper sends.
- Tell the shopper to send exactly the amount shown, with the reference. A
  transfer that arrives for a different amount is `held`, not applied.

A pending transfer can be cancelled on the page only when the shopper confirms
the funds were **not sent**. The invoice becomes payable again. Cancelling is
not a recall: a transfer that arrives after cancellation is recorded as late
and does not pay the invoice.

#### Bank statuses

| Status | Meaning | Invoice | Fulfil? |
| --- | --- | --- | --- |
| `pending` | Attempt recorded; transfer awaiting funds, or debit not yet accepted | open, not payable | no |
| `submitted` | Debit accepted by the bank provider | open, not payable | no |
| `confirmed` | Matching funds arrived | **paid** | yes — and keep watching |
| `held` | Funds arrived for a different amount, or could not be applied | open, not payable | no — needs operator resolution |
| `failed` | Debit refused or failed before money moved | open, payable again | no |
| `returned` | The bank returned the debit or transfer, also after `confirmed` | a paid invoice is **reopened** | reverse fulfilment |
| `canceled` | Unused transfer instructions retired by the shopper | open, payable again | no |

### USDC pay-ins

| Instruction | Rule |
| --- | --- |
| Network | Polygon in production; Polygon Amoy in sandbox. Use the network shown, never infer it from the currency. |
| Token | USDC |
| Deposit address | The address shown for this invoice |
| Amount | The invoice amount; a USD invoice is taken 1 USDC = 1 USD |
| Expiry | About one hour by default, never more than 24 hours, never after the invoice link's expiry |

- The shopper asks for instructions on the page. While a set is still awaiting
  payment, the page shows it rather than issuing another; after expiry, the
  shopper asks again for a new set. Reloading the page does not renew expired
  instructions.
- Instruction statuses: `awaiting_payment`, `expired`, `paid`.
- Never send against expired instructions, on another network, or a second
  time to fix an uncertain first transfer. Late, wrong-network or mismatched
  transfers need operator resolution; there is no automatic recovery.
- Very small amounts can be refused when network costs would consume the
  payment.

### How the merchant learns the invoice outcome

| Method used | Signal | Rule |
| --- | --- | --- |
| Card, Apple Pay, Google Pay | Transaction webhooks carrying the `invoice` id; the invoice turns `paid` | Fulfil when the invoice is `paid` (or the transaction is `PAID`) |
| USDC | A transaction webhook when the invoice is paid; the invoice turns `paid` | Fulfil when the invoice is `paid` |
| ACH debit, transfer, wire | **No webhook to rely on.** The invoice turns `paid` on `confirmed` | Check the invoice status (dashboard **Invoices**, or the private invoice contract) |

### Never assume

- Instructions shown, a debit submitted, a transfer sent, or a wallet
  "success" screen is **not** a paid invoice.
- `confirmed` is not final forever: a bank return can reopen a paid invoice.
- `held` is not paid and is not resolved by asking the shopper to pay again.
- A cancelled transfer that later arrives does not pay the invoice.
- Bank pay-ins are USD only; USDC needs a USD or USDC invoice with USDC enabled
  at creation; neither exists on product pages, the widget or Payment Intents.
- Do not generate code that calls bank, USDC or invoice routes from a browser,
  or that puts merchant secrets in an invoice URL.
