Hosted card iframes
One Card Vault-hosted iframe holds the whole card form. The cardholder types the card into it, and your page only ever receives a token and card metadata -- card number, expiry and CVC never pass through your page's JavaScript, your servers or your logs.
This page covers the hosted iframe templates you pick when you create an interface
in the dashboard, and cv-embed.js, the one Card Vault script your page
includes to drive them. It is the secure-integration guide: follow the security rules
below on every page that carries the iframe. For card inputs mounted as separate
fields in your own layout, see JS fields
instead.
Who owns what
- Your page -- layout, headings, the Pay / Save button, cardholder contact fields, consent wording, and what happens after success. The iframe has no buttons: your button sends the submit.
- The Card Vault iframe -- card number, expiry, CVC, cardholder name, postal code (and street on templates that offer it), field validation, Card Policy checks, and sending the card to the vault.
- Your dashboard -- the interface: template, the website allowed to show it, which optional fields appear, and the public key.
1. Choose a template
- IFRAME Standard (IFRAME 1) -- stacked fields: card number, cardholder name, expiry and CVC, plus optional postal code, street address and a "Use this card for future charges" checkbox. Fixed height: you size the iframe.
- IFRAME Horizontal (IFRAME 3) -- the same fields laid out across the row for wide checkouts, with the same optional postal, street and recurring checkbox. Fixed height: you size the iframe.
- IFRAME 4 -- form-only, transparent background, designed to sit
inside your own form: card number, MM / YY and CVC on one row, then cardholder
name and an optional postal code. No header, no street field and no recurring
checkbox -- your page owns those and tells Card Vault the card's usage on submit.
It shows the card brands your Card Policy
accepts as icons in the card number field, and it resizes itself
to fit its content (
cv:frame-resize). - IFRAME Compact (IFRAME 2) -- not available for new interfaces at this time.
IFRAME 4 is the recommended choice for new integrations.
2. Create the interface
In the Card Vault dashboard go to Settings > Interfaces and create an interface with the Credit Card Entry service and the template you chose.
- IFrame Host -- the website address of the page that will show
the iframe, host name only. The field already shows
HTTPS://in front of it, so typewww.example.com. A pastedhttps://www.example.com/is accepted and trimmed to the host. A non-default port may be added (www.example.com:8443). - Refused:
http://addresses (the page must be HTTPS), a page path (www.example.com/payments), a query string or fragment, wildcards, user names (user@host) and spaces. - One website per interface.
https://example.comandhttps://www.example.comare different origins -- enter the one your visitors actually see in the address bar (if your bare domain redirects towww, enter thewwwhost). A staging site needs its own interface. - Postal (Show / Require), Street (Show / Required, IFRAME 1 and 3 only) and Recurring (Show, IFRAME 1 and 3 only) decide which optional fields the iframe renders.
Then open the interface again to read the two values your page needs:
- URL -- the form URL, for example
https://cce.cardvault.com/acme-checkout. Use it exactly as shown. - Public Key -- identifies the interface on every submit. It is safe to put in browser code; it is not a secret. A disabled interface refuses every submit.
3. Embed it
Include cv-embed.js from the Card Vault CDN, pinned to an exact version
with Subresource Integrity. This is the only Card Vault script your page includes;
the template's own scripts and styles load inside the iframe from Card Vault.
<script src="https://cdn.cardvault.com/embed/1.0.0/cv-embed.js" integrity="sha384-ePaZCMD1iCr4nlJCfJTFtzgK6Eku91TQsGMLcH+gEmhBB/dvEQ2Cv3nz1rZVMIBu" crossorigin="anonymous"></script>
crossorigin="anonymous" is required with integrity; without
it the browser cannot check the file and will not run it.
A complete example
<div id="cv-payment"></div> <label><input type="checkbox" id="save-for-later"> Save this card for future payments to Acme Hotel</label> <button id="pay" type="button" disabled>Save card</button> <p id="card-message" role="alert"></p> <script src="https://cdn.cardvault.com/embed/1.0.0/cv-embed.js" integrity="sha384-ePaZCMD1iCr4nlJCfJTFtzgK6Eku91TQsGMLcH+gEmhBB/dvEQ2Cv3nz1rZVMIBu" crossorigin="anonymous"></script> <script> var button = document.getElementById("pay"); var notice = document.getElementById("card-message"); function fail(ctx) { notice.textContent = ctx.message; button.disabled = false; } CV.embed.load({ containerId: "cv-payment", formUrl: "https://cce.cardvault.com/acme-checkout", // the interface URL publicKey: "<the interface's Public Key>", height: "220px", // starting height; IFRAME 4 resizes itself onReady: function () { button.disabled = false; }, onSuccess: function (r) { // r.Token, r.Ref, r.Brand, r.Last4, r.UsageType ... -- POST to YOUR server sendToServer({ token: r.Token, ref: r.Ref, usageType: r.UsageType }); }, onDecline: fail, // { code, message, ref } -- incl. CARD_NOT_ACCEPTED onError: fail, // { code, message, ref } -- incl. READY_TIMEOUT onValidationFail: fail // { fieldId, fieldMessage, message } }); button.addEventListener("click", function () { button.disabled = true; notice.textContent = ""; var recurring = document.getElementById("save-for-later").checked; var sent = CV.embed.submit({ ref: "BOOKING-4821", // your reference, up to 64 chars profile: { fullName: "Jamie Cardholder", email: "jamie@example.com", usageCode: recurring ? 190 : 189 // see "Card usage" below } }); if (!sent) button.disabled = false; // not ready, busy, or clicked twice }); </script>
CV.embed API
CV.embed.load(options)-- creates the iframe insidecontainerId(an id, or a#selector). Required:formUrl(must be an absolutehttps://URL) andpublicKey. Optional:width(default100%),height(default400px),title(default "Secure card entry"),autoResize(defaulttrue: applycv:frame-resizeheights) andminHeight(default 44, in pixels), plus the callbacks below. Calling it again replaces the previous iframe.CV.embed.submit(submitData, chargeData?)-- sends the card.submitDatais{ ref, profile }. Returnsfalsewithout sending when the form is not ready, a submit is already running, or the last submit was less than 2 seconds ago.CV.embed.isReady()/CV.embed.isSubmitting()-- state checks.CV.embed.destroy()-- removes the iframe and the message listener.CV.embed.version/CV.embed.protocol-- the release ("1.0.0") and the wire protocol it speaks (1).
Callbacks:
onReady()-- the form can accept a submit. Keep your button disabled until it fires.onSuccess(result)-- the card was stored (and charged, if you sent a charge). See Results.onDecline({ code, message, ref })-- the card was refused.onError({ code, message, ref })-- anything else, includingREADY_TIMEOUTwhen the form does not report ready within 15 seconds.onValidationFail({ fieldId, fieldMessage, message })-- a field is empty or invalid; the iframe already shows the error under that field.onChange(data),onFocus({ fieldId }),onBlur({ fieldId }),onResize({ height })-- field and layout events. They identify the field, never what was typed.
Submit data
ref-- your order or booking reference, up to 64 characters. Echoed back on every answer and stored with the card.profile-- cardholder details stored with the card:fullName,email,phone,company,notes,aptSuite,city,region,country,segmentCode(see Segments),usageCode,usageExpiry(yyyy-MM-dd, single-use cards only) andcustomFields.chargeData(optional) -- only to charge at the same time:{ amount: 10.99, currency: "CAD", vaultOnSuccess: true, transactionType: 0 }.amountis in decimal dollars, maximum $999,999.99;transactionType0 = charge, 1 = pre-authorization;processorIdis optional. OmitchargeDatato save the card only.
4. Security rules for the host page
The iframe keeps card data off your site, but the page around it still matters: a compromised host page could replace the iframe with a fake form. Apply these rules to every page that carries the iframe.
- HTTPS only, with a valid certificate. The form is never framed by
an
http://page. - Framing is locked to your IFrame Host. Card Vault sends the form
with
Content-Security-Policy: frame-ancestors https://<your IFrame Host>, so the browser refuses to show it on any other origin -- including the other ofwww/ bare domain, and any page that wraps yours in a further frame. Opening the form URL directly in a browser tab returns HTTP 403: it only renders inside an iframe. - Submits are checked again on the server. Every card submission
must come from the hosted form itself or your registered origin (the browser's
Originheader) and carry the interface's public key; anything else is refused (ORIGIN_MISMATCH,INVALID_KEY). - Your own Content-Security-Policy, if your site sends one: allow
script-src https://cdn.cardvault.comforcv-embed.jsandframe-src https://cce.cardvault.comfor the iframe (or the directive your policy falls back to, such aschild-srcordefault-src). If your policy sets neither directive, nothing needs to change. - The message contract is origin-checked both ways.
cv-embed.jsposts only to the form's origin and accepts a message only when its origin is the form's origin and its source is the iframe it created. Each submit carries a fresh nonce; an answer carrying a different nonce is ignored. The iframe in turn accepts a submit only from your registered origin and posts its answers only to that origin. If you write your own message handling instead of usingcv-embed.js, do the same: checkevent.originon every message and never use"*"as thepostMessagetarget. - Never build your own card fields, and never copy card data into
your page. Show
BrandandLast4from the result. - Do not log or forward the messages. Keep results out of analytics, session replay and error-reporting tools: they carry the card token and the cardholder's name.
- Do not add a
sandboxattribute to the iframe -- it blocks the scripts the form needs. - Keep third-party scripts off the payment page where you can. Analytics, chat widgets, A/B tools and tag managers run with full access to the host page; keep an inventory of the ones that remain.
cv-embed.js with integrity
satisfies the integrity check for Card Vault's script; the other scripts on the page,
and change detection, are yours to manage.
5. Messages and results
With cv-embed.js the messages below arrive on your callbacks. Every
message is a JSON string with a type field.
cv:ready-- the form is loaded (onReady).cv:result-- the card was stored, and charged if a charge was sent (onSuccess).cv:decline-- the card was refused (onDecline).cv:error-- anything else (onError).cv:validationfail-- a field needs fixing (onValidationFail).cv:fieldchange-- for the card number:{ field: "cardnumber", brand, brandCode }when the detected brand changes, and{ field: "cardnumber", accepted, message }when Card Policy acceptance changes (onChange).cv:focus/cv:blur--{ fieldId }.cv:frame-resize-- IFRAME 4 only:{ source: "IFrame4", height }whenever the form's height changes (an error line appears, the postal field is shown).cv-embed.jsapplies it to the iframe unlessautoResizeisfalse, never belowminHeight. IFRAME 1 and 3 never send it: give them a fixed height with room for error text.
The result object
{
"Token": "<card token>", // send to YOUR server; null on a charge-only result
"CardId": "...", // stable card reference
"Ref": "BOOKING-4821", // your reference, echoed
"Brand": "Visa",
"BrandId": 1,
"Last4": "1111", // safe to display
"Bin": "411111",
"CardHolder": "Jamie Cardholder",
"Expiry": "2028-12-31",
"UsageType": "Recurring", // or "SingleUse"
"UsageExpiry": "2028-12-31",
"RecurringBlocked": false,
"Verification": { "CardVerified": true, "CvvMatch": true,
"StreetMatch": false, "PostalMatch": true },
"Approved": ..., "TxRef": ..., "AuthCode": ... // meaningful only when a charge was sent
}
Field names are capitalised exactly as shown. POST Token and
Ref to your server and show your confirmation, but do not treat the
browser message as proof of payment for anything of value: confirm on your server
through the API or webhooks.
Codes you can receive
On onDecline (cv:decline)
CARD_NOT_ACCEPTED-- your Card Policy refuses this card's brand or type.messageis your refusal text. Nothing is verified, charged or stored.VALIDATION-- the server rejected a field (card number, expiry, CVC, name, or a required postal code / street).PAV_DECLINE-- the card could not be verified.CHARGE_DECLINE-- the charge was declined (only when a charge was sent).CARD_GUARD-- too many different cards were tried; the attempt is refused.CONFIG_ERROR-- only when a charge was sent: theprocessorIdis invalid, inactive, or not aligned with the segment.
On onError (cv:error)
READY_TIMEOUT-- raised bycv-embed.jswhen the form does not report ready within 15 seconds. Usually a wrongformUrl, an IFrame Host that does not match the page, or a blockedframe-src.INVALID_KEY-- the public key is wrong, belongs to another interface, or the interface is disabled.ORIGIN_MISMATCH-- the submit did not come from the registered origin.INVALID_AMOUNT-- the charge amount is out of range (over $999,999.99).UNSUPPORTED_PROTOCOL-- this version ofcv-embed.jsis no longer accepted. Move to the current version (see below).BUSY-- a submit is already in progress.NETWORK_ERROR,TIMEOUT-- the request did not complete; let the cardholder try again.CONFIG_ERROR(form not configured),INVALID_REQUEST,SERVER_ERROR,PARSE_ERROR,PROCESSING_TIMEOUT-- the form or the charge setup could not complete the request; show the message and contact support if it persists.
Show message to the cardholder for declines and validation failures; it
is written for them. Never show or log anything the cardholder typed.
6. Card usage: single use or recurring
Set profile.usageCode on the submit that saves the card. It decides how
the stored card may be used later -- see
Card usage & lifecycle.
189(or omitted) -- single use. Charges need the cardholder present and a CVC each time. The card is kept untilusageExpiryif you send one, otherwise for the interface's default period (365 days unless changed).190-- recurring (card on file). Only a recurring card can later be charged by the merchant without the cardholder present, under the stored-credential rules described in Card usage. It is kept until the card itself expires;usageExpiryis ignored.
Send the number, not a string, and use only these two values. On IFRAME 1 and 3 with
the recurring checkbox shown, an omitted usageCode follows the checkbox;
a usageCode you send always wins. IFRAME 4 has no checkbox, so put one on
your page (as in the example) or send a fixed value.
190 only when the cardholder has agreed, and show wording beside the
checkbox or button that says who will charge the card, for what and how often.
Confirm the result: UsageType on the result is what was actually stored.
7. Card Policy
If you have set a Card Policy, it applies to every hosted iframe:
- IFRAME 4 shows only the brand icons your account-wide policy accepts (Visa, Mastercard, American Express, Discover, JCB, UnionPay) and flags a refused brand in the card number field as it is typed, with your message.
- On every template,
cv:fieldchangereportsaccepted: falseand yourmessagewhile a refused card is in the field -- use it to keep your button disabled. - If a refused card is submitted,
onDeclinefires withcode: "CARD_NOT_ACCEPTED". Nothing is verified, charged or stored.
The as-you-type check uses your account-wide policy; the check at submit also applies the segment's override and is the one that decides.
8. Versions, integrity and support
Every Card Vault script is published at a versioned address whose content never changes, so you can and should pin it with Subresource Integrity: the browser then refuses to run the file if it was ever altered.
- Current version:
cv-embed.js1.0.0 (wire protocol 1), released 2026-10-10, athttps://cdn.cardvault.com/embed/1.0.0/cv-embed.jswithintegrity="sha384-ePaZCMD1iCr4nlJCfJTFtzgK6Eku91TQsGMLcH+gEmhBB/dvEQ2Cv3nz1rZVMIBu". This page always lists the current version and its integrity value. - Published files are never updated. A fix or a new feature ships as
a new version (for example
1.0.1) at a new address with its own integrity value. There is no unversioned "latest" address. - Moving to a new version is a two-attribute change -- the version
in
srcand the newintegrityvalue. Test it on staging first. - Pinned versions keep working. Every supported version is tested against each change to the hosted forms before it ships.
- Support window: 18 months. When a new version is released, the
previous one stays supported and served for at least 18 months from the new
version's release date. Merchants are notified on the day a version is deprecated,
with its end-of-support date and the version to move to. After that date the file
may be withdrawn and the iframe may answer
UNSUPPORTED_PROTOCOL. - Security exception. If a version has a security flaw, its support may end early; merchants are contacted directly with the replacement version.
Report a suspected security vulnerability to security@cardvault.com.
Troubleshooting
- Blank iframe, console mentions
frame-ancestors-- the page's origin does not match the interface's IFrame Host. Checkwww, the port and HTTPS. - Blank iframe, console shows a
frame-srcorscript-srcviolation -- your own CSP blocks Card Vault; see the security rules above. - The script does not run, console reports an integrity failure --
the
integrityvalue does not match the version insrc, orcrossorigin="anonymous"is missing. - Error text under the fields is cut off -- on IFRAME 1 and 3,
increase the iframe height; on IFRAME 4, leave
autoResizeon. - The frame does not appear in a site builder's editor or preview -- expected: those run on a different origin. Test on the published page.
frame-ancestors, every message is origin-checked in both directions,
submits are re-checked server-side for origin and public key, and the one script your
page loads is immutable and SRI-pinned.