Learn about customisation options for th the card-on-file component.
const cardOnFileConfig: CardOnFileComponentConfig = {
limitTokens: number,
filterBy: {
excludeExpiredTokens: boolean,
schemes: string[],
fundingSource: string,
issuerCountryCode: string,
ownerType: string
},
orderBy: {
expiryDate: string,
scheme: string,
fundingSource: string,
ownerType: string,
issuerCountryCode: string,
lastUsageDate: {
orderByField: string
}
},
cardBrandImages: {
visaSrc: string,
mastercardSrc: string,
amexSrc: string,
cupSrc: string,
dinersSrc: string,
discoverSrc: string,
jcbSrc: string
},
expiredText: string,
validThruText: string,
deleteModal: {
dialogAriaLabel: string,
bodyText: string,
cancelButtonText: string,
deleteButtonText: string,
class: string
},
deleteErrorMessage: string,
deleteSuccessMessage: string,
updateErrorMessage: string,
updateSuccessMessage: string,
successMessageClass: string,
errorMessageClass: string,
isExpiryDateEditable: boolean,
isCvcRequired: boolean,
allowDeleteToken: boolean,
cvcComponentConfig: CardCvcComponentConfig,
expiryDateComponentConfig: CardExpiryDateComponentConfig,
styles: CSSProperties,
iconDeleteSrc: string,
iconSaveSrc: string,
iconCancelSrc: string,
iconEditSrc: string,
inputStyles: CSSProperties,
tokenItemClass: string,
useTransparentCardBrandImage: boolean,
editCardInformationAriaLabel: string,
saveCardInformationAriaLabel: string,
cancelEditCardInformationAriaLabel: string,
deleteCardButtonAriaLabel: string,
cardNumberAriaLabel: string,
cardExpiryDateAriaLabel: string,
};| Parameter | Description |
|---|---|
limitTokensnumber | The maximum number of tokens to display in the component. For example, if set to 5 then only the first five card tokens are displayed. |
filterByobject | Details about the filtering options. |
filterBy.excludeExpiredTokensboolean | Whether to exclude tokens associated with expired cards. |
filterBy.schemesstring [] | The list of card schemes to include. For example, [Visa, Mastercard]. |
filterBy.fundingSourcestring | The funding source type to include. For example Credit or Debit. |
filterBy.issuerCountryCodestring | The issuer country code to include. |
filterBy.ownerTypestring | The owner type to include. |
orderByobject | Details about the ordering options. |
orderBy.expiryDateobject | Details for ordering by expiry date. |
orderBy.expiryDate.directionstring | The direction to order by. Possible values:
|
orderBy.expiryDate.prioritynumber | The priority of the ordering option. |
orderBy.schemeobject | Details for ordering by card scheme. |
orderBy.scheme.valuesOrderstring | The card scheme. |
orderBy.scheme.prioritynumber | The priority of the ordering option. |
orderBy.fundingSourceobject | Details for ordering by funding source. |
orderBy.fundingSource.valuesOrderstring | The funding source. Possible values:
|
orderBy.fundingSource.prioritynumber | The priority of the ordering option. |
orderBy.ownerTypeobject | Details for ordering by owner type. |
orderBy.ownerType.valuesOrderstring | The owner type. Possible values:
|
orderBy.ownerType.prioritynumber | The priority of the ordering option. |
orderBy.issuerCountryCodeobject | Details for ordering by issuer country code. |
orderBy.issuerCountryCode.directionstring | The direction to order by. Possible values:
|
orderBy.issuerCountryCode.prioritynumber | The priority of the ordering option. |
orderBy.lastUsageDateobject | Details for ordering by last usage date. |
orderBy.lastUsageDate.directionstring | The direction to order by. Possible values:
|
orderBy.lastUsageDate.orderByFieldstring | The field to order by. Possible values:
|
orderBy.lastUsageDate.prioritynumber | The priority of the ordering option. |
cardBrandImagesobject | Details about the card brand images. |
cardBrandImages.visaSrcstring | The URL for the Visa card brand image. |
cardBrandImages.mastercardSrcstring | The URL for the Mastercard card brand image. |
cardBrandImages.amexSrcstring | The URL for the Amex card brand image. |
cardBrandImages.cupSrcstring | The URL for the CUP card brand image. |
cardBrandImages.dinersSrcstring | The URL for the Diners card brand image. |
cardBrandImages.discoverSrcstring | The URL for the Discover card brand image. |
cardBrandImages.jcbSrcstring | The URL for the JCB card brand image. |
expiredTextstring | The text to display for expired cards. |
validThruTextstring | The text to display for the "valid thru" label. |
deleteModalobject | Configuration for the deletion modal. |
deleteModal.dialogAriaLabelstring | The aria label for the deletion modal. |
deleteModal.bodyTextstring | The body text for the deletion modal. |
deleteModal.cancelButtonTextstring | The cancel button text for the deletion modal. |
deleteModal.deleteButtonTextstring | The delete button text for the deletion modal. |
deleteModal.classstring | The name of the class associated with the deletion modal. |
deleteErrorMessagestring | The error message to display when a card deletion fails. |
deleteSuccessMessagestring | The success message to display when a card deletion is successful. |
updateErrorMessagestring | The error message to display when a card update fails. |
updateSuccessMessagestring | The success message to display when a card update is successful. |
successMessageClassstring | The name of the CSS class to apply to success messages. |
errorMessageClassstring | The name of the CSS class to apply to error messages. |
isExpiryDateEditableboolean | Whether the expiry date field can be edited by the cardholder. |
isCvcRequiredboolean | Whether CVC is required when selecting a token. This applies to all tokens. |
allowDeleteTokenboolean | Whether to allow cardholders to delete a token (previously saved card). |
cvcComponentConfigCardCvcComponentConfig | Configuration for the standalone card CVC component. See Card CVC. |
expiryDateComponentConfigCardExpiryDateComponentConfig | Configuration for the standalone card expiry date component. See Card expiry date. |
stylesCSSProperties | Custom styling. |
iconDeleteSrcstring | The URL for your custom delete icon. |
iconSaveSrcstring | The URL for your custom save icon. |
iconCancelSrcstring | The URL for your custom cancel icon. |
iconEditSrcstring | The URL for your custom edit icon. |
inputStylesCSSProperties | Custom input styles. |
tokenItemClassstring | Custom class for the token item. |
useTransparentCardBrandImageboolean | Whether to use transparent card brand images. Defaults to true. |
editCardInformationAriaLabelstring | The aria label for the edit card information button. |
saveCardInformationAriaLabelstring | The aria label for the save card information button. |
cancelEditCardInformationAriaLabelstring | The aria label for the cancel edit information button. |
deleteCardButtonAriaLabelstring | The aria label for the delete card button. |
cardNumberAriaLabelstring | The aria label for the card number. |
cardExpiryDateAriaLabelstring | The aria label for the card expiry date. |
const cardOnFileConfig: CardOnFileComponentConfig = {
onPreRenderTokens: (data: RetrieveCardTokensReponseSuccess) => CardTokenMapping[],
onRetrieveTokensFailed: (data: RetrieveCardTokensReponseFailed) => void,
onPreDeleteToken: (token: BaseCardToken) => Promise<boolean>,
onDeleteTokenSuccess: (data: DeleteCardTokenResponseSuccess) => void,
onDeleteTokenFailed: (data: DeleteCardTokenResponseFailed) => void,
onUpdateTokenSuccess: (data: UpdateCardTokenResponseSuccess) => void,
onUpdateTokenFailed: (data: UpdateCardTokenResponseFailed) => void,
tokenItemBuilder: (elementIds: TokenBuilderElementIds) => string,
IDs.tokenLabelBuilder: (token: BaseCardToken) => string
}| Callback | Description |
|---|---|
onPreRenderTokens: (data: RetrieveCardTokensReponseSuccess) => CardTokenMapping[] | Event handler for pre-processing tokens before rendering. Allows custom filtering and mapping of token data. |
onRetrieveTokensFailed: (data: RetrieveCardTokensReponseFailed) => void | Event handler for when token retrieval from the API fails. |
onPreDeleteToken: (token: BaseCardToken) => Promise<boolean> | Event handler for before token deletion. Return true to proceed, false to cancel. |
onDeleteTokenSuccess: (data: DeleteCardTokenResponseSuccess) => void | Event handler for after a token is successfully deleted. |
onDeleteTokenFailed: (data: DeleteCardTokenResponseFailed) => void | Event handler for when token deletion fails. |
onUpdateTokenSuccess: (data: UpdateCardTokenResponseSuccess) => void | Event handler for after a token is successfully updated. |
onUpdateTokenFailed: (data: UpdateCardTokenResponseFailed) => void | Event handler for when a token update fails. |
tokenItemBuilder: (elementIds: TokenBuilderElementIds) => string | Custom HTML builder for token item layout. Returns an HTML string with a specific element. |
IDs.tokenLabelBuilder: (token: BaseCardToken) => string | Custom label builder for token display text. |
For more information about callbacks, see Events.
const cardOnFileConfig: CardOnFileComponentConfig = {
limitTokens: 5,
filterBy: {
excludeExpiredTokens: true,
schemes: ["Visa", "Mastercard"],
fundingSource: "Credit",
issuerCountryCode: "USA",
ownerType: "Consumer"
},
orderBy: {
expiryDate: {
direction: "asc",
priority: 1
},
scheme: {
valuesOrder: ["Visa", "Mastercard", "Amex"],
priority: 2
},
fundingSource: {
valuesOrder: ["Credit", "Debit"],
priority: 3
},
ownerType: {
valuesOrder: ["Consumer", "Commercial"],
priority: 4
},
issuerCountryCode: {
direction: "desc",
priority: 5
},
lastUsageDate: {
direction: "desc",
orderByField: "lastSuccessfulPurchaseDate",
priority: 6
}
},
cardBrandImages: {
visaSrc: "https://example.com/visa-logo.png",
mastercardSrc: "https://example.com/mastercard-logo.png",
amexSrc: "https://example.com/amex-logo.png"
},
expiredText: "Card expired",
validThruText: "Valid until",
deleteModal: {
dialogAriaLabel: "Delete card dialog",
bodyText: "Are you sure you want to delete this payment method?",
cancelButtonText: "No, keep it",
deleteButtonText: 'Yes, delete it',
class: "custom-modal-class"
},
deleteErrorMessage: "Unable to delete card. Please try again.",
deleteSuccessMessage: "Card has been removed successfully.",
updateErrorMessage: "Unable to update card information. Please try again.",
updateSuccessMessage: "Card information updated successfully.",
successMessageClass: "alert alert-success",
errorMessageClass: "alert alert-danger",
isExpiryDateEditable: true,
isCvcRequired: true,
allowDeleteToken: true,
cvcComponentConfig: {
required: true,
label: "Security code",
applyMask: true,
showMaskToggle: true,
labelPosition: "left",
errorMessage: "Please enter a valid security code",
inputStyles: {
base: {
color: "#333",
fontSize: "16px"
}
}
},
expiryDateComponentConfig: {
label: "Expiry date",
labelPosition: "left",
formatOptions: "MM/YY",
inputStyles: {
base: {
color: "#333",
fontSize: "16px"
}
}
},
styles: {
backgroundColor: "#f8f9fa",
border: "1px solid #dee2e6",
borderRadius: "8px",
padding: "20px"
},
iconDeleteSrc: "http://example.com/delete.jpg",
iconSaveSrc: "http://example.com/save.jpg",
iconCancelSrc: "http://example.com/cancel.jpg",
iconEditSrc: "http://example.com/edit.jpg",
inputStyles: {
borderRadius: "5px",
backgroundColor: "grey"
},
tokenItemClass: "custom-token-item-class",
useTransparentCardBrandImage: true,
editCardInformationAriaLabel: "Edit card information button",
saveCardInformationAriaLabel: "Save card information button",
cancelEditCardInformationAriaLabel: "Cancel edit card information button",
deleteCardButtonAriaLabel: "Delete card button",
cardNumberAriaLabel: "Card number",
cardExpiryDateAriaLabel: "Card expiry date",
onPreRenderTokens: (data: RetrieveCardTokensReponseSuccess) => {
return data.gatewayTokens
.filter(token => token.issuerCountryCode === 'USA')
.map(token => ({
id: token.gatewayTokenId,
isCvcRequired: true
}));
},
onRetrieveTokensFailed: (data: RetrieveCardTokensReponseFailed) => {
console.error('Failed to retrieve tokens:', data.errorMessage);
showErrorMessage('Unable to load saved cards');
},
onPreDeleteToken: (token: BaseCardToken) => {
return new Promise((resolve) => {
const confirmed = confirm(`Are you sure you want to delete card ending in ${token.maskedPrimaryAccountNumber.slice(-4)}?`);
resolve(confirmed);
});
},
onDeleteTokenSuccess: (data: DeleteCardTokenResponseSuccess) => {
console.log('Token deleted successfully:', data);
showSuccessMessage('Card removed successfully');
refreshTokenList();
},
onDeleteTokenFailed: (data: DeleteCardTokenResponseFailed) => {
console.error('Delete failed:', data);
showErrorMessage('Failed to delete card. Please try again.');
},
onUpdateTokenSuccess: (data: UpdateCardTokenResponseSuccess) => {
console.log('Token updated successfully:', data);
showSuccessMessage('Card information updated');
},
onUpdateTokenFailed: (data: UpdateCardTokenResponseFailed) => {
console.error('Update failed:', data);
showErrorMessage('Failed to update card information');
}
};