Skip to main content

Charge at submit — CVV, AVS & 3-D Secure at the first charge

Charge at submit is the charge-and-save flow for elements mode. On the buyer's first charge one collection.submit() charges the card, verifies the CVV the buyer just typed, runs address verification against the billing address, hands off to the issuer's hosted 3-D Secure challenge when one is required, and, when the buyer agreed to save it, vaults the card as a reusable vp_pmt_* (Getting the saved card back).

A stored token has no CVV, so the default vault-then-charge path can never return a CVV result unless the buyer re-enters it; charging at submit keeps the buyer-present security code in the request that authorizes the card. Charge at submit is enabled per session; CVV recovery, AVS and 3-D Secure activate at the account level with your gateway — confirm with your Von Payments contact before relying on the result codes in production.

Enable it on the session​

Create the session server-side with integrationMode: "elements" and chargeAtSubmit: true, and always set successUrl — it is where the issuer returns the buyer after a hosted 3-D Secure challenge (without one Von Payments uses its own hosted return page, so the buyer finishes on a Von Payments page instead of yours; cancelUrl is used when they abandon the challenge):

curl -X POST https://checkout.vonpay.com/v1/sessions \
-H "Authorization: Bearer $VON_PAY_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": 4999,
"currency": "USD",
"buyerId": "buyer_123",
"integrationMode": "elements",
"chargeAtSubmit": true,
"successUrl": "https://your-store.example.com/checkout/return",
"cancelUrl": "https://your-store.example.com/checkout/cancelled"
}'

Return the session id and publishableKey to the browser, then mount and submit exactly as in custom layout — the session flag alone switches submit() to the charge path. A session created without chargeAtSubmit: true vaults the card and returns a token instead.

Read the result​

Charge at submit adds chargeStatus, redirectUrl and paymentIntentId to the SubmitResult. Branch error → chargeStatus → token → charged (charged: false beside chargeStatus: "succeeded" on a captureMethod: "manual" session: authorized, held, not yet taken; fulfill only on charged === true); on the requires_action arm nothing has been charged yet, and if your code only handles succeeded and pending a 3-D Secure card lands in neither — the buyer sees a spinner or a false success and the payment is silently abandoned:

const result = await collection.submit();

if (result.error) {
// Nothing was charged. Surface result.error.message (see "Errors" below).
} else if (result.chargeStatus === "requires_action") {
// 3-D Secure required. NOTHING has been charged yet. Send the buyer to the
// issuer's hosted challenge; they return to the session's successUrl and the
// charge.* webhook is the authoritative outcome.
window.location.href = result.redirectUrl;
} else if (result.chargeStatus === "pending") {
// Authorised but not yet settled — do NOT fulfil yet. Wait for the charge
// webhook, keyed on result.paymentIntentId. No result.token on this arm.
} else if (result.recovered) {
// Resolved by polling after a lost response. result.paymentIntentId is
// absent here (only result.transactionId). Never fulfil on result.charged
// for a recovered outcome; confirm the payment server-side first.
} else {
// chargeStatus === "succeeded": the charge completed. result.charged is true
// when money was captured, and FALSE on a session created with
// captureMethod: "manual": the card was authorised, the money is held, and
// nothing moves until you capture result.paymentIntentId server-side. Fulfil
// only on result.charged === true; treat an absent value as unknown.
// result.token (vp_pmt_*) is set when the card was saved (see
// "Getting the saved card back"); otherwise result.charged comes with
// no token.
}
Submit already charged — never charge the session twice

When charge at submit is on, submit() has already charged the card. Do not also call POST /v1/payment_intents for the same session — that double-charges the buyer. The client result is a UX signal; confirm settlement via the charge webhook before fulfilling, and treat chargeStatus: "pending" as not yet settled. For a hold (charged: false), take the outcome from the capture response, not a webhook.

Billing address for AVS​

AVS only runs when the charge carries a billing address. Mount an address element and it is forwarded automatically:

