Requirements
Node.JS 10.x or later
Setting NPM Dependencies
The Nuvei SDK for Node.JS employs the NPM package.
Initializing the SDK
When you initialize the SDK, you effectively perform the authentication that is needed to send requests to the REST API. Ensure that you initialize the SDK properly by including the following before any request
const safecharge = require('safecharge'); safecharge.initiate(<merchantId>, <merchantSiteId>, <merchantSecretKey>, <env>); // env is optional can be 'int' (integration) or 'prod' (production - default if omitted)
Running Your First Request
safecharge.paymentService.createPayment({ "amount" : "10", "currency" : "EUR", "sessionToken" : '<sessionToken>', /* taken from openOrder result */ "paymentOption": { "card": { "expirationYear" : "2024", "CVV" : "123", "cardHolderName" : "John Smith", "expirationMonth": "01", "cardNumber" : "4000020951595032" } } }, function (pErr, pResult) { console.log(pErr, pResult) });
Advanced Sample
safecharge.paymentService.createPayment({ "currency" : "EUR", "amount" : "10", "paymentOption" : { "card" : { "cardNumber" : "4012001037141112", "cardHolderName" : "John Smith", "expirationMonth" : "01", "expirationYear" : "2020", "CVV" : "122", "threeD" :{ "version":"2", "challengePreference" : "1", "notificationUrl" : "https://www.merchant.com/notificationURL/", "merchantUrl" : "https://www.merchant-website.com", "platformType" : "02", "deliveryEmail" : "[email protected]", "deliveryTimeFrame" : "1", "giftCardAmount" : "456", "giftCardCount" : "10", "giftCardCurrency" : "826", "preOrderDate" : "20190219", "preOrderPurchaseInd" : "2", "reorderItemsInd" : "2", "shipIndicator" : "1", "rebillExpiry" : "", "rebillFrequency" : "", "ChallengeWindowSize" : "2" "browserDetails" :{ "acceptHeader" :"text/html,application/xhtml+xml", "ip" :"192.168.1.11", "javaEnabled" :"TRUE", "javaScriptEnabled" :"TRUE", "language" :"EN", "colorDepth" :"48", "screenHeight" :"400", "screenWidth" :"600", "timeZone" :"0", "userAgent" :"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47" } } } }, "shippingAddress" : { "firstName" : "some first name", "lastName" : "some last name", "address" : "some street", "phone" : "972502457558", "zip" : "123456", "city" : "some city", "country" : "DE", "state" : "", "email" : "[email protected]", "county" : "Anchorage", }, "dynamicDescriptor" : { "merchantName" : "merchant Name" "merchantPhone" : "merchant Phone" }, "billingAddress" : { "firstName" : "some first name", "lastName" : "some last name", "address" : "some street", "phone" : "972502457558", "zip" : "123456", "city" : "some city", "country" : "DE", "state" : "", "email" : "[email protected]", "county" : "Anchorage" }, "deviceDetails" : { "ipAddress" : "<customer's IP address>" }, }, function (pErr, pResult) { console.log(pErr, pResult) });