// Integrations

JS fields / iframe

Card inputs that live inside your checkout but outside your PCI scope: each sensitive field renders in a sandboxed, Card Vault-hosted iframe, so card data posts directly to the vault and never touches your page's JavaScript or your servers.

How it works

Markup

HTMLCHECKOUT PAGE
<script src="https://cdn.cardvault.com/fields/1.0.0/cv-fields.js"
        integrity="sha384-Gr9ligBK5csUw/LxtPtaKnhJ4VkV0blw9qJDR+OYNSb01KZSQ0sSdt74HymZlQc5"
        crossorigin="anonymous"></script>

<div id="card-number"></div>
<div id="card-expiry"></div>
<div id="card-cvv"></div>
<button id="pay" disabled>Pay</button>

Create and mount

JSCHECKOUT PAGE
var fields = CV.fields.create({
  publicKey:  "cvpk_test_...",          // publishable key -- safe in the browser
  fieldUrl:   "https://<your field URL from the dashboard>",
  collectUrl: "https://<your collect URL from the dashboard>",

  fieldHeight: "38px",                  // optional (default 38px; width 100%)
  style: { borderRadius: "8px", color: "#222222" },   // optional: match your design

  onReady:   function ()    { document.getElementById("pay").disabled = false; },
  onSuccess: function (res) { /* res.token etc. -- send to YOUR server */ },
  onDecline: function (ctx) {
    // ctx.code, ctx.message, ctx.ref -- declined by the issuer, or
    // ctx.code === "CARD_NOT_ACCEPTED" when your Card Policy refuses the card
  },
  onChange:  function (ctx) {
    // ctx.field, ctx.valid, ctx.empty, ctx.brand -- and for the card number:
    // ctx.accepted === false + ctx.message when your Card Policy refuses the card
  },
  onError:   function (ctx) { /* ctx.code, ctx.message */ },
  onValidationFail: function (ctx) {
    // ctx.field ("pan" | "expiry" | "cvv") + ctx.fieldId -- highlight the input
  }
});

fields.mount({ pan: "#card-number", expiry: "#card-expiry", cvv: "#card-cvv" });

Submit: vault only, or vault + charge

JSCHECKOUT PAGE
// Vault only: profile details ride along with the capture
fields.submit({
  ref:     "BOOKING-4821",
  profile: { fullName: "Jamie Cardholder", email: "jamie@example.com" }
});

// Vault + charge in one step
fields.submit(
  { ref: "INV-2026-0042" },
  {
    amount:          10.99,     // DECIMAL DOLLARS here -- converted internally;
                                // maximum $999,999.99
    currency:        "USD",
    vaultOnSuccess:  true,      // store the card if the charge approves
    transactionType: 0          // 0 = charge, 1 = pre-authorization
  }
);

Submits are debounced (2 seconds) and refused until onReady has fired. Outcomes arrive on your callbacks: onSuccess with the result (token + card metadata, plus the transaction outcome when charging), onDecline when the issuer says no -- or with code: "CARD_NOT_ACCEPTED" when your Card Policy refuses the card, before anything is charged or stored -- and onError for everything else.

API summary

Pin the script with integrity and crossorigin="anonymous".

Field events

onChange, onFocus, and onBlur fire as the cardholder types (with field identity, never contents), so you can drive your own inline styling. onValidationFail identifies exactly which field failed (ctx.field, ctx.fieldId) with a display-ready reason -- highlight the right input without ever being able to read it.

Card Policy: refused cards

If you have set a Card Policy, the card number field checks each card as it is typed:

The as-you-type check applies your account-wide policy; the check at submit also applies any segment override and is the one that decides.

Security posture, briefly. Field iframes are sandboxed, card data moves iframe-to-iframe inside Card Vault's origin, every submit carries a one-time nonce, and your page holds only a publishable key -- secret keys never appear in the browser.