{"object":"doc","slug":"save-a-card","title":"Save a card for later charges","summary":"Create a customer, show the merchant's terms, take the card in the hosted form in save mode, and save it, alone or with a first payment in the same call.","tags":["guide","card-on-file","collect"],"body":"# Save a card for later charges\n\nYour app never handles a card number. The cardholder types the card into the hosted card form, the form posts a one-time `nonce` to your page, and your server sends the nonce to ZeroPoint, which saves the card as a payment method (`pm_...`) of a customer (`cus_...`). The `saved-cards` concept explains what is stored and why a card can become unusable.\n\nYou need the scopes `customers:write` and `payment_methods:write` (a key issued with `full` has them).\n\n## 1. Create the customer\n\n```\nPOST /v1/customers\n{\"merchant_id\":\"mch_01j...\",\"email\":\"pat@example.com\",\"name\":\"Pat Lee\",\"metadata\":{\"app_user_id\":\"8841\"}}\n```\nAn `Idempotency-Key` is optional here (nothing reaches the processor); send one if your code may retry, so a retry returns the same customer. The answer is `201` with the customer. Keep the `cus_` id next to your own user. `email`, `name` and `metadata` are optional; `GET /v1/customers` with the filters `merchant_id` and `email` finds an existing one, so look before you create a second customer for the same person.\n\n`merchant_id` is optional on this call, on the card save in step 4 and on the saved-card charge. Without it, ZeroPoint uses the merchant id (`mch_...`) in a `ZeroPoint-Account` header (`Stripe-Account` is accepted too), and without that, the platform's only merchant in the key's mode. When neither names one and the platform has no merchant or several in that mode, the call answers `400 parameter_invalid` with `param` `merchant_id`. A body `merchant_id` and a header that name different merchants are refused the same way. The single-merchant default is decided on every request: once a second merchant exists in that mode, a call that relied on it answers that `400`, retries of it included, so send the header (or `merchant_id`) on every call.\n\n## 2. Show the merchant's terms\n\nBefore the card is saved, your page shows the cardholder the merchant's terms for storing the card and charging it later, and the cardholder agrees. The merchant owns those terms and is responsible for the cardholder's agreement. ZeroPoint shows no terms and no consent wording on the form and does not review the merchant's terms. Record the moment of agreement: you send it as `consent.agreed_at`.\n\n## 3. Take the card in the hosted form, in save mode\n\n```\nGET /v1/merchants/{merchant_id}/collect-config\n```\nThe answer carries `save_form_url` beside `form_url`. It is the same form with `save=1`: the button reads \"Save card\", and the `zeropoint.nonce` message the form posts to your page carries `\"save\": true`. Nothing else changes, so the embedding, the `origin` parameter and the messages are exactly as in `accept-a-keyed-payment` and the `collect` concept. Send the nonce to your server. Never store it or log it; it works once.\n\nApple Pay and Google Pay cannot be saved. The save form shows no wallet buttons, and a wallet nonce must never be sent to a save; charge it once as a keyed payment instead.\n\n## 4. Save the card\n\nThere are two ways. Pick one per nonce: a nonce works once.\n\n**Save and charge in one call** (a first payment now, more later):\n```\nPOST /v1/payments\n{\"merchant_id\":\"mch_01j...\",\"amount_cents\":4900,\"platform_reference\":\"order-2044\",\"method\":\"keyed\",\"nonce\":\"<from the browser>\",\"save_payment_method\":{\"customer\":\"cus_01j...\",\"consent\":{\"agreed_at\":1794700000,\"reference\":\"terms-2026-11\"}}}\n```\n**Save only** (add a card, a free trial, a first charge on another day):\n```\nPOST /v1/payment_methods\n{\"merchant_id\":\"mch_01j...\",\"customer\":\"cus_01j...\",\"nonce\":\"<from the browser>\",\"consent\":{\"agreed_at\":1794700000,\"reference\":\"terms-2026-11\"}}\n```\nBoth need an `Idempotency-Key`. `consent.agreed_at` is required: Unix seconds when the cardholder agreed (more than five minutes in the future is refused). `consent.reference` is optional, your own id for the terms. `metadata` is optional; the keys `token`, `token_enc`, `nonce`, `consent`, `secret`, `client_secret`, `access_token` and `refresh_token` are reserved. The customer field is called `customer` everywhere on the wire.\n\n**Save first, then charge.** Saving uses up the nonce, so a nonce that was charged first can no longer be saved and the card would be lost. The one-call form therefore saves the card first and then charges the saved card; it never charges the nonce. Do the same in your own flows: never charge a nonce you mean to keep.\n\n## What comes back from the one-call form\n\n| Answer | Card | Money | What to do |\n|---|---|---|---|\n| `201`, `state: succeeded`, `payment_method` set | Saved | Paid | Done. Keep the `pm_` id |\n| `201`, `state: failed` (`card_declined`, `duplicate_transaction`, `processor_rejected`, `partial_approval`), `payment_method` set | Saved, `active` | Not charged | Both facts are true. Keep the card or delete it; for a decline ask for another card |\n| `201`, `state: failed` with `card_not_saved` or `nonce_invalid`, `payment_method` null | Not saved | Not charged | Ask the cardholder to enter the card again |\n| `502 processor_unavailable` | Maybe saved | Unknown | Retry the identical request with the same `Idempotency-Key` and body. It resumes the same payment and never charges twice. Never a new `platform_reference` |\n| `409 nonce_already_used` | Already saved, or the nonce was already charged | | The message names the `pm_` or `pay_` id. Charge that method, or collect the card again |\n\nThe rest of the outcomes, and the retry rules, are those of `charge-a-saved-card`.\n\n## What comes back from the save-only form\n\n| Answer | What happened | What to do |\n|---|---|---|\n| `201` with the payment method | Saved. `payment_method.attached` is sent | Charge it later with `method: card_on_file` |\n| `402 card_not_saved` | The processor gave no usable card. Nothing saved | Ask for the card again |\n| `402 nonce_invalid` | The nonce expired or was used. Nothing saved | Ask for the card again |\n| `409 nonce_already_used` | This nonce already saved a card, or paid a payment, on this merchant | The message names the id; use that method |\n| `502 processor_unavailable` | Unknown whether the processor made a token; nothing stored, no money moved | Retry once with the same `Idempotency-Key` and nonce. If it then answers `nonce_invalid`, ask for the card again |\n| `400 card_on_file_unavailable` | Live mode, and saved cards are not yet switched on for your platform | See `going-live` |\n| `503 sandbox_processor_unconfigured` | This sandbox has no processor account | Saved cards need one; there is no simulator |\n\nLimits, test mode, per platform: 200 stored cards (`409 resource_limit_exceeded`), and 200 new cards and 600 save attempts a day (`409 sandbox_daily_limit_exceeded` with `Retry-After`). Live mode: `409 save_attempt_limit_exceeded` when the platform's daily allowance of saves is used up (resets at 00:00 UTC).\n\n## Testing in the sandbox\n\nWith no browser: send `\"nonce\": \"tok_visa\"` in test mode. The card (Visa 0010) is saved and its charges succeed; `tok_chargeDeclined` saves a card whose charges are declined. Nothing reaches the processor. The other tokens and their rules are in `sandbox`, \"Test card tokens\". A token never exercises your form embed: save one card typed into `save_form_url` (below) before going live.\n\nFrom the real card form: a nonce can only be made by a person typing a card into the form in an ordinary browser: an automated browser is refused (`RECAPTCHA_DECLINED`, VERIFIED 10/18/2026). Open `sandbox_form_url` from `collect-config`, type `4761 7390 0101 0010` with any future expiry, any CVV, any name and ZIP, and copy the nonce. VERIFIED sandbox 10/18/2026 and 10/28/2026: that card saves and its charges succeed; `4111 1111 1111 1111` saves and its charges are declined (`card_declined`). A card number sent where a nonce goes is refused with `400 parameter_invalid`. After one save, charge the card as often as you like with no browser, each charge with a new `platform_reference`.\n\n## Deleting a card\n\nWhen the cardholder asks to remove a card, call `DELETE /v1/payment_methods/{payment_method_id}` or `POST /v1/payment_methods/{payment_method_id}/detach` (the same operation under Stripe's name). See `saved-cards` for what that erases and for `409 payment_method_in_use`.","updated":1795275945}