Overview
This page presents many functions that can be performed using Nuvei Web SDKs.
Tokenization
Returning User – No Collection
Many merchants keep accounts for their users (customers) and would like to charge them on multiple occasions. Using the Nuvei Tokenization solution, customer cardholder information only needs to be collected once, and becomes available for use in future payments from then on.
Collecting cardholder information – Calling Web SDK createPayment()
or authenticate3d()
methods return a userPaymentOptionId
, representing the customer’s full cardholder information collected during that transaction. From then on, you can offer “returning customers” the option to select a payment method from one of their previously stored payment methods.
Retrieving stored cardholder information – To retrieve the userPaymentOptionId
, specify the userTokenId
field when calling the createPayment()
or authenticate3d()
methods. The response identifies the customer, and guarantees that the payment methods (cards) returned, belong to that customer.
(The userPaymentOptionId
and the userTokenId
parameters should be included in the initial calls and any subsequent calls.)
Handling card expiration – Store card expiration details together with the userPaymentOptionId
. To set a new expiration date, send a createPayment()
call, as shown in the example below.
Example createPayment()
Request
var sfc = SafeCharge({ env: 'int', // Nuvei API environment – 'int' (integration) or 'prod' (production – default if omitted) merchantId: '<your merchantId>', // your Merchant ID provided by Nuvei merchantSiteId: '<your merchantSiteId>' // your Merchant Site ID provided by Nuvei }); function main() { sfc.createPayment({ sessionToken: '7db38b03-c1ae-45fc-8fce-8a55cfa4a6e0', //as received from the openOrder userTokenId: "487106", clientUniqueId: "695701003", // optional paymentOption: { userPaymentOptionId: "53622598", card: { expirationMonth: "12", //optional – sets a new expiration date expirationYear: "26", //optional CVV: "217" } }, billingAddress: { email: "[email protected]", country: "GB" } }, function(res) { console.log(res); }); }
Returning User – CVV
As explained in the previous section, the Web SDK can process tokenized cardholder information using only the userPaymentOptionId
field.
Authenticating payments with the CVV/CVC verification codes – To authenticate a payment with the CVV/CVC verification codes, send a createPayment()
or authenticate3d()
request to collect the CVV from Nuvei Fields.
Handling card expiration – Store card expiration details together with the userPaymentOptionId
. To set a new expiration date, send a createPayment()
call, as shown in the example below.
Example createPayment()
Request – without Nuvei Fields
var sfc = SafeCharge({ env: 'int', // Nuvei API environment - 'int' (integration) or 'prod' (production - default if omitted) merchantId: '<your merchantId>', // your Merchant ID provided by Nuvei merchantSiteId: '<your merchantSiteId>' // your Merchant Site ID provided by Nuvei }); function main() { sfc.createPayment({ sessionToken: "7db38b03-c1ae-45fc-8fce-8a55cfa4a6e0", //as received from the openOrder userTokenId: "487106", clientUniqueId: "695701003", // optional paymentOption: { userPaymentOptionId: "53622598", card: { expirationMonth: "12", //optional – sets a new expiration date expirationYear: "26", //optional CVV: "112" } }, billingAddress: { email: "[email protected]", country: "GB" } }, function(res) { console.log(res); }); }
Example createPayment()
Request – with Nuvei Fields
var sfc = SafeCharge({ env: 'int', // Nuvei API environment - 'int' (integration) or 'prod' (production - default if omitted) merchantId: '<your merchantId>', // your Merchant ID provided by Nuvei merchantSiteId: '<your merchantSiteId>' // your Merchant Site ID provided by Nuvei }); var ScFields = sfc.fields({ fonts: [{ cssUrl: 'https://fonts.googleapis.com/css?family=Roboto' }, // include your custom fonts ] }); var ScFieldStyles = { base: { color: '#32325D', fontWeight: 500, fontFamily: 'Roboto, Consolas, Menlo, monospace', fontSize: '16px', fontSmoothing: 'antialiased', '::placeholder': { color: '#CFD7DF', }, ':-webkit-autofill': { color: '#e39f48', }, }, invalid: { color: '#E25950', '::placeholder': { color: '#FFCCA5', }, }, }; var ScFieldClasses = { focus: 'focused', empty: 'empty', invalid: 'invalid', complete: 'complete', }; var cardCvc = ScFields.create('ccCvc', { style: ScFieldStyles, classes: ScFieldClasses }); cardCvc.attach('#card-cvc'); function main() { sfc.createPayment({ sessionToken: "7db38b03-c1ae-45fc-8fce-8a55cfa4a6e0", //as received from the openOrder userTokenId: "487106", paymentOption: { userPaymentOptionId: "13084323", card: { expirationMonth: "12", // optional – sets a new expiration date expirationYear: "2026", // optional CVV: cardCvc } } }, function(result) { console.log(result); }) }
Authorization-Only
Authorization is the first step in an “Auth-Settle” flow. It applies a temporary hold on funds in the customer’s selected payment method (card) account, for a limited time frame, to ensure there are sufficient funds to settle the payment.
To complete the purchase, the authorization must be followed by one or more REST API settle requests.
For example, a travel agent can send an authorization-only transaction when booking an airplane ticket. Later, they can send a REST API settle request to complete the transaction.
Alternatively, you can send a REST API void request to cancel the temporary hold.
Perform an authorization-only transaction as follows:
- First, send an
/openOrder
request and settransactionType="Auth"
.
Example
/openOrder
Request{ "merchantId":"<your merchantId goes here>", "merchantSiteId":"<your merchantSiteId goes here>", "clientUniqueId":"<unique transaction ID in merchant system>", "clientRequestId":"<unique request ID in merchant system>", "currency":"USD", "amount":"200", "userTokenId": "<unique customer identifier in merchant system>", "transactionType": "Auth", "timeStamp":"<YYYYMMDDHHmmss>", "checksum":"<calculated checksum>" }
<?php $safecharge = new \SafeCharge\Api\RestClient([ 'environment' => \SafeCharge\Api\Environment::INT, 'merchantId' => '<your merchantId>', 'merchantSiteId' => '<your merchantSiteId>', 'merchantSecretKey' => '<your merchantSecretKey>', ]); $openOrderRequest = $SafeCharge->getPaymentService()->openOrder([ 'clientUniqueId' => '<unique transaction ID in merchant system>', 'clientRequestId' => '<unique request ID in merchant system>', 'currency' => 'USD', 'amount' => '500', 'userTokenId' => '<unique customer identifier in merchant system>', 'transactionType' => 'Auth', ]); ?>
public static void main(String[] args) { // for initialization String merchantId = "<your merchantId>"; String merchantSiteId = "<your merchantSiteId>"; String merchantKey = "<your merchantKey>"; safecharge.initialize(merchantId, merchantSiteId, merchantKey, APIConstants.Environment.INTEGRATION_HOST.getUrl(), Constants.HashAlgorithm.SHA256); //for openOrder String userTokenId = "<unique customer identifier in merchant system>"; String clientUniqueId = "<unique transaction ID in merchant system>"; String clientRequestId = "<unique request ID in merchant system>"; String currency = "USD"; String amount = "500"; String transactionType = "Auth"; Safecharge safecharge = new Safecharge(); SafechargeResponse response = safecharge.openOrder(userTokenId, clientRequestId, clientUniqueId, null, null, null, null, currency, amount, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); }
var safecharge = new Safecharge( "<your merchantKey>", "<your merchantId>", "<your merchantSiteId>", "<your server host value>", HashAlgorithmType.SHA256 ); var response = safecharge.OpenOrder( "USD", "500", transactionType: "Auth", userTokenId: "<unique customer identifier in merchant system>", clientUniqueId: "<unique transaction ID in merchant system>", clientRequestId: "<unique request ID in merchant system>", );
const safecharge = require('safecharge'); safecharge.initiate(<merchantId>, <merchantSiteId>, <merchantSecretKey>, <env>); safecharge.paymentService.openOrder({ 'clientUniqueId' : '<unique transaction ID in merchant system>', 'clientRequestId' : '<unique request ID in merchant system>', 'currency' : 'USD', 'amount' : '500' 'transactionType' : 'Auth', 'userTokenId' : '230811147', }, function (err, result) { console.log(err, result) });
- Then, from your client side, use the
sessionToken
returned from the/openOrder
to send acreatePayment()
or anauthenticate3d()
request, and settransactionType="Auth"
.
Zero-Authorization
Send a “zero” amount transaction to verify a card, or add a card to your customer’s account for future use (tokenize the card).
Perform a zero-amount transaction as follows:
- First, send an
/openOrder
request and setamount
=0 andtransactionType=
“Auth“.
Example
/openOrder
Request{ "merchantId":"<your merchantId goes here>", "merchantSiteId":"<your merchantSiteId goes here>", "clientUniqueId":"<unique transaction ID in merchant system>", "clientRequestId":"<unique request ID in merchant system>", "currency":"USD", "amount":"0", "userTokenId": "<unique customer identifier in merchant system>", "transactionType": "Auth", "timeStamp":"<YYYYMMDDHHmmss>", "checksum":"<calculated checksum>" }
<?php $safecharge = new \SafeCharge\Api\RestClient([ 'environment' => \SafeCharge\Api\Environment::INT, 'merchantId' => '<your merchantId>', 'merchantSiteId' => '<your merchantSiteId>', 'merchantSecretKey' => '<your merchantSecretKey>', ]); $openOrderRequest = $SafeCharge->getPaymentService()->openOrder([ 'clientUniqueId' => '<unique transaction ID in merchant system>', 'clientRequestId' => '<unique request ID in merchant system>', 'currency' => 'USD', 'amount' => '0', 'userTokenId' => '<unique customer identifier in merchant system>', 'transactionType' => 'Auth', ]); ?>
public static void main(String[] args) { // for initialization String merchantId = "<your merchantId>"; String merchantSiteId = "<your merchantSiteId>"; String merchantKey = "<your merchantKey>"; safecharge.initialize(merchantId, merchantSiteId, merchantKey, APIConstants.Environment.INTEGRATION_HOST.getUrl(), Constants.HashAlgorithm.SHA256); //for openOrder String userTokenId = "<unique customer identifier in merchant system>"; String clientUniqueId = "<unique transaction ID in merchant system>"; String clientRequestId = "<unique request ID in merchant system>"; String currency = "USD"; String amount = "0"; String transactionType = "Auth"; Safecharge safecharge = new Safecharge(); SafechargeResponse response = safecharge.openOrder(userTokenId, clientRequestId, clientUniqueId, null, null, null, null, currency, amount, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); }
var safecharge = new Safecharge( "<your merchantKey>", "<your merchantId>", "<your merchantSiteId>", "<your server host value>", HashAlgorithmType.SHA256 ); var response = safecharge.OpenOrder( "USD", "0", transactionType: "Auth", userTokenId: "<unique customer identifier in merchant system>", clientUniqueId: "<unique transaction ID in merchant system>", clientRequestId: "<unique request ID in merchant system>", );
const safecharge = require('safecharge'); safecharge.initiate(<merchantId>, <merchantSiteId>, <merchantSecretKey>, <env>); safecharge.paymentService.openOrder({ 'clientUniqueId' : '<unique transaction ID in merchant system>', 'clientRequestId' : '<unique request ID in merchant system>', 'currency' : 'USD', 'amount' : '0' 'transactionType' : 'Auth', 'userTokenId' : '230811147', }, function (err, result) { console.log(err, result) });
- Then, from your client side, use the
sessionToken
returned from the/openOrder
to send acreatePayment()
or anauthenticate3d()
request, and set theamount
=0 andtransactionType
=”Auth“.
For full details, see the Zero-Authorization with Web SDK topic.
Without Nuvei Fields
You can send the cardholder details directly in a createPayment()
request without using Nuvei Fields, as shown in the example below.
Example createPayment()
Request
// Instantiate Nuvei API var sfc = SafeCharge({ env: 'int', // Nuvei API environment - 'int' (integration) or 'prod' (production - default if omitted) merchantId: '<your merchantId>', // your Merchant ID provided by Nuvei merchantSiteId: '<your merchantSiteId>' // your Merchant Site ID provided by Nuvei }); function main() { sfc.createPayment({ sessionToken: "7db38b03-c1ae-45fc-8fce-8a55cfa4a6e0", //as received from openOrder clientUniqueId: "695701003", // optional paymentOption: { card: { cardNumber: "5333302221254276", cardHolderName: "john smith", expirationMonth: "12", expirationYear: "25", CVV: "217" } }, billingAddress: { email: "[email protected]", country: "GB" } }, function(res) { console.log(res) }); }
Tokenization-Only
The tokenization-only flow uses the Nuvei Web SDK getToken()
method to tokenize a card and CVV. It returns a ccTempToken
which can then be used to process the payment using the /payment
API method.
The ccTempToken
is a temporary one-time token that is valid only for that API session. It can be used to process payments with the Nuvei server-to-server API, and still be PCI descoped.
The tokenization-only integration is suited to merchants who:
- Want to be descoped from PCI, but still be in control of the complete flow from their server side.
- Perform complete 3D-Secure flows, both server side and client side.
- Want to be able to choose between 3D-Secure frictionless and challenge modes.
See the full integration in the Tokenization-Only Flow topic.
3D-Secure Authentication Only
You can use the Web SDK to perform a 3D-Secure-Only request, where Nuvei only authorizes and authenticates your customer, but does not process payments.
Invoke this 3D-Secure-Only service by sending an authenticate3d()
request. The input parameters for this method are identical to the createPayment()
method, but instead of performing a payment, the method returns a 3D-Secure response that includes these authentication values:
eci
– Upon successful authentication, theeci
value is either 5 (Visa) or 2 (Mastercard).cavv
– Upon successful authentication, this contains the encrypted authentication value; otherwise, it is either empty or null.
Example authenticate3d()
Request
// Instantiate Nuvei API var sfc = SafeCharge({ env: 'int', // Nuvei API environment - 'int' (integration) or 'prod' (production - default if omitted) merchantId: '<your merchantId>', // your Merchant ID provided by Nuvei merchantSiteId: '<your merchantSiteId>' // your Merchant Site ID provided by Nuvei }); function main(){ sfc.authenticate3d({ "sessionToken": "7db38b03-c1ae-45fc-8fce-8a55cfa4a6e0", //as received from openOrder "clientUniqueId": "695701003", "paymentOption": { "card": { "cardNumber": "5333302221254276", "cardHolderName": "john smith", "expirationMonth": "12", "expirationYear": "22", "CVV": "217" } }, "billingAddress": { "email": "[email protected]", "country": "GB" } }, function(result) { console.log(result.cavv) }); }
Currency Conversion
MCP for Web SDK
Integrating MCP is relatively simple because the regular payment workflow remains unchanged, with a few additional steps.
See the full integration in the MCP for Web SDK topic.
DCC for Web SDK
Integrating DCC is relatively simple because the regular payment workflow remains unchanged, with a few additional steps.
See the full integration in the DCC for Web SDK topic.
APM Special Functions
APM Recurring Billing
The subMethod
class can be used in a createPayment()
request method to access the APM Recurring Billing special APM feature.
The createPayment()
example below shows:
- An APM payment using the
paymentMethod
parameter to specify the"apmgw_expresscheckout"
PayPal APM. - The optional
subMethod
parameter is used to specify the"ReferenceTransaction"
flag, which indicates the “PayPal – Billing Agreement“, in a special APM Recurring Billing flow.
Example createPayment()
Request
sfc.createPayment({ sessionToken: "<sessiontoken>", merchantId: "<your merchantId>", merchantSiteId: "<your merchantSiteId>", clientUniqueId: "695701003", paymentOption: { alternativePaymentMethod: { paymentMethod: "apmgw_expresscheckout" }, subMethod: { subMethod: "ReferenceTransaction" // APM provider who supports the APM Recurring Billing feature } }, billingAddress: { country: "GB", email: "[email protected]" } }, function(res) { console.log(res); if (res.cancelled === true) { example.querySelector('.token').innerText = 'cancelled'; } else { example.querySelector('.token').innerText = res.transactionStatus + ' – Reference: ' + res.transactionId; } example.classList.add('submitted'); });
Customer Registration via APM
The subMethod
class can be used in a createPayment()
request method to access the Customer Registration via APM special APM feature.
The createPayment()
example below shows:
- An APM payment using the
paymentMethod
parameter to specify the"apmgw_expresscheckout"
PayPal APM. - The optional
subMethod
parameter is used to specify the"QuickRegistration"
flag, which indicates PayPal as the Customer Registration provider, in an advanced Customer Registration via APM flow.
Example createPayment()
Request
sfc.createPayment({ sessionToken: "<sessiontoken>", merchantId: "<your merchantId>", merchantSiteId: "<your merchantSiteId>", clientUniqueId: "695701003", paymentOption: { alternativePaymentMethod: { paymentMethod: "apmgw_expresscheckout" }, subMethod: "QuickRegistration" // APM provider who supports the Customer Registration feature }, billingAddress: { country: "GB", email: "[email protected]" } }, function(res) { console.log(res); if (res.cancelled === true) { example.querySelector('.token').innerText = 'cancelled'; } else { example.querySelector('.token').innerText = res.transactionStatus + ' – Reference: ' + res.transactionId; } example.classList.add('submitted'); });
APM Functions
apmWindowType
This allows you to specify the window type (popup
, newTab
, or redirect
(modal window)) for the system to redirect the customer to their APM provider. Alternatively, by specifying customRedirect
, the system provides you with the redirectUrl
for you to initiate the redirect.
Possible values:
- popup (default): A pop-up window opens automatically, redirecting the customer to their APM provider’s page.
- newTab: A new tab opens automatically, redirecting the customer to their APM provider’s page.
- redirect: A modal window opens automatically on top of the current payment page, redirecting the customer to their APM provider’s page.
- customRedirect: You (the merchant) must redirect your customer to their APM provider’s page, as follows:
- The response from the request is included a
redirectUrl
.
Redirect your customer to thisredirectUrl
using a type of window of your choice, for example, IFrame, popup, a new tab, etc. - Your customer submits their APM details and closes the window.
- Check the transaction status either by sending a
/getPaymentStatus
request, or by setting up a to receive a direct notification (at the webhook endpoint on your system, which you provided in theurlDetails.notificationUrl
in the original/openOrder
request).
- The response from the request is included a
sfc.createPayment({ sessionToken: sessionData.sessionToken, apmWindowType: 'redirect', paymentOption: { alternativePaymentMethod: { paymentMethod: "apmgw_MoneyBookers", account_id: document.getElementById('accountId').value }, }, billingAddress: { country: "DE", email: "[email protected]" } }, function(res) { console.log(res) }) }
Apple Pay and Google Pay
Apple Pay Using Web SDK
Nuvei offers the following Apple Pay Integration solutions using Web SDK for adding the Apple Pay payment method to your websites and applications.
See full integration details in these topics:
Google Pay Using Web SDK
Nuvei offers a Google Pay Integration solution using Web SDK for adding the Google Pay payment method to your websites and applications.
See full integration detail, see the Google Pay (Web SDK) topic.
Scan Card
The Scan Card feature is an integrated SDK to native apps, which allows a customer to choose scanning a new payment card instead of manually entering their new card details when registering the new payment card.
The scanner scans the full card number, expiration date, and cardholder name. The user only needs to manually enter their CVV to complete the card registration.
User Flow
- User is purchasing on a merchant site integrated with Web SDK and Scan Card. The user taps the “SCAN CARD” button.
The user is transferred to camera scanner interface, which should contain basic text information on how to successfully scan a card. - The system displays a green rectangle where the card should be placed.
- The user places their payment card into the designated area.
The camera detects a card and indicates the detection visually by showing the scanned data. - The user is transferred from the camera scanner to the merchant’s Payment Page.
- The Web SDK populates the fields based on data from the scanner.
- The user must enter the CVV field to complete the registration process.
Web SDK Features
Blocking Cards
You can block cards from being included in requests, or from being processed, as well as from being displayed to the customer in the Payment Methods list.
This can be done while initiating Web SDK when you create the SafeCharge()
object.
Include the blockCards
array parameter and specify the blocking list.
For full details, see the Blocking Cards topic.
Example SafeCharge()
Function Specifying a blockCards
Array
sfc = SafeCharge({ env: 'int', // Nuvei API environment - 'int' (integration) or 'prod' (production - default if omitted) merchantId: '<your merchantId>', merchantSiteId: '<your merchantSiteId>', blockCards: [["visa","credit","corporate"],["amex","GB","prepaid"]] // Visa corporate credit cards and British prepaid Amex cards are blocked });
Future requests (for example, the createPayment()
and authenticate3d()
requests), which are called in this session using this object, block the cards specified in the blocking list.
Open Amount
This feature supports merchants in industries where the payment amount is not known at the beginning of the payment flow or needs to be updated on the client-side device, for example, in the gambling industry.
The Open Amount feature allows you to:
- Set Amount Limits (
min
andmax
) in the/openOrder
request. - Call the setOpenAmount() method to set/change the
amount
(after sending the/openOrder
request but before calling thecreatePayment()
request).
Set Amount Limits
You can set “payment amount limits” in the/openOrder
request by including the openAmount{min,max}
object.
Send an /openOrder
request with its mandatory parameters, and include an openAmount{min,max}
object (and the optional amount
), as shown below:
Example /openOrder
Request with an openAmount{min,max}
Object
{ "merchantId": "<your merchantId goes here>", "merchantSiteId": "<your merchantSiteId goes here>", "clientUniqueId": "<unique transaction ID in merchant system>", "clientRequestId": "<unique request ID in merchant system>", "currency": "USD", "openAmount": { "min": "1", "max": "100" }, "amount": "50", "timeStamp": "<YYYYMMDDHHmmss>", "checksum": "<calculated checksum>" }
disableNuveiAnalytics
When set to true, analytics are disabled to prevent the analytics tool from conflicting with the merchant code.
The default value is false.
let sfc = SafeCharge({ sessionToken : orderObj.sessionToken, // sessionToken generated by your server env: 'int', // the environment you’re running on merchantId: orderObj.merchantId, // your Merchant ID provided by Nuvei merchantSiteId : orderObj.merchantSiteId, // your merchantsite id provided by Nuvei disableNuveiAnalytics: true, });
showAccountCapture
When set to true, the bank capture redirectUrl
is opened in a pop-up window. If the urlDetails
class is empty (no URLs received), then the redirect pop-up is closed automatically.
The default value is false.
var sfc = SafeCharge({ "sessionToken":"orderObj.sessionToken", "env":"int", "merchantId":"orderObj.merchantId", "merchantSiteId":"orderObj.merchantSiteId", "showAccountCapture":true //false (default) });
Web SDK Methods
Payment Methods
Press here to see all the Web SDK methods, which provide additional ways to control the payment process and/or perform custom actions during the payment process.
Withdrawal Methods
Merchants can use the following Web SDK methods to submit and manage withdrawal requests for existing users:
submitWdRequest()
– The merchant submits the withdrawal request with the following required parameters:upoId
,amount
, anduserId
. The response includeswdRequestStatus
with the current status of the withdrawal request.getWdRequests()
– Returns a list of the user’s pending withdrawal requests for the merchant to show to the user. The merchant submits the request withuserTokenId
, a required parameter. The response includeswithdrawalRequest
with details of the withdrawal requests, along with details of the order for each withdrawal request.cancelWdRequest()
– Cancels an existing withdrawal request. The merchant submits the request with the following required parameters:userTokenId
,wdRequestId
, andmerchantWDRequestId
. The response includeswdRequestStatus
with the current status of the withdrawal request.
For more information, press here.
Web SDK Process Events
onPaymentEvent
Event Callback
This event callback provides maximum transparency for the payment flow, by reporting back to you at each stage of the payment flow. You can use this information for analytics or to perform some custom action.
Example onPaymentEvent
Call
onPaymentEvent: function(result) { console.log('onPaymentEvent =>', result); },
The following response information is passed via the event callback when it is triggered:
pm
Example values:- cc_card
- apmgw_neteller
eventType
Possible values:- initiated (once payment initiated)
- tokenized (after initAuth3D)
- paymentStarted (after clientPayment() / clientAuthorize3D())
- challengeStarted (before redirection)
- challengeEnded (after finalizePayment())
- redirectionStarted (for APM)
- redirectionEnded (for APM)
threeD
(only when 3DS is applicable – no need for the irrelevant events)version
flow
Possible values:- frictionless
- challenge
Example onPaymentEvent
Response
{ "eventType": "paymentStarted", "threeD": { "version": "", "flow": "" }, "pm": "cc_card" }