API V4 docs / Secure Fields Form
The class for instantiating the secure fields and tokenizing the card details.
Creates an instance of the secure fields.
Parameters:
Name Name | Type | Description |
---|---|---|
auth | AuthenticationData object | (mandatory) Object used for authenticating the merchant with PayU. See Secure Field AuthenticationData below. |
options | PosFieldsOptions object | (optional) Options to pass when instantiating the secure fields. See Secure Field PosFieldsOptions below. |
Name Name | Type | Description | Example |
---|---|---|---|
merchantCode | string | (mandatory) The code assigned by PayU to the merchant | MERC_1 |
sessionId | string | (mandatory) Session ID generated by using the session API | S79fac7b6-4f87-4a17-92b4-bffe16f68f1e |
Name Name | Type | Description | Example |
---|---|---|---|
directionLtr | boolean | (optional) Whether to display the fields from left to right or right to left. Default is true (left to right). |
true |
fonts | array | (optional) A list of custom fonts to be applied to the fields. The fonts must be stored in an array of objects, with each
object having an src key and a value (string ) referencing the font location.
For an example, see Embedding the Secure Fields Form in a Checkout Page.
|
[ { src: 'https://fonts.googleapis.com/css?family=Source+Code+Pro' } ] |
luhnValidation | boolean | (optional) Whether to check if the card number passed luhn validation. Default is true . |
true |
Returns a token representation of the card data submitted through the secure fields form.
Parameters:
Name Name | Type | Description |
---|---|---|
elementType | string | The type of field for which the token will be created. Can be one of the following: fullCreditCard ,
creditCard , cardNumber . For an explanation of each field type, see Form Elements
Types below.
|
additionalData | object | A JSON object containing key - value pairs of additional data. You can use this data to complement the card data provided by the customer. This is parameter is required, as you must pass at least the card holder name. |
Form elements are fields that you can show in your checkout page.
Instantiates a specific form element (field) to show in your checkout page. formElements
is an instance returned by PayUSecureFields.Init(options?)
.
Parameters:
Name Name | Type | Description |
---|---|---|
elementType | string | The type of field to instantiate. See Form Elements Types below. |
options | object | (optional) Additional options to pass when instantiating a field. Form Elements Options below. |
Field Type Name | Description |
---|---|
fullCreditCard | Shows input fields for the card number, card expiration date and CVV code |
creditCard | Shows input fields for the card number and the card expiration date |
cardNumber | Shows an input field for the card number |
creditCardExpiry | Shows an input field for the card expiration date |
cvv | Shows an input field for the CVV code |
Option | Type | Description |
---|---|---|
cardFormat | boolean | Whether to format the card number on input. Only applicable to card-type input fields. Default is true
|
maxCardPanLength | number | The max length of the card number on input. Only applicable to card-type input fields. If the cardFormat option is true , we will add 3 more characters for the spaces used in the format. Default is 22 characters with cardFormat set on true.
|
classes | object | Applies the specified class names to the div wrapping the input field. For more information, see Styling
the Secure Fields Form.
|
disabled | boolean | Disables the input field |
includeCardImage | boolean | Whether to show the card image on input. Only applicable to card-type input fields. Default is true
|
placeholders | object | Placeholders for default text to show in an input field. Can be any of the following: cardNumber ,
cvv , expDate |
style | object | CSS styles for styling the input fields. For more information, see Styling the Secure Fields Form. |
Clears the input field. formElement
is an instance returned by formElements.create(elementType,options?)
.
Unmounts the input field from the DOM. You can only call this once.
formElement
is an instance returned by formElements.create(elementType,options?)
.
Mounts a field to the DOM. formElement
is an instance returned by formElements.create(elementType,options?)
.
Parameters:
Name | Type | Description |
---|---|---|
containerSelector | string | The ID of the form ’s input element to which to mount the field. |
Binds an event listener to the input field, for events that are triggered when the value of an input field has been changed. formElement
is an instance returned by formElements.create(elementType,options?)
.
Parameters:
Name | Type | Description |
---|---|---|
eventType | string | The type of event that is listened to. Can be one of the following: change , focus , blur .
|
callBack | function | A callback function. The function must take a single parameter through which a result object is returned. |
The parameter of the callback function will return an object with the following properties:
Name | Value Type | Description |
---|---|---|
bin | string | The first 6 digits of the card identifying the financial institution that issued the card. |
complete | boolean | Wether the card data is inserted and valid. Note: For card fields, this will be true
if you disabled the luhn check when instantiating the secure fields.
|
brand | string | The card brand. Only returned for card numbers. |
empty | boolean | Whether the input field is empty. |
error | object | An error object if an error occurred on input. |
If an error
object is returned, its object will have the following properties:
Name | Value Type | Description |
---|---|---|
cvv | string | The result of checking the cvv code on input. Example value: wrong length |
pan | string | The result of checking the account number on input. Example value: not luhn |
expiry | string | The result of checking the card expiration date on input. Example value: passed |
Updates the input field with the specified options.
formElement
is an instance returned by formElements.create(elementType,options?)
.
Parameters:
Name Name | Type | Description |
---|---|---|
options | object | (optional) Additional options to pass when instantiating a field. Form Elements Options below. |
You can style the secure fields by passing style
or classes
objects to the
formElements.create(elementType,options?)
call. For more information, see
Styling the Secure Fields Form.
The following is a list of object key names, representing the field input status to which you can apply styles. Note that the objects must be nested
with the style
object.
Key Name | Description |
---|---|
base | Styles that are inherited by the other objects |
complete | Applied when the field’s input is valid |
empty | Applied when the field has no input |
invalid | Applied when the field’s input is invalid |
The following is a list of style properties that you can apply to each object nested within the style
object (see Style Objects for a list of objects that can be nested).
Style | Type |
---|---|
backgroundColor | string |
color | string |
fontFamily | string |
fontSize | string |
fontSmoothing | string |
fontStyle | string |
fontVariant | string |
fontWeight | string |
letterSpacing | string |
padding | string |
textAlign | string |
textDecoration | string |
textShadow | string |
textTransform | string |
The following is a list of pseudo classes and pseudo elements that you can apply to each object nested within the style
object (see Style Objects for a list of objects that you can be nested).
The following is the list of object key names, representing the field input status for which you can apply custom class names. The default class names are listed as well.
Key Name | Description | Default class name if not supplied |
---|---|---|
base | The base class applied to the div elements wrapping each input field |
POSElement |
complete | The class name to apply to the field’s div element when the field’s input is valid.
Note: For card fields, this class will also be applied for invalid input if you disabled the luhn check when instantiating
the secure fields.
|
POSElement–complete |
empty | The class name to apply to the field’s div element when the field has no input |
POSElement–empty |
focus | The class name to apply to the field’s div element when the field gets focus |
POSElement–focus |
invalid | The class name to apply to the field’s div element when the field’s input is invalid |
POSElement–invalid |