{"object":"doc","slug":"accept-a-keyed-payment","title":"Accept a keyed (card-not-present) payment","summary":"Embed the hosted card form, get a one-time nonce in the browser, and charge it with one request that returns the final result.","tags":["guide","payments","keyed","collect"],"body":"# Accept a keyed (card-not-present) payment\n\nCard numbers never reach your server or your page. The browser hands the card to a form that ZeroPoint hosts, the form posts a one-time `nonce` to your page, and you post the nonce to us.\n\n## 1. Fetch the form configuration\n\n```\nGET /v1/merchants/{merchant_id}/collect-config\n```\nResponse `200`:\n```json\n{\"object\":\"collect_config\",\"merchant_id\":\"mch_01j...\",\"form_url\":\"https://HOST/collect/mch_01j...\",\"sandbox_form_url\":\"https://HOST/sandbox/collect?merchant_id=mch_01j...\",\"test_cards\":[{\"brand\":\"visa\",\"number\":\"4761739001010010\",\"expiry\":\"12/30\",\"cvv\":\"123\",\"outcome\":\"approved\"},{\"brand\":\"visa\",\"number\":\"4111111111111111\",\"expiry\":\"12/30\",\"cvv\":\"123\",\"outcome\":\"declined, failure_code card_declined\"}]}\n```\nA `503 sandbox_processor_unconfigured` means this sandbox has no processor account yet; simulated terminals still work.\n\n## 2. Embed the form (or use the sandbox page)\n\nA nonce can only be produced by the card form running in a real browser: there is no fixed sandbox nonce and no server-side endpoint that hands one back. If you are an agent without a browser, open `sandbox_form_url` in a real browser and have a person type a test card (a browser driven by an automation tool is refused with `RECAPTCHA_DECLINED`, gets no nonce, and the form reports `recaptcha_declined`), press \"Use this card\", copy the nonce the page shows, and post it with curl as shown in step 3. On the form, type the expiry as `MM/YY` with the slash (`1230` typed without it is rejected as `card_invalid`) and clear the ZIP field if it is pre-filled; the sandbox page shows the form's own messages next to the code, for example `card rejected: card_invalid (Enter a card number; Enter a CVV)`. In your own checkout page, embed `form_url` in an iframe and listen for its message:\n\n```html\n<iframe id=\"card\" src=\"FORM_URL?origin=https://shop.example.com&button=none\"\n        title=\"Card form\" style=\"width:100%;border:0;height:320px\"></iframe>\n<button id=\"pay\" disabled>Pay</button>\n<script>\n  const frame = document.getElementById('card');\n  const formOrigin = new URL(frame.src).origin;\n  window.addEventListener('message', (event) => {\n    if (event.origin !== formOrigin) return;\n    const msg = event.data;\n    if (msg.type === 'zeropoint.ready') pay.disabled = false;\n    if (msg.type === 'zeropoint.nonce') sendToYourServer(msg.nonce);\n    if (msg.type === 'zeropoint.error') showError(msg.code);\n  });\n  pay.onclick = () => frame.contentWindow.postMessage({ type: 'zeropoint.tokenize' }, formOrigin);\n</script>\n```\n`origin` is the scheme and host of the page that embeds the form (https, or http://localhost while developing); the form only posts to that origin and can only be framed by it. Leave out `&button=none` to use the form's own button. The `collect` concept page lists every message.\n\n## 3. Charge the nonce\n\n```\nPOST /v1/payments\n{\"merchant_id\":\"mch_01j...\",\"amount_cents\":4900,\"currency\":\"usd\",\"platform_reference\":\"inv-2044\",\"method\":\"keyed\",\"nonce\":\"<from the browser>\",\"description\":\"Monthly membership\"}\n```\nThis call requires an `Idempotency-Key` header, like every POST that creates something. Response `201` with a final `state`:\n- `succeeded`: paid; `processor_transaction_id`, `card_last4`, `card_brand`, `receipt_url` are set.\n- `failed` with `failure_code: card_declined` or `nonce_invalid` (expired or reused nonce; get a fresh one) or `processor_rejected` (the processor refused the request as invalid; not a card decline) or `processor_unverified` (the processor answered with a status we do not recognize; verify with support before retrying. Also the result when the processor declined or refused the sale on a retry of a `pending` payment, after a network re-send, or in an answer read back from its records: the first attempt may have been charged.) or `partial_approval` (the card approved only part of the amount; we voided that partial sale, since ZeroPoint never accepts a partial approval: show a decline and ask for another card or a smaller amount, and do not retry the same card for the same amount). Every keyed charge is sent to the processor with `partialAuthEnabled: false`, asking it not to approve part of the amount. The processor documents the field but not its effect (https://docs.poynt.com/api-reference/index.html, model \"Transaction\"); the sandbox processor accepted and echoed it on 11/17/2026, but whether it prevents a partial approval is still unverified. A partial approval that still comes back is declined and voided as above, and a physical terminal has no such field, so detection and the void remain the backstop there. A `card_declined` or `processor_unverified` payment carries `processor_transaction_id` when the processor returned an id for the attempt. That id names the processor's row, not a charge: only `state: succeeded` means money moved.\n\nA `502 processor_unavailable` means the network did not answer, or answered without deciding the sale (a timeout, a throttle, an authorization refusal). Retry the same request with the same `Idempotency-Key`; the payment stays `pending` on our side and the retry resumes that exact payment (same processor request id) without charging twice. The retry has to carry the original nonce and amount. A different nonce or amount under the same `platform_reference` answers `409 payment_resume_mismatch` and sends nothing to the processor; a new card is a new payment with a new `platform_reference`, taken once this one has ended. A second request for the same `platform_reference` while the first charge is still in flight answers `409 payment_in_progress` with `Retry-After` and sends nothing to the processor; retry it after the wait.\n\n## Retries from the browser\n\nCreate the `Idempotency-Key` and the `platform_reference` for a sale before the first submit, one pair per logical sale, and keep them with the order (on your server, or in `sessionStorage` keyed by the order id). A page reload or a second click that mints a new pair is a new sale, not a retry.\n\n| Answer to `POST /v1/payments` | Key and reference |\n|---|---|\n| No answer (network failure, timeout), `502 processor_unavailable`, `500 internal_error` | Keep both. Send the same request again: same key, same body, same nonce. It resumes the same payment |\n| `409 idempotency_in_progress` or `409 payment_in_progress` | Keep both. The first request is still running; wait `Retry-After` seconds and send the same request again |\n| `422 idempotency_key_reused` | Keep both. The key was first used with a different body; send the original body. Do not mint a new key to get past it |\n| `409 payment_resume_mismatch` | Keep the reference. The payment is still `pending` and the body changed (a different nonce or amount); send the original body with its original key |\n| `201` with `state: succeeded` | Done. Discard the pair |\n| `201` with `state: failed` and `card_declined`, `nonce_invalid` or `processor_rejected`, or `partial_approval` whose `payment.failed` says `reversed: true` | The sale was decided and nothing is left charged. Another attempt is a new payment: a new nonce, a new key and a new `platform_reference` |\n| `201` with `state: failed` and `partial_approval` whose `payment.failed` says `reversed: false` | Decided as a decline, but the partial authorization may still be standing on the card: `payment.needs_attention` (`standing_authorization`) follows and ZeroPoint retries the void; `payment.reversed_late` says when it is reversed. Ask for another card as a new payment with a new nonce, key and `platform_reference`, and do not charge the same card for this order again until it is resolved |\n| `201` with `state: failed` and `processor_unverified` | Unknown outcome. Do not start a new payment for the same money; see `handle-every-payment-state` |\n\nOnly a decided failure permits a new key and reference. Everything else in the table is either still running or unknown, and a new pair there can charge the customer twice. One more case looks like a decline and is not the card: a second sale on the same card for the same amount within seconds of a succeeded one (the errors guide, \"The processor's duplicate screen\").\n\n## Rules\n\n- A nonce is single-use and expires within minutes. Never store it, never log it.\n- Never send a card number, CVV, or expiry to `/v1/payments`; `metadata` values that look like card numbers are rejected, and so is a card number sent in the `nonce` field (`400 parameter_invalid`, nothing reaches the processor).\n- Keyed payments finish in one request, so `POST /v1/payments/{payment_id}/cancel` does not apply to them; refund instead.","updated":1795275945}