Skip to content
JS Reference
Last updated

Getting started

Shift4.js is a browser-side JavaScript library that can be used to securely collect sensitive payment information (like credit card numbers).

This documentation describes every object and method made available by the library.

Including Shift4.js

Shift4.js should be included on every page of your site where payment information will be collected. It should never be bundled or hosted on your website, but should always be loaded directly from https://js.dev.shift4.com.

<script type="text/javascript" src="https://js.dev.shift4.com/shift4.js"></script>

Initializing Shift4.js

To get started with Shift4.js, first, call the Shift4() method to create and configure a Shift4 object.

Shift4(publicKey, options)

Create a new Shift4 object and configure it.

Parameters

publicKey | string

Public API key used to identify your account. Your account is identified by a public API key. Once logged in, you can find your API keys in your account settings.

options | object, optional

Additional initialization options.

  • merchantId (string, optional) - identifier of the merchant. Useful especially in the context of platform setups.

Result

Shift4 object

Example

var shift4 =
 Shift4("pu_test_WVMFC9GFuvm54b0uorifKkCh");

Next steps

  • Shift4 object -- the main entry point to all Shift4.js functionality.
  • Components -- collect card details in one field or several.
  • Styling -- customize how components look.