Method reference
Methods for initializing and using PaymentJs.
Methods
init
Initializes the PaymentJs object for PAN and CVV entry. Pass null for cvvDivId to collect only the card number (PAN-only mode, no CVV field).
Parameters
publicIntegrationKey— the connector’s public integration key (provided to you with your credentials).numberDivId— theidof the<div>which will contain the primary account number (PAN).cvvDivId— theidof the<div>which will contain the CVV code, ornullfor PAN-only mode.completeCallback(PaymentJs)— a callback function that will receive the initializedPaymentJsas first argument.
initCvvRefresh
Initializes the PaymentJs object for CVV refreshing.
Parameters
publicIntegrationKey(string): the connector’s public integration key (provided to you with your credentials).
The selected connector, identified by the publicIntegrationKey,
- must use the same customer profile container as the used
paymentToken, or - must belong to the same merchant as the connector identified by the
referenceTransactionId.
- Reference to a register or debit with register transaction for which the CVV will be refreshed:
referenceTransactionId(string): the referenced transaction ID. -paymentToken(string): the customer profile payment token.
cvvDivId(string): theidof the<div>which will contain the CVV code.completeCallback(function:(PaymentJs) => void): a callback function that will receive the initializedPaymentJsas first argument.
tokenize
Submit the sensitive card information to the vaulting server for tokenization.
Parameters
additionalData(object): an object, may contain the following keys:first_name,last_name,month,year,email,phone_number,company,address1,zip,city,state,country.successCallback(function:(token, cardData) => void): will be called upon completion, receiving thetoken(as string) as first argument, and additionalcardDataas second argument , for example:
Possible cardType values are: amex, dinacard, diners, discover, elo, jcb, mada, maestro, mastercard, meeza, uatp, unionpay, visa_electron, and visa.
Please note that the enumerated list provided above is subject to change or expansion over time. As such, be ready to accommodate and appropriately handle unfamiliar card brands.
errorCallback(function:(errors) => void): called if an error occurs, containing error information. For more details see Error codes.
refreshCvv
Submit the CVC/CVV code to the vaulting server.
Parameters
successCallback(function:() => void): will be called upon successful completion.errorCallback(function:(errors) => void): called if an error occurs, containing error information. For more details see Error codes.
initRiskScript
Initialize Risk Scripts. Required for certain types of risk checks, see External risk checks for more details.
Parameters
options(object): An object including the type, e.g.{ type: 'forter' }.typecan beforterorriskified.completeCallback(function(...) => void): will be called upon successful completion, parameters depend ontypefromoptions.
setNumberStyle
Sets the style of the number field.
Parameters
styleObject(object): an object with CSS properties, for example:
Additionally, it is possible to style the placeholder of the number field by providing a nested object with CSS properties in the field ::placeholder, e.g.
In order to comply with Payment Card Industry (PCI) security standards, we are unable to permit the loading of external resources such as typefaces or background images.
setCvvStyle
Sets the style of the CVV field.
Parameters
styleObject(object): an object with CSS properties, for example:
Additionally, it is possible to style the placeholder of the CVV field by providing a nested object with CSS properties in the field ::placeholder, e.g.
In order to comply with Payment Card Industry (PCI) security standards, we are unable to permit the loading of external resources such as typefaces or background images.
setNumberPlaceholder
Sets the placeholder text for the number input field.
Parameters
placeholderText(string): text for the placeholder of the number input field.
setCvvPlaceholder
Sets the placeholder text for the CVV input field.
Parameters
placeholderText(string): text for the placeholder of the CVV input field.
setNumberInputType
Sets the type attribute on the number input field.
Parameters
inputType(string): type value (i.e. ‘text’, ‘password’).
setCvvInputType
Sets the type attribute on the CVV input field.
Parameters
inputType(string): type value (i.e. ‘text’, ‘password’).
setNumberAttribute
Sets an attribute on the number input field.
Parameters
attribute(string): attribute to set (allowed: ‘aria-describedby’, ‘aria-description’, ‘aria-disabled’, ‘aria-errormessage’, ‘aria-invalid’, ‘aria-label’, ‘aria-labelledby’, ‘aria-placeholder’, ‘aria-required’).value(string): value of the attribute.
setCvvAttribute
Sets an attribute on the CVV input field.
Parameters
attribute(string): attribute to set (allowed: ‘aria-describedby’, ‘aria-description’, ‘aria-disabled’, ‘aria-errormessage’, ‘aria-invalid’, ‘aria-label’, ‘aria-labelledby’, ‘aria-placeholder’, ‘aria-required’).value(string): value of the attribute.
numberOn
Attach an event listener for the number input field.
For more details see Event listening.
If getBinData is set to true, the result will be asynchronous (adding a backend call) and the BIN data will be attached as the binData key to the response data.
cardBrand is the brand as reported by the BIN data source. normalizedCardBrand is the same brand normalized to the card type identifiers also used by cardType (see the list below), or null if the brand cannot be resolved to one of them. binData is null while fewer than six digits have been entered or when no BIN data is found.
Parameters
event(string): the number input event to attach thecallbackFunctionto. One ofinput,focus,blur,mouseover,mouseout,enter,esc,tab, orshift-tab.callbackFunction(function:(event) => void): a callback that receives data about theevent, for example:
Possible cardType values are: amex, dinacard, diners, discover, elo, jcb, mada, maestro, mastercard, meeza, uatp, unionpay, visa_electron, and visa.
Please note that the enumerated list provided above is subject to change or expansion over time. As such, be ready to accommodate and appropriately handle unfamiliar card brands.
cvvOn
Attach an event listener for the CVV input field.
For more details see Event listening.
Parameters
event(string): the CVV input event to attach thecallbackFunctionto. One ofinput,focus,blur,mouseover,mouseout,enter,esc,tab, orshift-tab.callbackFunction(function:(event) => void): a callback that receives data about theevent, for example:
Possible cardType values are: amex, dinacard, diners, discover, elo, jcb, mada, maestro, mastercard, meeza, uatp, unionpay, visa_electron, and visa.
Please note that the enumerated list provided above is subject to change or expansion over time. As such, be ready to accommodate and appropriately handle unfamiliar card brands.
setRequireCardHolder
Disable the requirement of passing a card-holder name in the additionalData object of the tokenize method.
Parameters
requireCardHolder(boolean): a boolean whether a card-holder name is required when calling tokenize.
enableAutofill
Enables autofill handling.
For details see Auto-fill card data.
onAutofill
Registers an event handler to receive auto filled data.
For details, see Auto-fill card data.
Parameters
autofillCallback(function:(data) => void): a callback that is called when card-data autofill is triggered and receivesdataabout the event, for example:
Deprecated methods
onNumberInput
This function is deprecated in favor of numberOn('input', callbackFunction).
onCvvInput
This function is deprecated in favor of cvvOn('input', callbackFunction).