Skip to navigation

Run Tokenization Migration Guide

Move an existing Runner.js v1 integration to Runner.js v2 and Run Tokenization.

Overview

This guide is for ISVs and developers who already collect card or bank account details with Runner v1 (runner.js, versions 1.x) and want to move to Runner v2 (runner-v2.js).

Runner v2 is the SDK for Run Tokenization. It renders a single, themeable card form that stays the same whichever gateway processes your transactions. Run turns on Run Tokenization for each MID.

In short: swap the script tag, keep your existing init() and tokenize() code, set useCvv and useExpiry explicitly, and check whether your server reuses browser tokens.

Migration is optional. Runner v1 continues to work and is not deprecated.

Do I Need to Migrate?

Current ImplementationHow to Update
You want Run Tokenization (one themeable card form that works across gateways)Migrate to v2 and ask Run to enable Run Tokenization on your MIDs.
You only use ACH, or your MIDs will stay on their gateway’s hosted fieldsOptional. On these MIDs, v2 renders the same gateway form as v1.
You pin a 1.x version (for example …/javascripts/1.5.5/runner.js) and don’t want any changesNo action needed. Pinned 1.x bundles never change and never use Run Tokenization.

Run enables Run Tokenization on each MID; your code doesn’t. Loading v2 on a MID without Run Tokenization enabled changes nothing visible.

Migration Steps

1

Replace the Script Tag

<!-- Before: Runner v1 -->
<script src="https://javelin.runpayments.io/javascripts/1.5.5/runner.js"></script>
<!-- After: Runner v2, pinned -->
<script src="https://javelin.runpayments.io/javascripts/2.0.4/runner-v2.js"></script>

Load runner-v2.js, not runner.js. In production, pin a specific version (such as 2.0.4) instead of latest, so a new release never reaches your checkout before you’ve tested it.

Environmentenv valueScript host
Productionproduction (default)https://javelin.runpayments.io
Stagingstaginghttps://javelin-staging.runpayments.io
2

Keep Your Integration Code

The global is still Runner, and the public API is the same as in v1:

var runner = new Runner({ env: 'production' });
runner.init({
element: '#card-form',
publicKey: 'pk_live_xxx',
mid: '496160873888',
});
runner.tokenize(function (result) {
if (result.account_token) {
// Send result.account_token to your server
} else {
console.error(result.tokenizererror);
}
});

These all still work: init, tokenize(done, expMonth?, expYear?), destroy, onLoaded, onTokenize, getTokenizerError, cardDataChanged, validationMessageChange, the Plaid methods, and every v1 option.

3

Set useCvv and useExpiry Explicitly

On MIDs with Run Tokenization enabled, these options default to true (in v1 they defaulted to false). If you’ve never set them, your form will start showing CVV and expiry fields. Set them explicitly so the form looks the way you intend:

runner.init({
element: '#card-form',
publicKey: 'pk_live_xxx',
mid: '496160873888',
useCvv: true,
useExpiry: true,
});
4

Enable Run Tokenization on a Test MID

Send your Run representative the MIDs you want enabled. Start with one staging MID, work through the testing checklist below, then roll out one MID at a time.

5

Update Your Server If It Reuses Browser Tokens

Most integrations need to check this step. See Server-side changes below.

What Isn’t Changing

  • Same global and methods. new Runner(...), init(), tokenize(), destroy() and the v1 callbacks keep their names and signatures.
  • MIDs without Run Tokenization behave exactly as in v1. CardConnect, CyberSource, Payroc and iStream MIDs get the same gateway hosted fields, option defaults and result shape.
  • ACH and Plaid work as before. Continue to pass the Plaid attempt ID on the charge as you do today.
  • Card readers (cardReaderInputId) still tokenize through the gateway, even on Run Tokenization MIDs, because encrypted reader data is tied to that gateway.
  • The Charge API is unchanged. Send the token as account_token to POST /api/v1/charge, with the same payload and response.
  • Validation errors still arrive as JSON ({ "message": "…" }) through validationMessageChange and the hidden #tokenizererror field.

Changes for Run Tokenization

The Card Form

