{"object":"doc","slug":"collect","title":"The hosted card form","summary":"ZeroPoint hosts the card form; your page embeds it in an iframe and receives a one-time nonce over postMessage, so card data never touches your code.","tags":["concept","keyed","collect","security"],"body":"# The hosted card form\n\nKeyed (card-not-present) entry uses a card form that ZeroPoint hosts. Your checkout page embeds it in an iframe; the card number, expiry and security code exist only inside that frame. When the customer submits, the form posts a **nonce** to your page: a one-time reference to that card that you send to `POST /v1/payments` with `method: keyed`. Your page and your server never see the card, and they never load processor code or handle processor identifiers.\n\n## Embedding\n\n`GET /v1/merchants/{merchant_id}/collect-config` returns `form_url`. Put it in an iframe with `?origin=` set to the origin of the page that embeds it (scheme and host, no path):\n\n```html\n<iframe id=\"card\" src=\"https://HOST/collect/mch_01j...?origin=https://shop.example.com\"\n        title=\"Card form\" style=\"width:100%;border:0;height:320px\"></iframe>\n```\n\nThe origin must be `https://`, or `http://localhost` / `http://127.0.0.1` while you develop. The form's `Content-Security-Policy` names that one origin in `frame-ancestors`, so nobody else can frame it, and it posts messages only to that origin.\n\nIf your checkout page sends a Content-Security-Policy, allow the host of `form_url` in `frame-src`. Inside the form, the processor's card fields load from `*.poynt.net` and mount a risk frame from `https://api.sardine.ai` (processor behaviour, VERIFIED 10/18/2026). Any page that hosts those card fields directly must allow both origins in `frame-src`. ZeroPoint's form page allows those frames, the processor's script and its own inline script, and nothing else (`default-src 'none'`).\n\n## Messages\n\nListen for `message` events and check `event.origin` is ZeroPoint's origin (the host part of `form_url`):\n\n| `event.data.type` | Fields | Meaning |\n|---|---|---|\n| `zeropoint.ready` | `merchant_id` | The form loaded; enable your checkout. |\n| `zeropoint.nonce` | `merchant_id`, `nonce`, `card_last4`, `card_brand` | The customer submitted a valid card. Send `nonce` to your server now; `card_last4` and `card_brand` are display-only and may be `null`. On the save form (`save_form_url`) the message also carries `save: true`. |\n| `zeropoint.error` | `merchant_id`, `code`, `messages`, `error_type`, `fields` | One per failed submit. `card_invalid`: the customer's entry failed validation, keep the form open; `recaptcha_declined`: the processor's bot check refused this browser, so no nonce can be made in it; `form_unavailable`: the form could not load or the card could not be checked, ask them to reload. See below. |\n| `zeropoint.resize` | `height` | The form's content height, if you want the iframe to fit it. |\n\nThe form shows its own \"Use this card\" button. To drive it from your page's button instead, add `&button=none` to `form_url` and post `{type: \"zeropoint.tokenize\"}` to the iframe's `contentWindow` with ZeroPoint's origin as the target. After a nonce the form shows \"Card details checked.\" under the fields; when your page shows a failure itself (a decline, the security check, any other error), post `{type: \"zeropoint.clear\"}` the same way and the form clears its own status line under the fields (that line or its own error sentence), so the message shows once, on your page. Nothing else changes, and a submit in progress is never cleared.\n\n```js\nconst frame = document.getElementById('card');\nconst formOrigin = new URL(frame.src).origin;\nwindow.addEventListener('message', (event) => {\n  if (event.origin !== formOrigin) return;\n  const msg = event.data;\n  if (msg.type === 'zeropoint.ready') payButton.disabled = false;\n  if (msg.type === 'zeropoint.nonce') sendToYourServer(msg.nonce);\n  if (msg.type === 'zeropoint.error') showError(msg.code);\n});\npayButton.onclick = () => frame.contentWindow.postMessage({ type: 'zeropoint.tokenize' }, formOrigin);\n```\n\n### Error codes\n\nBranch on `code`. `messages`, `error_type` and `fields` are filled only for `card_invalid`, and may be empty even then.\n\n| `code` | When | What to do |\n|---|---|---|\n| `card_invalid` | The form's own validation refused the entry (a missing or malformed field), or the processor answered the request that mints the nonce with HTTP 400 or 422. | Keep the form open. `messages` holds the form's own validation sentences, for example `Enter a card number` (at most 10, each at most 200 characters), and is empty when the processor refused the request; `error_type` is `missing_fields` or `invalid_details` when the form says which, otherwise `null`; `fields` names the fields at fault (`cardNumber`, `expiryDate`, `cvc`, `zipCode`). The form shows the same sentences below the card fields. |\n| `recaptcha_declined` | The processor's bot check refused the browser (processor code `RECAPTCHA_DECLINED`). Expect it from a browser driven by an automation tool; a real customer may see it too. | `messages` is empty. Ask the customer to try a regular browser window, or offer another way to pay. |\n| `form_unavailable` | The form could not load, or the request that mints the nonce failed without the processor judging the card: a network failure, a processor outage, or any HTTP status other than 400 and 422 (401, 403, 404 and 429 included). Also posted once, on load, when ZeroPoint will not serve card fields for the merchant (card payments held, a mode mismatch, or an account that could not be checked): the frame then shows only \"Card payments are not available for this business.\", and this one message carries `merchant_id: null`. | `messages` is empty. Ask the customer to reload; the card is not at fault, so do not ask them to correct it. If it repeats for one merchant, check that merchant's processor connection. |\n\n`messages` are the processor form's own sentences, observed in English: show them, do not parse them. After a failed submit the form keeps its button off, and ignores `zeropoint.tokenize`, for up to a second and a half while the processor's form finishes; your page needs no handling for that. A code this page does not list may be added later, so treat an unknown `code` like `form_unavailable`. The mapping of `recaptcha_declined` and of a failed nonce request is built from the processor form's code and has not been seen end to end (UNVERIFIED 11/15/2026); the `card_invalid` fields for a missing field were VERIFIED 11/15/2026.\n\nA nonce is single-use and expires within minutes; a reused or stale one comes back as `failure_code: nonce_invalid`. Reload the iframe (set `src` again) after each payment to take the next card.\n\n## Save mode\n\n`collect-config` also returns `save_form_url`: the same form with `save=1`, for saving a card for later charges (`save-a-card`). Its button reads \"Save card\" and its `zeropoint.nonce` message carries `save: true`. Nothing else changes: the fields, the messages, the origin rule and the page policy are the same, the flag binds nothing on the server, and the form shows no terms (the merchant's terms are your page's to show). Wallets cannot be saved, so the save form never offers them.\n\n## Sandbox\n\n`collect-config` also returns `sandbox_form_url`: a stand-alone page that embeds the same form, prints the nonce it receives, and can post the charge with a pasted test key. Use it to see the flow before you have a page of your own. Test card `4761739001010010` with any future expiry and any CVV is approved; `4111111111111111` and `4242424242424242` are declined as `card_declined`, whatever the amount and whether or not the name and ZIP fields are filled. The form collects the cardholder name and ZIP so its nonces carry the same address data a production form would.\n\nProcessor behaviour, VERIFIED 10/18/2026: card tokenization refuses a browser driven by an automation tool with `RECAPTCHA_DECLINED`, headless or headed, and no nonce is produced. A real browser typed into by a person succeeded every time. The form reports the refusal to your page as `zeropoint.error` with `code: recaptcha_declined`. The check is a score, not a fixed rule: on 11/15/2026 one visible Chrome window driven through its debugging port was accepted twice. Automated tests cannot rely on minting nonces, so keep a manual real-browser step in your test plan.","updated":1795275945}