Skip to main content

Customizations

The Payen Hosted Payment Components (HPC) toolkit provides several configuration options that allow you to tailor the appearance, accessibility, and behaviour of each embedded field.

All customizations are applied through the configuration object passed to OrchestratorMerchant at initialization time, as shown in the Quick Start.

Configuration Structure

The top-level configuration object accepts three properties:

PropertyTypeRequiredDescription
initializeUrlStringYesThe URL of the HPC initialization endpoint. Provided in your integration credentials.
allowedFieldsObjectYesDeclares which HPC components to instantiate on the page. Only cardNumber, expiryDate, and cvv are supported. At least one field must be configured.
feedbackClassesObjectNoCSS class names applied to container elements for visual feedback. See Feedback Classes below.

Field Configuration

Each field entry within allowedFields accepts the following properties:

PropertyTypeRequiredDescription
idStringYesThe DOM element ID of the container div where the component will be rendered. The element must exist in the page at initialization time.
titleStringNoTitle text for the field (used as a tooltip). Defaults are provided for each field type.
ariaStringNoAccessibility label applied to the embedded input. Defaults are provided for each field type.
placeholderStringNoPlaceholder text displayed in the empty field. Defaults are provided for each field type.
autocompleteStringNoHTML autocomplete attribute value. Defaults are provided for each field type.
minLengthNumberNoMinimum number of characters required. Defaults are provided for each field type.
maxLengthNumberNoMaximum number of characters allowed. Defaults are provided for each field type.
stylesObjectNoCSS properties to apply within the component iframe. See Field Styles below.

Default Field Values

If you omit any of the optional properties, the following defaults are used:

Card Number

Supports card numbers from 13 to 19 digits (e.g., Visa, Mastercard, American Express). The component automatically formats input with spaces and validates using the Luhn algorithm.

PropertyDefault Value
title"The long card number from your card"
aria"Card number"
placeholder"Card number"
autocomplete"cc-number"
minLength11
maxLength19

Expiry Date

PropertyDefault Value
title"The expiry date of your card"
aria"Expiry date"
placeholder"MM/YY"
autocomplete"cc-ext"
minLength5
maxLength5

CVV

PropertyDefault Value
title"The 3 or 4 digit unique security code from your card"
aria"Security code"
placeholder"CVV"
autocomplete"cc-csc"
minLength3
maxLength4

Field Styles

The styles object accepts a subset of CSS properties as key-value pairs. These styles are applied within the component's iframe and control the appearance of text entered by the user.

All style values must be strings with a maximum length of 50 characters.

PropertyDescription
caret-colorColour of the input cursor/caret
colorText colour
font-familyFont family for the field content
font-sizeText size (e.g., "1rem", "16px")
font-styleText style (e.g., "normal", "italic")
font-weightText weight (e.g., "400", "bold")
letter-spacingSpacing between characters
line-heightLine height of the text
text-alignHorizontal text alignment (e.g., "left", "center", "right")
text-transformText transformation (e.g., "none", "uppercase", "lowercase")

Example applying multiple style properties:

"cardNumber": {
"id": "exampleCardNumber",
"styles": {
"font-size": "1rem",
"color": "#333333",
"font-family": "Arial, sans-serif"
}
}
info

Styles are applied within the component iframe. Container-level styling (borders, padding, margins) should be applied to the host div element using standard CSS as shown in the Quick Start.

Feedback Classes

As the user interacts with each HPC field, feedback classes are automatically added or removed from the container element. These allow you to provide visual feedback (e.g., green border for valid input, red for invalid) using your own CSS.

The feedbackClasses object at the top level of your configuration accepts four keys:

KeyApplied WhenDefault Class Name
validThe field content passes validation"is-valid"
invalidThe field content fails validation"is-invalid"
emptyThe field is empty or has not been interacted with"is-empty"
focusThe field currently has keyboard focus"is-focus"

To override the default class names, include a feedbackClasses object in your configuration:

 const config = {
"initializeUrl": "https://prprocessing.trustpayglobal.com/hosted-component/initialize",
"feedbackClasses": {
"valid": "my-valid-class",
"invalid": "my-invalid-class",
"empty": "my-empty-class",
"focus": "my-focus-class"
},
"allowedFields": { ... }
};

You can then target these classes in your own CSS:

.my-valid-class {
border-color: green;
}

.my-invalid-class {
border-color: red;
}

.my-focus-class {
box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}
info

Feedback classes are applied to the container element (the div with the configured id), not to elements inside the iframe. This allows you to style the container using your existing CSS framework. The default class names (is-valid, is-invalid) are compatible with Bootstrap.

To disable a feedback class entirely, set its value to an empty string:

"feedbackClasses": {
"valid": "",
"invalid": "is-invalid",
"empty": "",
"focus": ""
}

Complete Configuration Example

The following shows a fully customized configuration for all three fields:

const config = {
"initializeUrl": "https://prprocessing.trustpayglobal.com/hosted-component/initialize",
"feedbackClasses": {
"valid": "is-valid",
"invalid": "is-invalid",
"empty": "",
"focus": "is-focus"
},
"allowedFields": {
"cardNumber": {
"id": "exampleCardNumber",
"title": "Enter your card number",
"aria": "Card number",
"placeholder": "1234 5678 9012 3456",
"maxLength": 19,
"styles": {
"font-size": "1rem",
"color": "#333333"
}
},
"expiryDate": {
"id": "exampleExpiryDate",
"placeholder": "MM/YY",
"styles": {
"font-size": "1rem"
}
},
"cvv": {
"id": "exampleCVV",
"aria": "Security code (3 or 4 digits)",
"placeholder": "CVV",
"styles": {
"font-size": "1rem"
}
}
}
};

const orchestrator = new OrchestratorMerchant(config);