FeatureRunner v1Runner v2 (Run Tokenization MID)
FormThe gateway’s hosted fieldsOne Run-hosted iframe containing card number, expiry and CVV
useCvv / useExpiry defaultfalsetrue
Expiry inputSeparate month and year (on some gateways)One MM/YY field
Default expiry labelExpiration DateExpiry
yearPlaceholder and per-field selectors (cardNumberFieldSelector, payroc*Selector, …)SupportedIgnored; the form renders inside element
StylingGateway-specific CSS formatOne CSS string or object, filtered by an allowlist
inactivitytoDefaults to 300; only works with tokenizeAutomatically: trueDefaults to 0 and fires on its own. This applies only to Run Tokenization fields: on CardConnect, v2 still defaults to 300 and still needs tokenizeAutomatically

New Options

OptionDefaultDescription
layout'default'Field arrangement: default, single-row, stacked or custom
errorDisplay'inline'Show errors inline next to each field, or in one summary region
updateModefalseFor updating a card on file: the expiry field is not shown or required
autoAdvancetrueMoves focus from card number to expiry to CVV as each field is completed

New Callbacks

Set these on the Runner class, not on an instance:

CallbackFires when
Runner.onFieldChangeA field changes. Returns { field, state, valid }; never the field value.
Runner.onBinInfoThe first six digits are entered. Returns the card brand and first six digits.
Runner.onIdleTimeoutCard data that was entered but not submitted is cleared after 5 minutes of inactivity.

The Token Result

// Success (Runner v2, Run Tokenization MID)
{ account_token: "3f2b…", bin: "411111", last4: "1111", brand: "visa", expiry: "12/28" }
// Failure
{ account_token: null, tokenizererror: "Invalid card number" }

The result no longer includes card_info, bank_account or risk_info. Use bin, last4 and brand instead. cardDataChanged does not fire on Run Tokenization MIDs; read the same data from the tokenize() result or from onTokenize.

For the full list of options and styling, see the Run Tokenization reference.

Potential Hurdles

IssueCauseFix
CVV and expiry fields appear unexpectedlyThese now default to true on Run Tokenization MIDsSet useCvv and useExpiry explicitly (step 3)
Server-side charges with saved browser tokens failRun Tokens are now short-lived and single-useSave a vault instead (see Server-side changes)
The form doesn’t load and shows an errorAn unrecognized env value. v1 silently fell back to a different host; v2 refuses to loadUse only production or staging

Good to Know

  • Layout. Card number, expiry and CVV live in one iframe. You can arrange them with layout or css, but you can’t place your own inputs between them.
  • CSS. Properties such as position, z-index, transform, url(...) and @import are removed. Colors, fonts, borders, spacing and grid placement are allowed.
  • Single-page apps. Call runner.destroy() before mounting the form again.

Server-Side Changes

On a Run Tokenization MID, the account_token returned to the browser is a Run Token, a short-lived card session reference:

  • It expires 5 minutes after tokenization.
  • It is single-use: the first charge or vault creation consumes it.
  • It only works for MIDs under the same customer as the MID that created it.

POST /api/v1/bin-info and POST /api/v1/surcharge read the token without consuming it, so you can call them before the charge.

If your server saves the browser token to charge later, that will stop working. Save a vault instead:

You want to…Do this
Charge now and keep the card on fileCharge with vault: "Y", then use the returned vault_id for later charges
Keep a card from a previous chargePOST /api/v1/vault_payment_accounts/from_transaction
Charge a saved cardCharge with vault_id, as you do today

Existing vaults keep working after you migrate. As long as Run Tokenization stays enabled on a MID, vaults created through it can still be charged even if Run later moves that MID to a different gateway.

If you charge with a Run Token on a MID that doesn’t have Run Tokenization enabled, the charge is declined with the message Card token is invalid or expired — please re-enter card details. If you see this, ask the customer to enter their card again.

Testing Checklist

Run these checks on a staging MID with Run Tokenization enabled:

  • The form shows the fields you expect (CVV, expiry).
  • A valid test card returns account_token, bin, last4 and brand.
  • An invalid card number shows an error and returns account_token: null.
  • A charge with the token is approved, and a second charge with the same token is declined.
  • A charge with vault: "Y" creates a vault, and a later charge with that vault_id is approved.
  • A charge on a vault created before the migration is approved.
  • Your styling, layout and error placement look right on mobile and desktop.
  • If you use updateMode, the expiry you pass to tokenize() reaches the charge.

Rolling Back

To roll back, restore your pinned v1 script tag. Vaults are stored by Run, so vaults created while you were on v2 keep working. If you also want a MID taken off Run Tokenization, ask your Run representative to disable it.