First, load the JavaScript library. This can be done using the following script:
<script type="text/javascript" src="https://securecredentialcapture.visa.com/sdk.js"></script>
SDK will expose VisaSecureCapture Object with multiple methods, which are explained further down this page.
The VisaSecureCapture.configure(ClientModalSettings) function needs to be called before all the other functions. This function tells the SDK where to inject the iFrame. Provide the elementId of the HTML element where the iFrame is to be placed within.
let ClientModalSettings = { type: 'IFRAME', elementId: string };
VisaSecureCapture.configure(ClientModalSettings);
The VisaSecureCapture.init({idToken, entryPoint, preferredLanguage}) function will begin the RDP flow. It requires an idToken to authenticate the client and user.
VisaSecureCapture.init({
apiKey: string // Client's API key
idToken: string,
preferredLanguage: 'en-us', //supported languages (ru-ru, en-us, es-es). Defaults to ru in case no value provided.
entryPoint: 'ADD_CARD' | 'VIEW_CARDS'
})
The VisaSecureCapture.on(eventName, callbackFn(UserAliasInfo)) function allows the client to subscribe to events triggered by user actions within the RDP webpage. For example, the 'UI.ready' event is triggered when the SDK has successfully opened the UI, and the session is beginning.
VisaSecureCapture.on("UI.ready", callbackFn() => {
// perform appropriate action
})
VisaSecureCapture.on("UI.closed", callbackFn() => {
// perform appropriate action
})
VisaSecureCapture.on("UI.Card.added", callbackFn(userAliasInfo) => {
// perform appropriate action
})
VisaSecureCapture.on("UI.Card.removed", callbackFn(userAliasInfo) => {
// perform appropriate action
})
VisaSecureCapture.on("UI.Card.updated", callbackFn(userAliasInfo) => {
// perform appropriate action
})
VisaSecureCapture.on("UI.Card.made-default", callbackFn(userAliasInfo) => {
// perform appropriate action
})
/* When the event occurs, the SDK will call the callbackFn you provide and send the user's UserAliasInfo. You will receive the name ex. (John D) and cardName ex. (Visa ••• 9010). */
/* UserAliasInfo {
name: string,
cardName: string
} */
/* Sample payload sent in postmessage to Client application
UserAliasInfo {
name: Ankur S
cardName: VISA ••• 1091
} */
'UI.ready'
'UI. closed'
User Actions – Events letting the client know about actions made by the user in the window.
'UI.Card.added'
'UI.Card.removed'
'UI.Card.updated'
'UI.Card.made-default'
The VisaSecureCapture.off(eventName) function allows the client to unsubscribe from events.
<!DOCTYPE html>
<html lang="en" style="height: 100%; width: 100%">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>HTML 5 Boilerplate</title>
<style>
#placeiFrameHere {
height: 100%;
width: 100%;
}
</style>
</head>
<script src="https://SecureCredentialCapture.visa.com/sdk.js"></script>
<script>
const VisaSecureCapture = window.VisaSecureCapture;
// Setup iframe
VisaSecureCapture.configure({
type: 'IFRAME',
elementId: 'placeiFrameHere',
});
</script>
<body style="height: 100%; width: 100%; margin: 0">
<div style="display: flex; align-items: center; flex-direction: column" id="pageActions">
<button style="height: 40; width: 160px" onclick='window.openSdk("ADD_CARD")'>
Add Card
</button>
<button style="height: 40px; width: 160px" onclick='window.openSdk("VIEW_CARDS")' id="viewCardsButton">
View Cards
</button>
</div>
</div>
<div id="placeiFrameHere"></div>
<script>
VisaSecureCapture.init({
idToken: _idToken,
entryPoint: entry,
preferredLanguage: document.querySelector('#preferredLanguage').value
});
VisaSecureCapture.on("UI.ready", callbackFn() => {
// perform appropriate action
})
VisaSecureCapture.on("UI.closed", callbackFn() => {
// perform appropriate action
})
VisaSecureCapture.on("UI.Card.added", callbackFn(userAliasInfo) => {
// perform appropriate action
})
VisaSecureCapture.on("UI.Card.removed", callbackFn(userAliasInfo) => {
// perform appropriate action
})
VisaSecureCapture.on("UI.Card.updated", callbackFn(userAliasInfo) => {
// perform appropriate action
})
VisaSecureCapture.on("UI.Card.made-default", callbackFn(userAliasInfo) => {
// perform appropriate action
})
</script>
</body>
</html>