Customisation
The iFrameConfiguration object is key for customising the look and behaviour of the iFrame.
You can change the appearance, behaviour and language, by passing the JSON configuration object into createCardDetails:
It is optional to provide the iframeConfiguration object in the createCardDetails call. If it is not provided, the customisation properties will be set as their default values.
Configuration to style fields is within the Styles object.
Styles can be applied to all fields by placing the style attribute in the default object inside Styles. You can also apply styles individually to fields, directly to the field name.
The styles object has six properties:
- Default
- Focus
- Error
- Valid
- cv2
- expiryDate
Each of the above properties has two properties:
- Field
- Label
The properties for field and label:
- Mapped to the style objects of the input and label HTML elements.
The properties for focus, error and valid:
- Mapped on state transition allowing the functionality to be consistent with other forms on your site.
Any property defined in default will be applied to all the fields.
Any property defined in a field will take priority over a default property, the fields are expiryDate and cv2.
All valid style properties are supported and take the form of camel cased CSS properties, eg padding-bottom becomes paddingBottom.
Three layout options are provided:
- Vertical
- Compact
- Horizontal
An array of JSON objects each representing a font, are added to the page.
They can be referenced from the Style object. Each object can have the following properties:
Property Name | Values | Example Value |
---|---|---|
family | Specifies the name of the font face value properties. | Roboto |
src | Specifies the resource containing the font data. | "/fonts/OpenSans-Regular-webfont.woff2" |
display | Determines how a font face is displayed. Based on whether and when it is downloaded and ready to use. | auto
|
style | Specifies the font styles. | italic
|
unicodeRange | The range of font Unicode code points to be used. | U+0025-00FF, U+4?? |
weight | Specifies the font weight, or boldness. | 400 |
You can:
- Add any language you need.
- Override some or all of the translations of an existing language. The Web SDK supports: en, de, fr, es, pt.
To add a new language:
- Define a dictionary of the language(s) you wish to add or override. This is an object of languages, along with their translation keys and values. Ensure the keys have no spelling errors, otherwise the translations will not work.
- To define a new language: Supply all translation keys and values
- To override an existing language: Supply only the translation key / pair values to override
For the purpose of this exercise, the following example dictionary object contains:
- Translations for a new language: Italian
- Translations for an existing language: English
It is important the language dictionary follows this structure with inner dictionaries and strings, so the translations can be applied.
Error Message strings:
- The above example dictionary object contains error message strings which contain values {0} and {1}.
- The {0} and {1} values will be will be swapped for strings at runtime, depending on the current state of the iFrame form. For example:
- {0} will change to the card verification code acronym This will be named depending on the card type, for example CVC, or CVV.
- {1} will refer to the detected card type, for example Visa, Mastercard, Diners Club International or Discover.
Ensure you include {1} or {0} in your translation strings (for appropriate keys), to enable this behaviour. For more information on error messages, including these dynamic values, see Payment Form Error Messages.
Set the customLanguages property in your iFrame configuration object to the dictionary object you have defined.
Judopay's Web SDK supports multiple languages.
The default property is English.
Language | Code |
---|---|
English | en |
French | fr |
Spanish | es |
Portuguese | pt |
German | ge |
You can also add other languages or override an existing language, see Adding a New Language.
Below is an example configuration object that customises the payment iFrame.
It is provided as a parameter to the createCardDetails Web SDK call: judo.createCardDetails('payment-iFrame', iFrameConfiguration)