const address = collection.create("address", { mode: "billing" });
address.mount("#billing-address");
// …mount card fields…
const result = await collection.submit(); // the address rides along

Or pass it from your own form and skip the element:

const result = await collection.submit({
billingAddress: {
line1: "1600 Pennsylvania Ave NW",
city: "Washington",
state: "DC",
postalCode: "20500",
country: "US", // 2-letter ISO 3166-1 code
},
});

line1, postalCode and country are required and validated before any network call — a missing or malformed field returns frame_field_validation_failed and nothing is charged. Each street line can be up to 60 characters, city and state up to 40, and the postal code up to 16. From vora.js 1.52.0 a longer value returns frame_field_validation_failed naming the field, before anything is sent. An explicit submit({ billingAddress }) takes precedence over a mounted address element.

Read the address and security-code results on your server: avs_result_code and cvv_result_code on the charge.succeeded and charge.failed webhooks. The submit() result does not carry them: its avsResultCode and cvvResultCode fields are deprecated and always absent, and stay in the types so existing code compiles. A no_match is a signal for you to act on, not an automatic decline.

The shopper's name from your own form​

From vora.js 1.52.0, pass the shopper's given and family names from your own form with collection.submit({ billingDetails: { firstName, lastName } }). They go with the card charge, and only when the card form charges at submit. A saved card, Apple Pay, Google Pay, the embedded card form, a collect-only form and a card the form saves for your server to charge do not send them.

  • Pass the two names separately. vora.js does not split a full name, and does not read the name from a cardholder element.
  • Each name is trimmed, and a blank name is not sent. A name longer than 50 characters (an emoji counts as 2 or more), a name that is not text, or a name with a control or invisible formatting character returns frame_field_validation_failed before anything is sent. The names are checked on every submit(), even one that does not send them.
  • When you send either name, the checkout takes both from this payment: a name you leave out is then missing, not taken from the session. Send neither, and the checkout uses the names stored on the session.
  • The names are used for this charge only. They are not saved, and no response returns them.
  • They reach your payment processor only when the billing details for your account are switched on, which is an account setting. A successful charge does not confirm they were sent. See Putting a name on the payment.
  • Your server can send the same names when it calls POST /v1/public/sessions/{sessionId}/charge itself, as first_name and last_name. There each name can be up to 50 characters, the same as in vora.js, and a bad value returns 400 validation_error. A repeat under the same Idempotency-Key returns the first result and ignores a changed name.
  • After a declined card, pass the names again on the next submit().

3-D Secure​

When a card requires 3-D Secure, the challenge runs on the issuer's hosted page and the buyer leaves your page for its duration (issuers increasingly refuse to render their authentication page inside another site's frame). submit() resolves with { chargeStatus: "requires_action", redirectUrl, last4, brand } and nothing has been charged. Send the buyer to redirectUrl; they authenticate, return to your successUrl, the charge settles, and the charge.succeeded / charge.failed webhook is the authoritative outcome — fulfill on that, not on the redirect. The return to successUrl is performed by the payment provider and Von Payments does not add or control its query string: treat it as "the buyer is back", and confirm the outcome from the webhook or a server-side read of the payment intent.

If 3-D Secure is required but no usable challenge URL can be produced, submit() fails closed with frame_3ds_required and nothing is charged — and re-running submit() will not help. From vora.js 1.39.0 error.reason says why; for try_another_payment_method, ask the buyer to pay another way (a card or method that does not need a bank check can succeed), and report the session id to support. The reasons are on Errors. The 3-D Secure guide covers sandbox test cards and the server-driven confirm path used by the tokenize-then-charge flow.

Getting the saved card back​

A card is vaulted when the charge completes, so what you get back depends on the arm:

chargeStatusresult.tokenresult.paymentIntentId
"succeeded"present when the card was savedpresent
"pending"never: read the card back once the payment settlespresent
"requires_action"nevernever

