Run Tokenization (Runner.js v2)
Collect card details in a PCI-safe, fully themeable iframe and get back a gateway-agnostic Run Token.
Overview
Runner.js v2 is Run’s browser SDK for Agnostic Gateway Tokenization. It mounts a secure card entry form (card number, expiry and CVV) on your checkout page. Clients type their card details into an iframe hosted by the Runner.js tokenization service, so the data never touches your page or your servers. In return you get an account_token that you can charge or vault through the Run API.
You don’t choose a gateway in your front-end code. When you call init(), Runner looks up the merchant’s configuration and mounts the right integration automatically. This guide covers the flexible, fully themeable card tokenizer used by accounts enabled for Run Tokenization.
Run turns on Run Tokenization for each MID. Send a Run Request asking for Run Tokens to be activated for a particular merchant. On a MID without Run Tokenization, v2 renders the gateway’s hosted fields and returns the v1 result shape.
If you’re moving an existing Runner.js v1 integration, follow the Run Tokenization Migration Guide.
How It Works
- Card data stays in the iframe. You only ever see the
account_tokenand PCI-permitted metadata:bin(first 6 digits),last4andbrand. - The integration is selected for you. There is no gateway parameter to pass.
- One iframe, three fields. Card number, expiry and CVV are all rendered in a single iframe. You control how they’re arranged inside it (see Field layout).
Quick Start
That’s the whole happy path. Everything else is optional configuration.
Loading the SDK
Load runner-v2.js from the host that matches your environment:
The script exposes a global Runner class. Create one instance per card form:
/javascripts/latest/runner-v2.js always serves the newest release. To stay on a specific version, pin it in the path: /javascripts/2.0.4/runner-v2.js.
env must be one of the supported values. If it isn’t, the SDK refuses to send tokenization requests rather than risk routing card data to an unknown origin.
Constructor Options
Configuration
Pass all options to runner.init(). Only element, publicKey and mid are required.
Required
Labels & Placeholders
Field Behavior
Layout & Styling Options
Built-In Capabilities
These work automatically. No configuration is needed.
Card Brand Recognition
The brand is detected from the BIN on every keystroke, and a live brand icon appears in the field. Supported brands: Visa, Mastercard, American Express, Discover, JCB and Diners Club. Unrecognized ranges fall back to a generic 16-digit (4-4-4-4) rule set and never block the form.
Auto-Formatting
Digits are grouped by brand as the client types, for example 4-4-4-4 for most cards and 4-6-5 for American Express.
Luhn and Length Validation
Real-time and brand-aware. An error appears only once the field reaches a valid length for the brand without passing the check. A failing check blocks tokenization.
BIN Lookup
A debounced lookup runs on the first 6 digits and surfaces brand metadata through Runner.onBinInfo. A failed lookup never blocks tokenization.
Masked Metadata
The token response includes the PCI-permitted bin (first 6) and last4. The full card number is never exposed.
CVV Length by Brand
4 digits for American Express, 3 for all other brands.
Browser Autofill
Standard autocomplete attributes (cc-number, cc-exp, cc-csc) are set so browser card autofill works.
Auto-Resize
The iframe reports its height to your page and adjusts as the layout or error messages change.
PCI Idle-Clear
If card fields contain typed but unsubmitted data for 5 minutes with no activity, they are cleared automatically so an abandoned card number or CVV never lingers on the page. This fires Runner.onIdleTimeout. It’s a security control and can’t be configured or disabled. It never affects a card that has already been tokenized.
Layout & Styling
The card form is fully themeable. Because your CSS is applied inside the secure card iframe, it’s filtered through a security allowlist. You get full control over colors, fonts, borders, spacing and grid or flex layout. Properties that could be used to hide or overlay fields are removed.
Field Layout
The form container (.rn-form) is a CSS grid. Every field and every error message is its own grid item, so you aren’t limited to a fixed row.
Presets
Choose a preset with the layout option:
Custom Layouts
For full control, set layout: 'custom' and target the styling hooks with css. All grid properties are on the allowlist.
All three fields live in one iframe. You can arrange them freely inside it, but you can’t place your own page inputs (such as a cardholder name field) between them. This is a deliberate PCI boundary.
Styling
Pass CSS with the css option, either as a CSS string or as an object of selectors mapped to property/value pairs:
Styling Hooks
Error Display
Choose where validation messages appear with errorDisplay:
To control your own submit button in real time, listen to Runner.onFieldChange rather than relying on the visible errors.
CSS Allowlist
Unrestricted CSS inside a card iframe is a clickjacking risk: a malicious rule could move or hide the CVV field and overlay it on the host page. To prevent this, Runner only accepts a sanitized allowlist of layout and theming properties. Anything not listed below is removed.
How Your CSS Is Sanitized
- Comments (
/* ... */) are removed first so they can’t hide anything. - Only flat
selector { property: value; }blocks are read. At-rules such as@import,@charsetand@mediaare dropped, and nested blocks aren’t supported. - Selectors containing
<,>,\or@are rejected. - Each declaration is kept only if its property is on the allowlist.
- A declaration is dropped if its value contains
url(,expression(,image-set(,javascript:,<,>,\,@or a comment delimiter. !importantis removed, so you can’t override critical layout rules.
Allowed Properties
Color & Typography
color, background, background-color, font, font-family, font-size, font-weight, font-style, line-height, letter-spacing, text-align, text-transform, text-decoration
Box Model & Sizing
padding, padding-top, padding-right, padding-bottom, padding-left, margin, margin-top, margin-right, margin-bottom, margin-left, width, min-width, max-width, height, min-height, max-height, box-sizing
Borders & Focus Rings
border, border-top, border-right, border-bottom, border-left, border-color, border-width, border-style, border-radius, outline, outline-color, outline-width, outline-style, outline-offset, box-shadow
Flexbox Layout
display, gap, row-gap, column-gap, flex, flex-direction, flex-wrap, flex-grow, flex-shrink, flex-basis, align-items, align-content, align-self, justify-content, justify-items, justify-self
Grid Layout & Ordering
grid, grid-template, grid-template-columns, grid-template-rows, grid-template-areas, grid-column, grid-row, grid-area, grid-auto-flow, grid-auto-columns, grid-auto-rows, place-items, place-content, place-self, order, white-space, vertical-align
These only rearrange items inside the iframe. They can’t position anything relative to your page.
Transitions
transition, transition-property, transition-duration, transition-timing-function
Not Allowed
If a property you set has no effect, check it against the allowlist above. Positioning and remote-resource properties are removed on purpose.
Methods, Events & Tokens
Methods
Call these on your Runner instance.
onTokenize Payload
expiration is a legacy field kept for v1 compatibility. Use expiry instead.
bin, last4, brand and expiry match the token result when the integration supplies them, which it does for Run Tokenization accounts.
Events
Three real-time hooks let you drive your own UI, such as enabling your submit button only when the card is valid, without waiting for tokenize().
Set these hooks as functions on the global Runner class, not on your instance.
Runner.onFieldChange
Fires on every change to the card number, expiry or CVV field.
The field’s value is never included. Only the field name and its validity cross the iframe boundary, so the card number and CVV never reach your page.
Runner.onBinInfo
Fires once 6 digits have been entered, and again when server-side enrichment arrives.
In this release BIN data from onBinInfo is for display only: card_brand and the first six digits are derived from the card number prefix. For issuer, country and commercial-card data (for example, for L2/L3 or routing decisions), call the server-side POST /api/v1/bin-info endpoint with the returned token after tokenization.
Runner.onIdleTimeout
Fires when card fields with typed but unsubmitted data are cleared after 5 minutes of inactivity. Use it to reset your own UI, for example to re-enable a card entry state or hide a stale summary.
This only fires for unsubmitted data. A card that has already been tokenized is masked and read-only, so it’s left as is.
Token Result
This is the object passed to your tokenize(done) callback. The same data is available through onTokenize.
Success
Failure
Always check that account_token is present before continuing. The token expires 5 minutes after tokenization, so charge or vault it promptly. Never send raw card data to your server.
Examples
Card-On-File Update
Re-tokenize a stored card without collecting expiry or CVV again.
In updateMode, an empty expiry is sent to the tokenizer unless you pass one to tokenize(done, expMonth, expYear). Make sure your flow supplies the expiry wherever the processor requires it.
Enable Your Submit Button Only When the Card Is Valid
Themed Single-Row Form with Summary Errors
Single-Page Apps
Destroy the form before navigating away or mounting it again.
Notes & Limitations
- Send the token, never card data.
account_tokenis what goes to your server. It expires 5 minutes after tokenization, so charge or vault it promptly. - Fields share one iframe. You can arrange card number, expiry and CVV freely inside the form, but you can’t place your own inputs between them. This is a deliberate PCI boundary.
- Supported brands. Visa, Mastercard, American Express, Discover, JCB and Diners Club. Unrecognized BINs use a generic 16-digit rule set and still tokenize.
- BIN data is display-only in this release. For issuer, country and commercial-card data used for L2/L3 or routing, call
POST /api/v1/bin-infofrom your server after tokenization. - updateMode and expiry. Pass
expMonthandexpYeartotokenize()if your processor requires an expiry. Use a 4-digit year ('2028'); CyberSource requires it. - CSS is allowlisted. If a property has no effect, check the CSS allowlist.