Nuvei Web SDK 2.0 supports the methods and functions appearing on this page.
Initialization
nuveiWebSDK()
nuveiWebSDK
– This method initializes the Web SDK.
Example Request
var nuveiWebSDK = webSDK({ //env: 'int', // int, prod sessionId: 'sid_f3a192a9844545d29a11cbc3e3a46bb2' // received from /orders API response support19Digits:true , // false (default) alwaysCollectCvv : 'optional', blockCards: ['visa'], / Visa cards are blocked onResult: function(res) { console.log('onResult callback', res);}} );
Input Parameters
Parameter | Type | Description |
---|---|---|
accessToken Mandatory | String(20) | The accessToken retrieved from a POST /orders request that references the order created in the Nuvei system. |
env Mandatory | String(4) | The Nuvei environment you’re running on. If not provided, prod is assumed. Possible values: prod – Production int – Integration |
BlockCards | Array | Specifies which sets of cards can be blocked from appearing to the customer in Payment Methods lists. To block a set of cards, simply include the blockCards parameter in the request and specify a blocking list. brand : visa, mastercard, amex, diners, discover, jcb, dankort, unionpay Press here for more information. Example blockCards Blocking Lists blockCards: [“visa”,“amex”] // Visa and Amex cards are blocked |
Support19Digits | Boolean | When set to true, Web SDK supports unique credit card lengths, such as 15 and 19 digits. Possible values: true false |
AlwaysCollectCvv | String | Used to set the CVV parameter to optional. By default, the CVV is always collected. Set this parameter to “optional” to make the CVV parameter optional. NOTE: If the merchant does not want to collect the CVV at all, then they should use Nuvei’s Three-Part Card Fields Integration and not include the CVV/CVC value. |
Payment Methods
payment()
Use this method to process end-to-end card payments. The method receives any form of cardholder information, tokenized or not, and performs the process to the end, including seamlessly performing any 3D-Secure or PCI requirement.
Before submitting a payment using the client-side Web SDK 2.0, you need to send a server-to-server POST /orders
REST API 2.0 request that authenticates your Nuvei merchant credentials and creates a session. For details, press here.
Example Request
function payment() { nuveiWebSDK.payment({ paymentOption: { card: { cardHolderName: document.getElementById('cardHolderName').value, } } useFields: 'ccNumber' }).then(x => console.log(x)) }
Input Parameters
Parameter | Type | Description |
---|---|---|
processingEntity Mandatory | uuid | Processing entityId provided by Nuvei. |
merchantTransactionId | string(45) | ID of the transaction in the merchant system. |
sourceApplication | string(50) | |
custom | object | property name* - string |
deviceDetails | object | Include the following parameters:deviceName - stringdeviceOS - stringdeviceType - stringipAddress - stringbrowser - object, including:
|
paymentOption Mandatory | object | Include the following parameters:store – Possible values:
Card - object, including:
paymentToken - object, including:
alternativePaymentMethod - object, including:
networkToken - object, including:
|
buyerDetails | object | Include the following parameters:firstName - string(30)lastName - string(40)companyName - string(100)locale - string(5)dateOfBirth - dateemail - string(100)phone - string(18) phone2 - string(18)workPhone - string(18)nationalIdentificationNumber - string(25)billingAddress - object, including:
shippingAddress - object, including:
|
logging | object | property name* - string |
cvvIcon | Boolean | Determines whether a default icon appears in the CVV entry field, including a mouseover tooltip. Possible values: false (default) – No icon appears. true – A default icon appears. |
object | A custom image appears and you can configure where the tooltip appears. Include the following parameters:backgroundImage – Custom image URL.tooltipPosition – top or bottom. |
Output Parameters
Parameter | Type | Description |
---|---|---|
paymentId | int64 | The ID generated by REST API. |
transactionId | transactionId(20) | Nuvei Digital Payments Gateway Transaction ID. |
externalTransactionId | transactionId(20) | A unique ID generated by Nuvei that represents the APM transaction. |
amount | number | The transaction amount. |
currency | string(3) | The 3-letter ISO currency code. |
transactionType | transactionType | Possible values: Auth Sale PreAuth Settle Void Refund InitAuth3D Auth3D Sale3D |
result Mandatory | string | Include the following parameters:status (string)Mandatory Possible values: approved authorizedOnly declined error pending redirect challenge fingerprint authenticated authenticationNotSupported Error - object |
authCode | string(128) | The authorization code of the transaction. |
cvv2Code | string(1) | CVV2 (card verification value) response. Possible values: M – CVV2 Match N – CVV2 No Match P – Not Processed U – Issuer is not certified and/or has not provided Visa with the encryption keys. S – CVV2 processor is unavailable. |
avsCode | string(1) | The AVS (address verification) response. The following values may be returned: A – The street address matches, but the ZIP code does not. W – Whole 9-digit ZIP code matches, but the street address does not. Y – Both the 5-digit ZIP code and the street address match. X – An exact match of both the 9-digit ZIP code and the street address. Z – Only the 5-digit ZIP code matches, the street code does not. U – Issuer Unavailable S – Not Supported R – Retry B – Not Authorized (declined) N – Both street address and ZIP code do not match. |
partialApproval | object | Include the following parameters:requestedAmount - numberMandatory requestedCurrency - string, >= 3 characters and
Mandatory |
redirectUrl | string(2000) | User to redirect the customer to the payment page for use in future transactions. |
paymentOption | object | Include the following parameters:Card - object, including:
alternativePaymentMethod - object, including:
networkToken - object, including:
|
providerResponseDetails | object | Include the following parameters:Code - string (100)Reason - string (400) |
additionalTransactionInfo | object | Include the following parameters:additionalTransactionBankId - stringreferenceId - string |
setOpenAmount()
The setOpenAmount()
method is used to set or override the payment amount (in the same currency) from the client side.
You can only call the setOpenAmount()
method before calling a payment()
request.
Use this method:
- When an amount was not sent in the POST
/orders
request. - To change a payment amount (same currency) if you have not called the
payment()
request yet. For example, whenever the user changes any amount on your payment page.
Call the setOpenAmount()
method from the client-side, as shown below.
Example Request
function setOpenAmount() { var openAmount = document.getElementById('openAmount').value; nuveiWebSDK.setOpenAmount(openAmount).then(console.log); }
APMs
getPaymentOptions()
This method returns the APMs supported with all the metadata needed for displaying them to the user and preparing them for processing, such as their display name, logo, required input to collect from the end user, etc. One important parameter it returns for each APM is the APM identifier with Nuvei that you must submit when requesting the payment (with the payment()
method).
The getPaymentOptions()
method can retrieve either the entire APM set supported by your account with Nuvei or, alternatively, a customized set of APMs. For example, you can request to retrieve APMs corresponding to certain criteria such as by transaction currency or by the user country.
Example Request
function getPaymentOptions() { nuveiWebSDK.getPaymentOptions({ countryCode: 'US', currency: 'USD', includeOptionalFields: false }).then(console.log);
Input Parameters
Parameter | Type | Description |
---|---|---|
Currency | String(3) | The 3-letter ISO currency code. If the currency is provided, the returned APM set only consists of APMs supporting this currency. If not provided, the APM set includes all APMs regardless of their supported currencies. |
CountryCode | String(2) | The 2-letter ISO country code. If provided, the returned APM set consists only of APMs supported in this country. |
IncludeOptionalFields | Boolean | This parameter determines if you would like to include optional fields in the response. The default value is False. |
Output Parameters
Parameter | Type | Description |
---|---|---|
PaymentOption Mandatory | String | Include the following parameters:name - string(50), mandatorysupportsFieldsRecovery - boolean, mandatory. The default is False.fields - List of input fields for a payment option, including:
|
result Mandatory | String | Include the following parameters:status - string. The transaction status.Possible values: approved authorizedOnly declined error pending redirect challenge fingerprint authenticated authenticationNotSupported errors - object, including:code - string(11), for example, 7000.1000. If an error occurs on the request side, an error code is returned in this parameter.reason - string(400), for example, Internal Processing Error. If an error occurs on the request side, an error code is returned in this parameter. |
Additional Functions
destroy()
This method is used to remove the payment element from the payment page.
document.getElementById("SfcFields").addEventListener('click', function (ev) { ev.preventDefault(); SfcFields.destroy(); });