Guides
Accept a keyed (card-not-present) payment
Embed the hosted card form, get a one-time nonce in the browser, and charge it with one request that returns the final result.
Card numbers never reach your server or your page. The browser hands the card to a form that Monetize.Pay hosts, the form posts a one-time nonce to your page, and you post the nonce to us.
Start from the reviewed zeropoint.node.keyed-checkout snippet (list_snippets, get_snippet): a tested Node server for this flow, with its instructions and tests. Use this guide to understand what it does. Write your own server only when the snippet does not fit your stack.
1. Fetch the form configuration
Response 200:
{"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"},{"brand":"visa","number":"4242424242424242","expiry":"12/30","cvv":"123","outcome":"approved"}]}test_cards is shortened here; the full list and every outcome are in sandbox, "Keyed test cards".
A 503 sandbox_processor_unconfigured means this test merchant has no test business; create a new test merchant. Simulated terminals still work.
2. Embed the form (or use the sandbox page)
A nonce comes from the card form in a browser: there is no fixed sandbox nonce. In test mode the form is Monetize.Pay's test card form, which has no bot check, so a person or an automated browser can use it. Open sandbox_form_url, type a test card (4761 7390 0101 0010 approves), press "Use this card", copy the nonce the page shows, and post it with curl as shown in step 3. Type the expiry as MM/YY with the slash; the sandbox page shows the form's own messages next to the code. In your own checkout page, embed form_url in an iframe and listen for its message:
<iframe id="card" src="FORM_URL?origin=https://shop.example.com&button=none"
title="Card form" style="width:100%;border:0;height:320px"></iframe>
<button id="pay" disabled>Pay</button>
<script>
const frame = document.getElementById('card');
const formOrigin = new URL(frame.src).origin;
window.addEventListener('message', (event) => {
if (event.origin !== formOrigin) return;
const msg = event.data;
if (msg.type === 'zeropoint.ready') pay.disabled = false;
if (msg.type === 'zeropoint.nonce') sendToYourServer(msg.nonce);
if (msg.type === 'zeropoint.error') showError(msg.code);
});
pay.onclick = () => frame.contentWindow.postMessage({ type: 'zeropoint.tokenize' }, formOrigin);
</script>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.
3. Charge the nonce
This call requires an Idempotency-Key header, like every POST that creates something. Response 201 with a final state:
succeeded: paid;processor_transaction_id,card_last4,card_brand,receipt_urlare set.failedwithfailure_code: card_declinedornonce_invalid(expired or reused nonce; get a fresh one) orprocessor_rejected(the Processor refused the request as invalid; not a card decline) orprocessor_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 apendingpayment, after a network re-send, or in an answer read back from its records: the first attempt may have been charged.) orpartial_approval(the card approved only part of the amount; we voided that partial sale, since Monetize.Pay never accepts a partial approval: show a decline and ask for another card, and do not retry the same card for the same amount). Every keyed charge also asks the Processor not to approve part of the amount (partialAuthEnabled: false). Monetize.Pay does not rely on that request: a partial approval that still comes back is declined and voided as above, on keyed, card-on-file and terminal payments alike. Acard_declinedorprocessor_unverifiedpayment carriesprocessor_transaction_idwhen the Processor returned an id for the attempt. That id names the Processor's row, not a charge: onlystate: succeededmeans money moved.
A 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.
Retries from the browser
Create 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.
Answer to POST /v1/payments | Key and reference |
|---|---|
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 |
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 |
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 |
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 |
201 with state: succeeded | Done. Discard the pair |
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 |
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 Monetize.Pay 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 |
201 with state: failed and processor_unverified | Unknown outcome. Do not start a new payment for the same money; see handle-every-payment-state |
Only 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: the Processor's duplicate screen, which refuses 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"). In test mode only test card 4000 0000 0000 0135 gets it.
Read the answer as paid, declined or unknown
A keyed charge ends as paid, declined or unknown. Unknown is not a decline: the card may have been charged. Code that treats every answer other than succeeded as a decline asks the customer for another card and can charge them twice. This is the reading your server needs for one answer to POST /v1/payments, in Node:
// No sale was taken and the card can be tried again as a new payment.
const DECLINED = new Set(["card_declined", "nonce_invalid", "processor_rejected"]);
function readKeyedAnswer(status, answer) {
if (status !== 201) {
// Not decided by this answer. The retry table above says what to send next for each code.
return { outcome: "not_decided", code: answer && answer.error && answer.error.code };
}
if (answer.state === "succeeded") return { outcome: "paid" };
if (answer.state === "failed") {
const code = answer.failure_code;
if (DECLINED.has(code)) return { outcome: "declined" };
if (code === "duplicate_transaction") return { outcome: "duplicate" };
if (code === "partial_approval") {
const reversed = Boolean(answer.partial_approval && answer.partial_approval.reversed);
return { outcome: reversed ? "declined" : "declined_hold_standing" };
}
}
// processor_unverified, and anything this code does not recognize.
return { outcome: "unknown" };
}What to do with each outcome. The sentences for the customer are the ones in handle-every-payment-state, "What to tell the customer":
| Outcome | Next |
|---|---|
paid | Mark the order paid. Discard the key and reference |
declined | The sale was decided and nothing is left charged. Another card is a new payment: a new nonce, a new key and a new platform_reference |
declined_hold_standing | A partial approval whose void is not confirmed yet (reversed: false). Treat it as a decline, and do not charge the same card for this order again until payment.reversed_late arrives. Another card is a new payment |
duplicate | Not a card decline and no money moved. Do not ask for another card: check that the earlier charge is the one you meant |
unknown | Keep the key and reference. Take no other payment for this order, and do not tell the customer it was declined. Send the payment id and the request_id to your Monetize.Pay contact; see handle-every-payment-state. A payment.failed event that carries processor_unverified is still unknown |
not_decided | Follow the retry table above for that status and code. A non-2xx answer does not prove nothing was charged: when a payment already exists under this platform_reference, read it before doing anything else |
The reviewed zeropoint.node.keyed-checkout snippet (list_snippets, get_snippet) is a tested server for this flow: start from it. It is stricter than the reading above: it never retries on its own and sends more cases to review instead of calling them declines.
How an order leaves unknown
An order held as unknown needs a way out, or it waits forever. Build these:
- Read the payment again:
GET /v1/payments/{payment_id}, orGET /v1/paymentswithmerchant_idandplatform_referencewhen you have no id.succeededsettles the order as paid.failedthat the reading above callsdeclinedsettles it as declined.pending: follow the retry table above; a keyed payment stillpendingafter 15 minutes endsfailedwithprocessor_unverified.failedwithprocessor_unverifiedstays unknown. An empty list read while the original request may still be running proves nothing; once that request has ended, an empty list (same key mode, same merchant) means Monetize.Pay sent no charge for that reference. - Apply the same reading to the
payment.succeededandpayment.failedevents for that payment. Apayment.reversed_latenaming this payment means the charge behind it was voided. - Treat an order your server started charging and then lost track of (a crash, a restart) as unknown, not as open. Store the key and the reference before the first send, and look the payment up by that reference before letting the customer pay again.
- What is still unknown after that goes to a person. Show it on a list your staff can see, and send the payment id and the
request_idto your Monetize.Pay contact. Do not release the order for another payment on a timer.
Rules
- A nonce is single-use and expires within minutes. Never store it, never log it.
- Never send a card number, CVV, or expiry to
/v1/payments;metadatavalues that look like card numbers are rejected, and so is a card number sent in thenoncefield (400 parameter_invalid, nothing reaches the Processor). - Keyed payments finish in one request, so
POST /v1/payments/{payment_id}/canceldoes not apply to them; void before settlement, refund after.