
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:
Name | Type | Description |
---|---|---|
flowId | String | The id of the flow (eg. `checkout`, `application`, `lookup`) |
flowOptions | Object | An object sent to the Ecommerce Gateway that configures the flow |
elementOptions | Object | Optional. This object configures additional display options. See below |
This function returns a VCredit.Element object.
Display options for Vcredit.launch:
Name | Type | Description |
---|---|---|
target | String | the selector of the parent element of where the SDK iframe will be inserted. This option overrides the global target option. |
resizeTo | String | Determines 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.
Name | Type | Description |
---|---|---|
event | String | The type of event (eg. `ready`) |
listener | Function | The 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.
Name | Type | Description |
---|---|---|
event | String | The type of event (eg. `ready`) |
listener | Function | The function that was registered with the on method |
function onReady () {// VCredit ready}// Register 'ready' listenervcredit.on('ready', onReady)// Remove 'ready' listenervcredit.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:
Name | Type | Description |
---|---|---|
event | String | The type of event (eg. `ready`) |
data | Object | Any custom data that pertains to the event. This field may be null. |
element | VCredit.Element | A 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:
Name | Type | Description |
---|---|---|
dom | Element | The actual DOM element that this element represents |
VCredit.Element.destroy
Removes the element from the DOM, cleaning up any listeners associated with it.