Web SDK v2 v3Improve this page
The Fidel SDKs provide a secure way for you to add card-linking capabilities to your applications. The alternative involves using the Fidel Cards API, but you'll need to be PCI Compliant before you can use it. Using the Fidel SDKs, card details are sent directly to the Fidel API through a secure connection without exposing your servers to sensitive information. They take care of all PCI Compliance requirements, so you don't have to.
The Fidel Web SDK v3 is a JavaScript-based SDK that injects a secure HTML iframe into your web page. Your users will need to have JavaScript enabled in their browsers.
The SDK provides a pre-built UI that allows you to easily collect credit card details, tokenise and link credit/debit cards with rewards services from your website, e-commerce platform or mobile web apps. However, for mobile apps, we recommend using the iOS, Android or React Native SDKs.
You can customize the UI of the SDK to match your use case. All modern desktop and mobile browsers are supported, including Chrome, Firefox, Safari, Microsoft IE11 and Edge.
After successfully tokenising and linking a card on the Visa, Mastercard or American Express networks, the Fidel API returns the created Card object. The Card object has a unique id
that you can use to link each unique card and transaction to your user's account. The id
of each linked card is present on the Transaction object as well, as cardId
. You can create card-linked web and mobile applications with online and offline transaction data visibility in a matter of minutes.
Integrating the Web SDK
Integrating the Fidel Web SDK into your web application starts with loading the JavaScript file we provide, https://resources.fidel.uk/sdk/js/v3/fidel.js
, in a <script>
tag. It registers a global Fidel
variable, and uses an options object to allow you to configure it when calling Fidel.openForm()
.
index.html
123456<script type="text/javascript" src="https://resources.fidel.uk/sdk/js/v3/fidel.js" data-id="fidel-sdk" ></script>
Fidel Web SDK Configuration
You can configure the Fidel Web SDK by defining parameters when calling Fidel.openForm()
. sdkKey
, programId
and companyName
are the required parameters.
Important note: For security reasons, please DO NOT store the SDK Key in your codebase. Follow our SDK security guide for detailed recommendations.
1234567891011121314151617Fidel.openForm({ companyName: "Fidel", sdkKey: yourSdkKey, programId: "bca59bd9-171b-4d1f-92af-4b2b7305268a", onCardEnrolledCallback() { console.log("onCardEnrolledCallback called"); console.log(arguments); }, onCardEnrollFailedCallback() { console.log("onCardEnrollFailedCallback called"); console.log(arguments); }, onUserCancelledCallback() { console.log("onUserCancelledCallback called"); }, });
The Fidel Web SDK can be customized to better fit your website. The functionality is customizable with the language
, schemes
, countries
and closeOnSuccess
parameters. There is also a versatile custom
property, that accepts CSS styles and allows you to greatly customize the UI of the SDK.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768Fidel.openForm({ companyName: "Fidel", sdkKey: yourSdkKey, // make sure to store it in a secure place programId: "bca59bd9-171b-4d1f-92af-4b2b7305268a", custom: { close: { location: "form", }, overlay: { style: { background: "#111111", }, }, form: { style: { background: "#1C1C1C", border: "none", }, }, title: { style: { textAlign: "center", color: "white", }, }, cardNumber: { label, input, }, expiryDate: { label, input, }, country: { label, input, }, submit: { style: { background: "#44EDB0", color: "#111111", borderRadius: "4px", }, }, }, }); const input = { style: { color: "#737373", border: "none", background: "#282828", }, focusStyle: { background: "#303030", borderWidth: "2px", borderColor: "black", }, errorStyle: { borderWidth: "2px", borderColor: "red", }, }; const label = { hide: true, };
Fidel Web SDK Parameters
Parameter | Value | Description |
---|---|---|
companyName required | string | The name of the company using card linking. |
sdkKey required | string | A valid SDK Key. You can find yours on the Dashboard. It starts with "pk_". For security reasons, please do not store the SDK Key in your codebase. Follow our SDK security guide for detailed recommendations. |
programId required | string | The id of the Fidel API Program to link the card to. |
programName | string | The name of the Fidel API Program to link the card to. |
callback | function | Deprecated Function to be called when the card enroll succeeds or fails. |
onCardEnrolledCallback | function | Function to be called when a Card is enrolled successfuly. Receives the Card entity as argument. |
onCardEnrollFailedCallback | function | Function to be called when a Card enrollment fails. Receives an error object as argument. |
onUserCancelledCallback | function | Function to be called when the user cancels the card enrollment with one of the following actions: - Closing the window with the "x" in the top right corner - Clicking/tapping outside the SDK's frame - Pressing the ESC key on the keyboard No arguments are provided. |
container | HTML element | A wrapper element that you can wrap around the iframe. |
countries | array of strings Possible values: 'GBR', 'IRL', 'USA', 'SWE' | If the array has only one value, that will be set as the country of issue for all collected cards and the country select box is removed from the UI. If the array has multiple values, those will be the available options in the country select box. |
language | string Possible values: 'EN', 'EN-BG', 'FR', 'JA', 'SV' Default value: 'EN' | The language to be displayed. It follows `window.navigator.language` language codes. |
metadata | Record<string, any> | The global metadata object. See more details in the next sections. |
closeOnSuccess | boolean Default value: true | Toggles the form's auto-close behavior on successful card linking. |
schemes.mastercard schemes.visa schemes.amex | boolean By default, all three are true. | Properties that toggle the availability of the Mastercard, Visa and Amex card schemes in the form. |
custom | object | Object that allows you to customize the UI for the Web SDK. You can find the structure for it in the customization section below. |
Fidel Web SDK Global Object
After adding the Web SDK script on your website, a global variable Fidel
is created with two methods that you can use to open and close the web form manually, Fidel.openForm()
and Fidel.closeForm()
.
To open the iframe overlay form with a button, you could use this example:
1234567891011121314151617181920212223242526272829<button id="open-form" type="submit">Link Card</button> <script type="text/javascript" data-id="fidel-sdk" src="https://resources.fidel.uk/sdk/js/v3/fidel.js" ></script> <script type="text/javascript"> document.getElementById("open-form").addEventListener("click", function () { Fidel.openForm({ companyName: "Fidel", sdkKey: yourSdkKey, // make sure to store it in a secure place programId: "bca59bd9-171b-4d1f-92af-4b2b7305268a", onCardEnrolledCallback() { console.log("onCardEnrolledCallback called"); console.log(arguments); }, onCardEnrollFailedCallback() { console.log("onCardEnrollFailedCallback called"); console.log(arguments); }, onUserCancelledCallback() { console.log("onUserCancelledCallback called"); }, }); }); </script>
Web SDK metadata
The metadata id
property is a non-unique index, so you can set it to a custom UID (unique identifier). Later you can query the cards using the same metadata.id
. You can use our "List Cards from Metadata ID" API Endpoint.
Hint: Adding user data in the metadata as key: value pairs can simplify reconciliation with your system. For example, adding
'myUserId':'123'
will help you match the added card to your user with id 123.
index.html
12345678910111213141516171819202122232425262728293031323334<button id="open-form" type="submit">Link Card</button> <script type="text/javascript" data-id="fidel-sdk" src="https://resources.fidel.uk/sdk/js/v3/fidel.js" ></script> <script type="text/javascript"> document.getElementById("open-form").addEventListener("click", function () { Fidel.openForm({ companyName: "Fidel", sdkKey: yourSdkKey, // make sure to store it in a secure place programId: "bca59bd9-171b-4d1f-92af-4b2b7305268a", onCardEnrolledCallback() { console.log("onCardEnrolledCallback called"); console.log(arguments); }, onCardEnrollFailedCallback() { console.log("onCardEnrollFailedCallback called"); console.log(arguments); }, onUserCancelledCallback() { console.log("onUserCancelledCallback called"); }, metadata: { id: "this-is-the-metadata-id", myUserId: "123", customKey: "customValue", }, }); }); </script>
Customizing the Web SDK
The custom
property allows for customizing most of the Fidel Web SDK UI. It supports the same CSS properties as the HTML DOM Style Object. Here is a complete list of parameters, all of which are optional.
Parameter | Value | Description |
---|---|---|
logo.url | string | The URL of the logo on the iframe. |
logo.style | CSS properties | The style of the logo on the iframe. |
form.style | CSS properties | The style of the form element of the iframe. |
overlay.style | CSS properties | The style of the overlay element of the iframe. |
close.location | string Possible values: form | overlay | none Default value: overlay | The location of the close icon. |
close.color | string | The color of the close icon. |
title.text | string Default value: "Connect your card" | The text of the title at the top of the page. |
title.style | CSS properties | The style of the title at the top of the page. |
cardNumber.label | LabelStyles (see definition below) | The style of the Card Number label. |
cardNumber.input | InputStyle (see definition below) | The style of the Card Number input field. |
expiryDate.label | LabelStyles (see definition below) | The style of the Expiry Date label. |
expiryDate.input | InputStyle (see definition below) | The style of the Expiry Date input field. |
country.label | LabelStyles (see definition below) | The style of the Country field label. |
country.input | InputStyle (see definition below) | The style of the Country input field. |
terms.text | string Default value: "I authorize {{scheme}} to monitor my payment card to identify transactions that qualify for a reward and for {{scheme}} to share such information with {{companyName}}, to enable my card linked offers and target offers that may be of interest to me." | The Terms of Use text. |
terms.privacyUrl | string | The Privacy Policy URL. |
terms.termsUrl | string | The Terms and Conditions URL. |
terms.deleteInstructions | string Default value: "going to your account settings" | Text to inform the user about how to opt out from the transaction monitoring. It is appended to the text "You may opt out of transaction monitoring on the payment card you entered at any time by". |
terms.checkbox | style : CSS propertiescheckedStyle : CSS properties | The styles of the terms checkbox. |
terms.checkbox.checkColor | string | The border color of the terms checkbox. |
submit | style : CSS propertieshoverStyle : CSS propertiesloadingStyle : CSS propertiessuccessStyle : CSS propertiesdefaultText : stringDefault value: "Continue" | "Verify", depending on the step loadingText : stringsuccessText : string | Parameters to customize the CTA button on the screens of the card verification. |
The LabelStyles type includes the following parameters:
Parameter | Type | Description |
---|---|---|
label.hide | CSS properties | The default style of the input |
label.style | CSS properties | The style of the input |
label.errorStyle | CSS properties | The error style of the input |
label.focusStyle | CSS properties | The focus style of the input |
label.placeholderColor | string | The color of the input's placeholder |
The InputStyles type includes the following parameters:
Parameter | Type | Description |
---|---|---|
input.style | CSS properties | The default style of the input |
input.errorStyle | CSS properties | The error style of the input |
input.focusStyle | CSS properties | The focus style of the input |
input.placeholderColor | string | The color of the input's placeholder |
The definition of the custom
parameter:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889Fidel.openForm({ ... custom: { logo: { url: string, style: CSSPropertiesObject, }, form: { style: CSSPropertiesObject, }, overlay: { style: CSSPropertiesObject, }, close: { location: 'form' | 'overlay' | 'none', color: string | { form: string, overlay: string }, }, title: { text: string, style: CSSPropertiesObject, }, cardNumber: { label: { style: CSSPropertiesObject, errorStyle: CSSPropertiesObject, focusStyle: CSSPropertiesObject, placeholderColor: string, hide: boolean }, input: { style: CSSPropertiesObject, errorStyle: CSSPropertiesObject, focusStyle: CSSPropertiesObject, placeholderColor: string }, }, expiryDate: { label: { style: CSSPropertiesObject, errorStyle: CSSPropertiesObject, focusStyle: CSSPropertiesObject, placeholderColor: string, hide: boolean }, input: { style: CSSPropertiesObject, errorStyle: CSSPropertiesObject, focusStyle: CSSPropertiesObject, placeholderColor: string }, }, country: { label: { style: CSSPropertiesObject, errorStyle: CSSPropertiesObject, focusStyle: CSSPropertiesObject, placeholderColor: string, hide: boolean }, input: { style: CSSPropertiesObject, errorStyle: CSSPropertiesObject, focusStyle: CSSPropertiesObject, placeholderColor: string }, }, terms: { text: string, privacyUrl: string, termsUrl: string, deleteInstructions: string, checkbox: { style: CSSPropertiesObject, checkedStyle: CSSPropertiesObject, checkColor: string, }, }, submit: { style: CSSPropertiesObject, hoverStyle: CSSPropertiesObject, loadingStyle: CSSPropertiesObject, successStyle: CSSPropertiesObject, defaultText: string, loadingText: string, successText: string, }, } })
Here are some examples of what is achievable using the customization:
Card entity
This object is returned through the onCardEnrolledCallback
when a card is successfully enrolled.
Parameter | Value | Description |
---|---|---|
id | string | The ID of the enrolled card |
accountId | string | The account ID of the program where the card was enrolled |
programId | string | The ID of the program where the card was enrolled |
scheme | string Possible values: 'mastercard', 'visa', 'amex' | Card scheme |
lastNumbers | string | If made available, this property will be populated with the last 4 numbers of the enrolled card. If they're not available, you'll receive "****" (4 stars, an obfuscated string value). To turn on or off receiving these numbers, please check your Fidel API Dashboard account's Security settings. |
firstNumbers | string | If made available, this property will be populated with the first 6 numbers of the enrolled card. If they're not available, you'll receive "******" (6 stars, an obfuscated string value). To turn on or off receiving these numbers, please check your Fidel API Dashboard account's Security settings. |
expYear | number | Expiration year of the card. The values are full year values (2023), not shortened year values (23) |
expMonth | number | Expiration month of the card |
expDate | string Format: MM/YY | Expiration date |
created | string Format: YYYY-MM-DDTHH:mm:ss.SSSZ | Card enrollment date |
countryCode | string | This field will have the code of the card issuing country, as selected by the cardholder in the card enrollment step. |
termsOfUse | boolean | Accepted or declined terms of use |
live | boolean | Flag that checks if the card is from a live or a test environment |
metadata | object | This will contain the exact JS object that might have been set using the metadata parameter. |
Error object
This object is returned whenever you receive an error callback.
Parameter | Value | Description |
---|---|---|
cardId | string (optional) | The ID of the enrolled card. This field will only be present if the card is already enrolled. For example, if the error is thrown in the card enrollment phase, it will not have a cardId since the card is not enrolled yet. |
date | string Format: YYYY-MM-DDTHH:mm:ss.SSSZ | The date when the error happened |
type | string | Returns the error code |
message | string | Returns the error message |
Error codes
Value | Description |
---|---|
service-unavailable | Service unavailable at the moment |
item-exists | Card already exists |
uuid | Invalid program ID |
credential | Invalid SDK key |
unauthorized | Unauthorized request |
verification-incorrect-amount | Incorrect amount for microcharge verification |
verification-max-attempts-reached | Max failed attempts reached on card verification |
verification-not-found | Verification not found for the current linking card |
card-already-verified | Verification already done for the current linking card |
card-not-found | Card not found when creating a new card verification |
verification-error-generic | Unable to verify due to unknown reason |