Method reference
Methods for initializing and using PaymentJs.
Methodsβ
initβ
PaymentJs.init(publicIntegrationKey, numberDivId, cvvDivId, completeCallback);
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β
PaymentJs.initCvvRefresh(publicIntegrationKey, referenceTransactionId, cvvDivId, completeCallback);
PaymentJs.initCvvRefresh(publicIntegrationKey, paymentToken, cvvDivId, completeCallback);
Initializes the PaymentJs object for CVV refreshing.
Parametersβ
publicIntegrationKey(string): the connector's public integration key (provided to you with your credentials).infoThe 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.
- must use the same customer profile container as the used
- 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β
PaymentJs.tokenize(additionalData, successCallback, errorCallback);
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:{"card_type": "visa","full_name": "Alex Smith","bin_digits": "41111111","first_six_digits": "411111","last_four_digits": "1111","month": "10","year": "2031","fingerprint": "46f7adfeb0a123fb8fcbfasdf6171asd6b3dfas44834c"}Possible
cardTypevalues are:amex,dinacard,diners,discover,elo,jcb,mada,maestro,mastercard,meeza,uatp,unionpay,visa_electron, andvisa.Forward compatibilityPlease 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β
PaymentJs.refreshCvv(successCallback, errorCallback);
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β
PaymentJs.initRiskScript(options, completeCallback);
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β
PaymentJs.setNumberStyle(styleObject);
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{"border-color": "red","font-size": "10px"}::placeholder, e.g.{"border-color": "red","font-size": "10px","::placeholder": {"color": "#a00"}}PCI compliance: no external resource loadingIn 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β
PaymentJs.setCvvStyle(styleObject);
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{"border-color": "red","font-size": "10px"}::placeholder, e.g.{"border-color": "red","font-size": "10px","::placeholder": {"color": "#a00"}}PCI compliance: no external resource loadingIn 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β
PaymentJs.setNumberPlaceholder(placeholderText);
Sets the placeholder text for the number input field.
Parametersβ
placeholderText(string): text for the placeholder of the number input field.
setCvvPlaceholderβ
PaymentJs.setCvvPlaceholder(placeholderText);
Sets the placeholder text for the CVV input field.
Parametersβ
placeholderText(string): text for the placeholder of the CVV input field.
setNumberInputTypeβ
PaymentJs.setNumberInputType(inputType);
Sets the type attribute on the number input field.
Parametersβ
inputType(string): type value (i.e. 'text', 'password').
setCvvInputTypeβ
PaymentJs.setCvvInputType(inputType);
Sets the type attribute on the CVV input field.
Parametersβ
inputType(string): type value (i.e. 'text', 'password').
setNumberAttributeβ
PaymentJs.setNumberAttribute(attribute, value);
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β
PaymentJs.setCvvAttribute(attribute, value);
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β
PaymentJs.numberOn(event, callbackFunction, { getBinData: boolean });
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.
{
"binData": {
"cardBrand": "VISA",
"fundingSource": "CREDIT",
"issuer": "VISA Bank 1",
"normalizedCardBrand": "visa",
"subBrand": null
},
...
}
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:{"cardType": "visa","cvvLength": 3,"numberLength": 12,"validCvv": true,"validNumber": true}Possible
cardTypevalues are:amex,dinacard,diners,discover,elo,jcb,mada,maestro,mastercard,meeza,uatp,unionpay,visa_electron, andvisa.Forward compatibilityPlease 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β
PaymentJs.cvvOn(event, callbackFunction);
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:{"cardType": "visa","cvvLength": 3,"numberLength": 12,"validCvv": true,"validNumber": true}Possible
cardTypevalues are:amex,dinacard,diners,discover,elo,jcb,mada,maestro,mastercard,meeza,uatp,unionpay,visa_electron, andvisa.Forward compatibilityPlease 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β
PaymentJs.setRequireCardHolder(requireCardHolder);
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β
PaymentJs.enableAutofill();
Enables autofill handling.
For details see Auto-fill card data.
onAutofillβ
PaymentJs.onAutofill(autofillCallback);
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:{card_holder: "Alex Smith",month: 10,year: 2031,}
Deprecated methodsβ
onNumberInputβ
PaymentJs.onNumberInput(callbackFunction);
This function is deprecated in favor of numberOn('input', callbackFunction).
onCvvInputβ
PaymentJs.onCvvInput(callbackFunction);
This function is deprecated in favor of cvvOn('input', callbackFunction).