Shift4 object is the main entry point to all Shift4.js functionalities. Create one by initializing Shift4.js.
Create a new component of the specified type.
type | string
Component type to be created. It could be a card - a single component to collect all card details. To collect card details in separate fields, use ComponentGroup.createComponent().
options | object
Plain object with additional options.
var card = shift4.createComponent("card");Create a new grouping object that will be used to create multiple related components, such as number, expiry and cvc components that will be used together to collect details for a single card.
var components = shift4.createComponentGroup();Tokenize card data from a given component or component group by sending it to the "create token" API method.
component | Component | ComponentGroup
A single component or a group of components from which sensitive card data will be tokenized.
data | object
Additional data that will be included in the tokens API request. The "create token" API method lists all permitted keys.
For security reasons, this parameter cannot be used to send the following fields in the request: number, expMonth, expYear and cvc. Values of these fields must be collected using components.
Promise object
var card = shift4.createComponent("card");
function onFormSubmit() {
shift4.createToken(card)
.then(tokenCreatedCallback)
.catch(errorCallback);
}Starts a 3D Secure process.
Depending on the card and the card's issuer, this may result in the 3D Secure challenge being displayed in an iframe or popup window.
request | object
The request object will be sent to the API. The following keys are allowed:
card(string) - a token identifier (generated by thecreateToken()method) or a card identifier (created using the Cards API).amount(integer) - the amount in minor units of the given currency (for example, 10€ is represented as "1000" and 10¥ is represented as "10"), which must match the value that will be used to create a Charge using APIcurrency(string) - the currency, represented as a three-letter ISO currency code, must match the value later used to create a Charge using APImerchantAccountId(string, optional) - the merchant account identifier that will be used to complete the 3D Secure processchallengeIndicator(string, optional) - this field is used to express preference when it comes to the 3DS flow. Possible values:no_preferenceno_challenge_requested- merchant prefers frictionless flowchallenge_requested_requestor_preference- merchant strongly prefers challenge flowchallenge_requested_mandate- merchant strongly prefers challenge flow due to PSD2 requirements
Promise object
function tokenCreatedCallback(token) {
var request = {
card: token.id,
amount: 2499,
currency: 'USD',
};
shift4.verifyThreeDSecure(request)
.then(threeDSecureCompletedCallback)
.catch(errorCallback);
} - Components -- mount components and collect card details.
- Styling -- customize how components look.