Skip to content
Docs

Checkout

Shift4 Checkout is a hosted payment form that handles the entire payment flow for you. It collects card details, validates input, handles 3D Secure authentication, and creates the charge.

How it works

To open Checkout, first create a Checkout Session on your backend and pass its clientSecret to the frontend. Then use our Checkout library, available at https://dev.shift4.com/checkout.js, to render the Checkout app in the browser.

Once you have your Checkout Session, there are two ways to integrate with Checkout on the frontend:

  • Simple integration provides a button that opens Checkout and, after successful payment, submits your payment form with Checkout results added as hidden input fields.
  • Custom integration allows you to open Checkout from JavaScript and handle the Checkout results in the JavaScript callback function.

Both are shown in Using Checkout.

Please check our guidelines for CSP here.

Integration models

Checkout Sessions

A Checkout Session is a server-created configuration that defines what the customer is paying for and how the Checkout form behaves. Sessions must be created using a secret API key, which allows Shift4 to enforce rate limiting and prevent abuse scenarios such as automated card testing.

Once created, a session is immutable. If changes are required, create a new session.

See the Create a checkout session endpoint in the API Reference.

Configuration parameters

These parameters can be added to your <script> tag to configure and customize Checkout.

Required

Optional

ParameterDescription
data-imageThe relative (or absolute) URL to image of your brand or product. Recommended image size is 70×70 pixels. Recommended image types are .png, .jpeg, and .gif.
data-nameThe name of your company or website.
data-descriptionThe description of the product that is being sold.
data-payment-buttonThe text that will appear on the payment button in Checkout. If the text contains {{amount}}, it will be replaced by a charge amount. Otherwise, the charge amount will be appended at the end.
data-emailIf provided, it will be used to the pre-fill email field in Checkout.
data-checkout-buttonThe text that will appear on the button that will be added on your website.
data-classValue of the HTML class attribute that will be set on the payment button on your website.
data-localeThe language that will be used in Checkout, provided as a two-letter code from Supported languages. If not provided, Checkout will be displayed in the user's preferred language (defined in the browser).
data-shipping-addressIf set to true, Checkout will collect the customer's shipping address.
data-billing-addressIf set to true, Checkout will collect the customer's billing address.
data-payment-button-background-colorSets color of a payment button.
data-typographySets fonts used in Checkout form.
data-show-payment-amountIf set to false amount on the payment button is hidden. Default setting is true.

Result parameters

These parameters are added to your payment <form> tag after a successful payment.

ParameterDescription
shift4EmailThe email address that was provided by the user in Checkout.
shift4CustomerIdIdentifier of the customer object that was used by Checkout. It can be either a customer provided when Checkout was initialized, or a new customer created by Checkout.
shift4ChargeIdIdentifier of the charge object that was created by Checkout.
shift4SubscriptionIdIdentifier of the subscription object that was created by Checkout. Only present if Checkout was configured to create a recurring subscription.

Billing and shipping details

These parameters are added alongside the ones above. Billing parameters are only populated when data-billing-address is set to true, and shipping parameters only when data-shipping-address is set to true.

ParameterDescription
shift4BillingNameThe name provided in the billing details.
shift4BillingAddressLine1First line of the billing address.
shift4BillingAddressZipPostal code of the billing address.
shift4BillingAddressCityCity of the billing address.
shift4BillingAddressCountryCountry of the billing address.
shift4BillingVatThe VAT number provided in the billing details.
shift4ShippingNameThe name provided in the shipping details.
shift4ShippingAddressLine1First line of the shipping address.
shift4ShippingAddressZipPostal code of the shipping address.
shift4ShippingAddressCityCity of the shipping address.
shift4ShippingAddressCountryCountry of the shipping address.

Supported languages

The following languages are supported by Checkout:

CodeLanguage
beBelarusian
bgBulgarian
csCzech
daDanish
deGerman
elGreek
enEnglish
esSpanish
etEstonian
fiFinnish
frFrench
hrCroatian
huHungarian
itItalian
iwHebrew
ltLithuanian
lvLatvian
nlDutch
noNorwegian
plPolish
ptPortuguese
roRomanian
ruRussian
skSlovak
slSlovenian

If the requested code is not on this list, Checkout falls back to English.

Next steps

  • Charges -- understand the charge object created behind the scenes.