Versatile Logo
IntroductionGetting StartedConfigurationFlowsAPI ReferenceGeneral EventsCommon EventsVCredit.launchVCredit.onVCredit.offVCredit.destroyVCredit.EventVCredit.Element

API Reference

General Events

The following events are general purpose events and not associated with any flow.

ready

This event is fired when the SDK has been initialized

error

This event is fired when there's a general error in the system. Payload is an error object

Common Events

The following events are common to all flows.

flow.start

This event is fired at the start of the user interaction for each flow. There is one parameter, flowId, that indicates the flow that was launched.

flow.start.{flowId}

A specialization of flow.start that is fired for a specific flow.

flow.end

This event is fired at the end of the user interaction for each flow. There is one parameter, flowId, that indicates the flow that was launched.

flow.end.{flowId}

A specialization of flow.end that is fired for a specific flow.

VCredit.launch

This launches a UI flow

It has the following parameters:

NameTypeDescription
flowIdStringThe id of the flow (eg. `checkout`, `application`, `lookup`)
flowOptionsObjectAn object sent to the Ecommerce Gateway that configures the flow
elementOptionsObjectOptional. This object configures additional display options. See below

This function returns a VCredit.Element object.

Display options for Vcredit.launch:

NameTypeDescription
targetStringthe selector of the parent element of where the SDK iframe will be inserted. This option overrides the global target option.
resizeToStringDetermines how the iframe is resized. A value of `target`, resizes the iframe to the dimensions of the target element. A value of `content` resizes the frame to dimesions of its contents. Default is `target`.
var vcredit = VCredit.create({
secureSessionUrl: 'https://yourbackend.com/sessions'
})
vcredit.on('ready', function () {
vcredit.launch('application', null, {
target: '#modal',
resizeTo: 'target'
})
})

VCredit.on

Registers an event listener

It has the following arguments.

NameTypeDescription
eventStringThe type of event (eg. `ready`)
listenerFunctionThe function that listens for the event. The argument passed to the listener will be a VCredit.Event object.
var vcredit = VCredit.create({
secureSessionUrl: 'https://yourbackend.com/sessions'
})
vcredit.on('ready', function () {
// VCredit ready
})

VCredit.off

Removes an event listener

It has the following arguments.

NameTypeDescription
eventStringThe type of event (eg. `ready`)
listenerFunctionThe function that was registered with the on method
function onReady () {
// VCredit ready
}
// Register 'ready' listener
vcredit.on('ready', onReady)
// Remove 'ready' listener
vcredit.off('ready', onReady)

VCredit.destroy

Removes any listeners and other data associated with the VCredit object

vcredit.destroy()

VCredit.Event

Represents an event in the Storefront SDK. The event has the following properties:

NameTypeDescription
eventStringThe type of event (eg. `ready`)
dataObjectAny custom data that pertains to the event. This field may be null.
elementVCredit.ElementA VCredit.Element object associated with the event or null

VCredit.Element

Wrapper for a DOM element that represents the root UI element in the flow

An element has the following properties:

NameTypeDescription
domElementThe actual DOM element that this element represents

VCredit.Element.destroy

Removes the element from the DOM, cleaning up any listeners associated with it.