The card is saved when someone agreed to it, and the session has a buyer. Agreement comes from one of three places: the buyer ticks the save box; your page's own wording, when you pass setupForFutureUse: "off_session" to elements.create() or submit() with no save box in the collection (your own wording; from vora.js 1.44.0 on a guest checkout too); or you declare setupForFutureUse: "on_session" on the session. The buyer is your buyerId, or, when the session has none, a buyer Von Payments creates for the session (vp_buyer_id on GET /v1/sessions/{id}): with no buyer email, only when the buyer agreed through the box or your wording; with a buyer email, whenever the card is saved, whichever of the three agreed. The card never goes to an existing buyer with the same email (buyers Von Payments creates).

On requires_action you get neither — that is every 3-D Secure card, and it needs a recovery path.

Recovering the card after a 3-D Secure charge​

The charge.succeeded webhook is where the payment intent's id comes from — there is no list endpoint for payment intents and GET /v1/sessions/{id} does not return one.

  1. Receive charge.succeeded. Read payment_intent_id from it.
  2. Read the intent back from your server (neither the Node nor the Python SDK exposes a payment-intent read, so this is a direct REST call with your secret key):
curl https://checkout.vonpay.com/v1/payment_intents/$PAYMENT_INTENT_ID \
-H "Authorization: Bearer $VON_PAY_SECRET_KEY"
{
"id": "vpi_live_8rT3jQv5xY9mNa_pQ",
"status": "succeeded",
"payment_method_id": "vp_pmt_live_sLCHe8nrneFldDJF"
}
A null on the first read does not mean the card was not saved

The webhook can reach you before the vaulted card is attached to the intent, so status: "succeeded" with payment_method_id: null is a normal first read. Re-read with a short backoff. A null that persists on a succeeded payment that should have saved the card is a support case — writing "no card on file" into your records re-prompts a buyer for a card they already gave you.

payment_method_id is legitimately null when the payment saved nothing: nobody agreed to save the card, or the payment never succeeded. A saved card outlives the payment that saved it, so it keeps being returned on later reads. The same handle appears as id on a POST /v1/tokens response, token on the charge-at-submit result, and payment_method_id on the payment intent; all three are what you pass as payment_method.id on POST /v1/payment_intents.

A charge at submit saves the card only when someone agreed to it (above). Mounting the save-for-future-use element records two consents when the buyer ticks it, and both are write-once — a token vaulted without them cannot be upgraded (Tokenization → reusability):

FieldThe question it answers
setup_for_future_useMay you charge this card again? off_session makes the token usable for merchant-initiated charges (subscriptions, renewals); on_session permits reuse only while the buyer is present.
allow_redisplayMay the card be shown back to the buyer in a later checkout? always | limited | unspecified.

A ticked box vaults off_session with allow_redisplay: "always". When your label names one arrangement ("Save this card for my subscription"), pass displayScope: "limited" on the element so the card is not offered back on an unrelated purchase; an unticked box records unspecified. Both values come back on the result (setupForFutureUse, allowRedisplay) echoing what was persisted on the returned token, and absent when nothing was vaulted. From vora.js 1.44.0 setupForFutureUse comes only from the checkout's confirmation: absent means "not confirmed by this submit", not "not saved". Saved cards are read server-side with GET /v1/payment_methods.

Errors​

All failures come back on result.error — the card is not charged when error is set:

CodeMeaning
frame_field_validation_failedA required field (including a supplied billing address) was missing or malformed. Fixed before any charge.
frame_card_brand_not_acceptedYour account does not accept the brand of this card (vora.js 1.52.0 and later). Nothing charged, and no payment attempt used. Ask for a card of another brand on the same session. One session can have the card brand checked at most 30 times; after that the checkout answers session_attempt_limit_reached, and the shopper needs a new session.
frame_payment_declinedThe card was authorized through 3-D Secure (or no 3DS was required) but the issuer/processor declined the charge. Also raised when the buyer did not finish their bank's security check, where the same card can work: error.declineCode is then authentication_not_completed. When the check did not pass, it is authentication_failed: nothing was charged and the checkout session usually ends: when error.retryable is false, start a new session; when it is true, the card form was reset and the buyer can try again on it (see Decline reasons in the browser).
frame_3ds_challenge_failedThe 3-D Secure challenge was rejected, or couldn't finish technically. Nothing charged. Not buyer cancellation — that has its own code.
frame_3ds_challenge_timeoutThe buyer ran out of time on the 3-D Secure challenge. Nothing charged.
frame_3ds_challenge_cancelledThe buyer closed the 3-D Secure challenge. Nothing charged, card is fine — an abandoned checkout, not a failure.
frame_3ds_required3-D Secure was required but no usable challenge URL could be produced, so the charge failed closed. Re-running submit() will not help. From vora.js 1.39.0 error.reason says why: for try_another_payment_method, ask the buyer to pay another way (a card or method that does not need a bank check can succeed), and report the session id to support; for not_supported_here, contact support with the session id.

