// Integrations

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

1. Choose a template

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.

Then open the interface again to read the two values your page needs:

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.

HTMLCHECKOUT PAGE
<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

HTML + JSCHECKOUT PAGE
<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

Callbacks:

Submit data

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.

The host page is in your PCI DSS scope. The hosted iframe removes card data from your systems, but the page that embeds it is still part of your assessment: PCI DSS v4.0.1 requirement 6.4.3 (authorize, justify and verify the integrity of every script on the payment page) and 11.6.1 (detect unauthorized changes to the page and its security headers). Pinning 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.

The result object

onSuccess(result)JSON
{
  "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)

On onError (cv:error)

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.

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.

Recurring needs the cardholder's agreement. Card network rules require the cardholder's consent before a card is stored for future charges. Send 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:

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.

Report a suspected security vulnerability to security@cardvault.com.

Troubleshooting

Security posture, briefly. Card data is typed into and sent from Card Vault's origin only. Framing is locked to one HTTPS origin per interface by 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.