Subscribe Pro Vault Hosted Iframe API


The following documentation describes the Subscribe Pro Vault Hosted Iframe API, including methods, events, and configuration options.

Loading the Iframe Client Script

To load the Subscribe Pro Vault Hosted Iframe client script, add the following <script> tag to your page:

<script
  type="text/javascript"
  src="https://vault.subscribepro.com/js/iframe-client-1.11.0.js"
></script>

Accessing the Iframe Client

Access the Subscribe Pro Vault Hosted Iframe client by referencing the global IframeClient object.

IframeClient.init(newConfig: ClientConfigType)

The Subscribe Pro Vault Hosted Iframe client script is configured by passing a configuration object to the IframeClient.init() function. The configuration object has the following properties:

ClientConfigType Type

PropertyRequiredTypeDescription
newConfig.vaultUrlStringThe URL of the Subscribe Pro Vault environment to use.
Default: https://vault.subscribepro.com
newConfig.vaultEnvironmentIdYesStringThe ID of the Subscribe Pro Vault environment to use. This is a UUID which you should retrieve from the Subscribe Pro Commerce Platform environment you are using.
newConfig.numberIframeYesObjectObject representing configuration for the card number iframe / field.
newConfig.numberIframe.containerYesStringThe ID of the <div> element.
newConfig.numberIframe.titleStringTitle to use for the document title inside iframe.
newConfig.numberIframe.inputTypeStringType of <input> element: text, number or password.
newConfig.numberIframe.inputModeStringInput mode of <input> element: text, numeric, etc. See: [inputmode - HTML: HyperText Markup Language
newConfig.numberIframe.inputStyleStringInline styles to apply directly to the <input> element.
newConfig.numberIframe.inputClassStringValue to use for the class attribute on the <input> element.
newConfig.numberIframe.inputPlaceholderTextStringPlaceholder text for the <input> element.
newConfig.numberIframe.styleSheetStringStyles to apply inside a <style> tag within the iframe document.
newConfig.cvvIframeConditionalObjectObject representing configuration for the CVV iframe / field. Required when showCvv is true.
newConfig.cvvIframe.containerYesStringThe ID of the <div> element in which to place the CVV iframe.
newConfig.cvvIframe.titleStringTitle to use for the document title inside iframe.
newConfig.cvvIframe.inputTypeStringType of <input> element: text, number or password.
newConfig.cvvIframe.inputModeStringInput mode of <input> element: text, numeric, etc. See: [inputmode - HTML: HyperText Markup Language
newConfig.cvvIframe.inputStyleStringInline styles to apply directly to the <input> element.
newConfig.cvvIframe.inputClassStringValue to use for the class attribute on the <input> element.
newConfig.cvvIframe.inputPlaceholderTextStringPlaceholder text for the <input> element.
newConfig.cvvIframe.styleSheetStringStyles to apply inside a <style> tag within the iframe document.
newConfig.accountIframeConditionalObjectObject representing configuration for the bank account number iframe / field.
newConfig.accountIframe.containerYesStringThe ID of the <div> element in which to place the bank account iframe.
newConfig.accountIframe.titleStringTitle to use for the document title inside iframe.
newConfig.accountIframe.inputTypeStringType of <input> element: text, number or password.
newConfig.accountIframe.inputModeStringInput mode of <input> element: text, numeric, etc. See: [inputmode - HTML: HyperText Markup Language
newConfig.accountIframe.inputStyleStringInline styles to apply directly to the <input> element.
newConfig.accountIframe.inputClassStringValue to use for the class attribute on the <input> element.
newConfig.accountIframe.inputPlaceholderTextStringPlaceholder text for the <input> element.
newConfig.accountIframe.styleSheetStringStyles to apply inside a <style> tag within the iframe document.
newConfig.showCvvBooleanWhether or not to show the CVV field / iframe.
Default: true
newConfig.requireCvvBooleanWhether or not to require the CVV field to be filled before tokenization.
Default: true
newConfig.requireValidationBooleanWhether or not to require that the card number be successfully validated before tokenization.
Default: true
newConfig.enablePrettyFormatBooleanWhether or not to enable pretty formatting of the card number.
Default: false

IframeClient.tokenize()

Tokenizes the card data entered into the card number and CVV fields (or other payment data).

IframeClient.setInputElementStyle({ fieldCode, style })

Sets the style of the specified input element. The method has the following parameters:

ParameterTypeDescription
fieldCodeStringThe field code of the input element to set the style of. One of: number, cvv, account
styleObjectA string containing CSS styles to apply to the input element.

IframeClient.addInputElementStyle({ fieldCode, style })

Adds the specified style to the specified input element. The method has the following parameters:

ParameterTypeDescription
fieldCodeStringThe field code of the input element to set the style of. One of: number, cvv, account
styleObjectA string containing CSS styles to apply to the input element.

IframeClient.setStyleSheet({ fieldCode, styleSheet })

Sets the contents of a stylesheet (<style> element) which will be created inside the iframe and thus can apply styles to the specified input element.

The method has the following parameters:

ParameterTypeDescription
fieldCodeStringThe field code of the input element to set the style of. One of: number, cvv, account
styleSheetStringA string containing CSS style content to apply inside the created <style> element.

IframeClient.setInputClass({ fieldCode, className })

Sets the CSS class of the specified input element. The method has the following parameters:

ParameterTypeDescription
fieldCodeStringThe field code of the input element to set the style of. One of: number, cvv, account
classNameStringThe CSS class to apply to the input element.

IframeClient.on(eventName, callback)

This method allows you to register a callback function to be called when the specified event occurs.

Please see here for detail about each event type and the data returned to the event handler callback function: Subscribe Pro Vault Hosted Iframe Events