A charge can also be rejected by the provider before any authentication is attempted: HTTP 422 provider_request_rejected (selfHeal.retryable: false, nextAction: "fix_request"). The card was neither charged nor declined, so a different card fails the same way — fix the request. The error reference has the complete code union.

If you change the session's total​

A charge-at-submit session is an elements session, so its total can be changed with PATCH /v1/sessions/{sessionId} (sessions.update() in the server SDKs). After changing it, call collection.fetchUpdates() and wait for it before the buyer pays (vora.js 1.36.0 and later):

// Your server has just changed the total.
const { amount, currency } = await collection.fetchUpdates();
showTotal(amount, currency); // show the buyer what they will pay

It re-reads the session and resolves with the total the checkout now holds. From then on, every card payment from this collection carries that total, and a payment whose total changed again without another fetchUpdates() is refused with frame_wallet_total_mismatch; the card is not charged. Show the new total and let the buyer pay again.

  • Calling submit() while fetchUpdates() is still reading is refused with frame_session_not_ready, and nothing is charged.
  • A failed fetchUpdates() leaves the previous total in force, so a later payment can only be refused, never charged at a total nobody saw.
  • It is opt-in. Until the first call, card payments are sent as before, and a total change is caught only if it happens while the charge request is being processed (409 expected_amount_mismatch, nothing charged).

A server that calls POST /v1/public/sessions/{sessionId}/charge directly sends the same check itself as expected_amount ({ amount, currency }, the total the buyer was shown).

If you name the guest after the page opened​

Your server can give a guest session the shopper's email, or name the customer with buyerId, after the page opened, with PATCH /v1/sessions/{sessionId}. The charge reads it from the session when the shopper pays. If your change arrives as the shopper presses Pay, the charge answers 409 session_update_conflict with reason: "concurrent_update". Nothing was charged and the session is still open. From vora.js 1.51.0 the browser SDK reports it as frame_session_update_conflict; before that, as frame_tokenization_failed with status 409. Let the shopper press Pay again with the same card. Do not ask for a different card, and do not create a new session.

If the shopper presses Pay again​

A submit() can lose its answer, for example on a dropped connection, or get a pending one. From vora.js 1.52.0:

  • A repeat submit() with the same details is the same try. The checkout answers with the result of the first one.
  • A repeat with changed details is a new try with what the shopper chose now. Changed details are the names, the address, the save choice, or a total changed by fetchUpdates().
  • A checkout still takes one payment only. If an earlier try went through, submit() reports the checkout as paid. Before 1.52.0, that answer was reported as frame_tokenization_failed.

If your server repeats a charge request​

A server that calls POST /v1/public/sessions/{sessionId}/charge can repeat a request with the same Idempotency-Key, for example after a timeout:

  • The repeat gets the recorded answer of the earlier request, with replayed: true in the body and the header Idempotent-Replayed: true. A first answer never carries them.
  • The repeat moves no money, but the earlier request may have. While a replayed answer reads pending or requires_action, or succeeded with charged: false, the earlier payment can still complete. Do not start a new payment for the order. Wait for the webhook, or read the session.
  • replayed does not say whether the session is still open. Read status and retry as usual.
  • A repeat usually gets the recorded answer instead of 410 session_expired. It still gets the 410 in these cases: the earlier request was answered 410 itself, no result was recorded for it, the payment was cancelled while it waited on the bank check, or the session forwards the card to another processor and has since expired or been cancelled.

