JS fields
Separate card number, expiry and CVC inputs placed anywhere in your own form, styled to match it.
4242 4242 4242 4242 (approve), 4000 0000 0000 0002
(decline) or 4000 0000 0000 0069 (card not accepted), with any future
expiry and any CVC.
JS fields put three separate Card Vault inputs -- card number, expiry and CVC -- wherever you want them in your own form. Everything else on this page is the shop's own markup: fonts, colours, layout, the contact and shipping fields, the loyalty and gift-note fields and the Pay button. Switch the theme to see the card inputs follow the design.
Field messages carry the field name and state, never what was typed. On your own page, keep results out of logs, analytics and session-replay tools.
Style the card fields
cv-fields.js has a style option and
instance.setStyle(style). The values are an allow-list -- anything else is
dropped -- and the card field re-checks every value before applying it:
<script src="https://cdn.cardvault.com/fields/1.0.0/cv-fields.js" integrity="sha384-Gr9ligBK5csUw/LxtPtaKnhJ4VkV0blw9qJDR+OYNSb01KZSQ0sSdt74HymZlQc5" crossorigin="anonymous"></script> <script> var fields = CV.fields.create({ publicKey: "<the interface's Public Key>", fieldUrl: "https://cce.cardvault.com/<your-interface>/JSFI", collectUrl: "https://cce.cardvault.com/<your-interface>/JSFIP", fieldHeight: "44px", style: { fontFamily: "Georgia, serif", fontSize: "15px", color: "#3B2A1E", placeholderColor: "#A08C7A", background: "#FFFFFF", borderColor: "#D9C7B3", borderRadius: "10px", paddingX: "12px", focusColor: "#9A4F1C", focusRingColor: "rgba(154,79,28,0.18)" }, onReady: function () { /* enable your Pay button */ }, onSuccess: function (r) { /* send r.Token to YOUR server */ }, onDecline: function (d) { /* d.code, d.message */ }, onError: function (d) { /* d.code, d.message */ } }); fields.mount({ pan: "#card-number", expiry: "#card-expiry", cvv: "#card-cvc" }); // on your Pay button -- your own fields travel in profile: fields.submit({ ref: "ORDER-1001", profile: { fullName: "Alex Example", email: "alex@example.com", street: "12 Wharf Street", city: "Halifax", region: "NS", postal: "B3J 1A1", customFields: [{ key: "Loyalty", value: "HLR-0042" }] } }); </script>
- Style properties --
fontFamily,fontSize(10-24px),fontWeight(300-700),color,placeholderColor,background,borderColor,borderWidth(0-3px),borderRadius(0-24px),paddingX(0-24px),height(24-64px),focusColor,focusRingColor,validColor,errorColorandshowIndicator(true / false). Colours are#rgb,#rrggbb,#rrggbbaa,rgb()orrgba(). - Fonts must be installed on the visitor's device: web fonts cannot load
inside the card field. Give a stack that ends in a generic family
(
"Inter, Segoe UI, sans-serif"). - Dark pages -- if your page sets
color-scheme: dark, give the card field iframescolor-scheme: light. Otherwise the browser paints a light backdrop behind them, which shows at the corners of a rounded field. setStylemerges into the current style; a property set tonullgoes back to the default.- The result carries the card details, your reference and your custom fields. Contact and address details are stored with the card, not echoed back.
Mounting, callbacks, Card Policy and the security rules for the page are in JS fields.