JavaScript SDK script configuration
Provider Name | User Login Name | User Password | MFA Action |
---|---|---|---|
Credential 1 | user_1 | pass_good | None |
Credential 2 | user_2 | pass_good | None |
window.grailpay.init(initProps)
method. This method allows you to pass the necessary configuration options
and callbacks to handle various events during the integration process. Ensure that this method has been added within
the BODY tag of your HTML file.
Here’s a breakdown of the available types and the required parameters for successful initialization:
InitProps
interface represents the configuration options and callbacks that you can provide when initializing the widget.
token
( required ) Your access token . A unique authentication token that identifies the user and authorizes
access to the Bank Link SDK.userId
( optional ) The unique identifier of the user for whom you want to perform operations.
If not provided, we will create it on our end.vendorId
( optional ) Your vendor identifier to ensure secure communication with the servers.role
( optional ) The user role to perform operations can be specified as either “business” or
“person”. If not provided, we will create user with business role.timeout
( optional ) The timeout (in seconds) is set to delay the callback in the onBankConnected function,
allowing for the return of bank account details along with the connection status. The minimum timeout value is 10
seconds.branding_name
(optional) The branding name replaces the application name and is displayed on the dashboard of
the bank link widget. It must be a maximum of 20 characters, including spaces.subtitle
(optional) The subtitle will replace the text on the finder screen beneath the branding name. It must
be a maximum of 100 characters, including spaces.searchPlaceholder
(optional) It will replace the placeholder text on the finder screen where you can search for
a bank from the list. This must also be a maximum of 30 characters, including spaces.onError
- A callback function, that will be called when an error occurs during the operation. It reports
intermediate account addition failure events, integration errors, and GrailPay application launch errors.
onUserCreated
- A callback function, will be invoked when a new user is created during the operation. It
reports that the intermediate user account has been successfully created.
onBankConnected
- A callback function, is triggered when a connection with a bank account is established during the
operation. It reports intermediate account details, including the connection status as either failed, pending,
or complete. If the account connection remains pending or failed, you must wait for the webhook to provide complete
details.
onLinkedDefaultAccount
- A callback function, is triggered when a connection with a bank account is established
during the operation. It reports selected default account details, including the connection status as either
failed, pending, or complete.
onLinkExit
- A callback function, that will be called when the Bank Link SDK is closed. This method refers to the action where a consumer has exited or terminated the flow – either abruptly or intentionally, which marks the end of the session.
button
Elementgrp__pay
. When the user clicks on this button, the Bank Link SDK will be automatically opened, and the necessary user interactions and authentication will be handled internally.
To implement this option, include the following HTML code on your page:
openGrailPayWidget
, which, when called, will open the Bank Link SDK. We also added an event listener to another HTML element with the id open-widget-button
. When the user clicks on this element, the openGrailPayWidget
function will be called, and the widget will be opened allowing the user to link their bank account. The widget will handle all necessary user interactions and authentication.
Both options provide a convenient way for users to link their bank accounts seamlessly, and the Bank Link SDK will handle the rest of the process.
window.grailpay.close()
method, which you can use to programmatically close the active widget.
Here’s how you can utilize the window.grailpay.close()
method:
closeGrailPayWidget
, which, when called, will close the active Bank Link SDK. We also added an event listener to another HTML element with the id close-widget-button
. When the user clicks on this element, the closeGrailPayWidget
function will be called, and the widget will be closed.