When your checkout replaces its session​

Some checkouts create a new session when the order changes (a coupon, a new shipping price), instead of changing the total of the open one. From vora.js 1.47.0, collection.switchSession() moves the card form to the new session, so the buyer keeps the card they typed. The card data stays in the card fields; only the new session's client secret and its total come from your page.

// Your server created the new session with the same card_form_group as the old one,
// and your page now shows its total to the buyer.
const result = await collection.switchSession(newClientSecret, {
amount: shownTotal.amount, // the total on the screen, in minor units
currency: shownTotal.currency,
});

if (result.outcome === "switched") {
showTotal(result.total.amount, result.total.currency);
} else {
// The card form is gone. Build a new one for the new session, as before.
console.info("switchSession not_switched:", result.reason);
await buildCardForm(newClientSecret);
}

Before you call it​

  • Your server gives both sessions the same card_form_group. Set it on POST /v1/sessions, or later with PATCH /v1/sessions/{sessionId}. Derive it on your server, one value per shopper checkout, for example an HMAC of your cart id with a key only your server holds. Never use a customer id, a store id or a constant, and never take the value from the browser or send it there.
  • Both sessions charge at submit. Create them with integrationMode: "elements" and chargeAtSubmit: true, for a payment, without the in-page bank check.
  • Your page has both client secrets. The page loaded the old session with its client secret, and passes the new session's client secret to switchSession().
  • The collection holds only card fields. That is the card element, or card-number, card-expiry and card-cvc, with an optional save box, email, address and cardholder name. An embedded card form, wallet buttons or saved cards in the collection answer not_switched.
  • No card charge was sent from the form yet, whatever its outcome. After one, the answer is not_switched.
  • amount and currency are the total on the buyer's screen, not a value read back from the new session. A new session at another total answers not_switched.
  • The checkout also checks the two sessions. They must be for the same buyer (the same buyerId, or both guests) with the same buyer country, on the same account, mode, channel and currency. The card form must be less than 50 minutes old, and it can move at most 10 times. Otherwise the answer is not_switched.

What it resolves with​

outcomeWhat happenedWhat to do
switchedThe card form now pays the new session, and the old session is closed. The next payment pays exactly total. The save box is unticked.Show total. A buyer who wants to save the card ticks the box again.
not_switchedThe card form did not move to the page's new session. The collection is unmounted, so its card form can never pay the old session. Treat the old session as finished: do not pay it.Call vora.sessions.retrieve() with the new session's client secret and build a new form, as you do without this method.

Handle every not_switched reason the same way. If a payment was already sent from the old form, first read its outcome on your server (the charge.* webhooks or GET /v1/sessions/{sessionId}). Do not offer another payment while that payment is pending or its outcome is unknown. reason is for your logs. Some reasons come from your page (for example total_mismatch or source_has_payment), and others come from the checkout unchanged (for example not_declared: the two sessions do not carry the same card_form_group). When the checkout does not offer the handover, the reason is not_available. New reasons can appear, so do not branch on the value.

A switch to the session the form is already on also answers switched, and sends nothing. To read a new total on the same session, use fetchUpdates().

When it refuses​

The promise rejects and nothing changes when:

  • the first argument is not a client secret: frame_client_secret_invalid;
  • the total is not { amount, currency } in minor units: frame_field_validation_failed;
  • a payment, a bank check, fetchUpdates() or another switch is running on the form: frame_session_not_ready. Call again when it ends;
  • the collection was unmounted before the call.

While a switch runs, submit() and fetchUpdates() are refused with frame_session_not_ready, and nothing is charged.

The switch loads its own file from https://js.vonpay.com on the first call, like the other parts of vora.js (the @vonpay/vora npm package loads vora.js from there too). Your Content Security Policy does not change, and Vora.cspSources() is unchanged.