• Documentation
  • API Reference
  • Documentation
  • API Reference
Expand All Collapse All
  • Payment Overview
    • Introduction
    • Choosing an Integration Method
  • Accept Payment
    • Payment Page
      • Quick Start
      • Input Parameters
      • Output Parameters
    • Web SDK
      • Quick Start
      • Nuvei Fields
        • Styling
      • Additional Functions
      • APM Payments
      • Tokenization-Only Flow
      • Scenarios
      • Using ReactJS
        • Full Samples
        • Sandbox Examples
      • FAQs
    • Checkout
      • Quick Start
        • UI Customization
        • Payment Customization
        • Advanced Controls
        • Checkout Examples
      • Server-to-Server
      • Payment Scenarios
      • Mobile SDKs (Beta Release)
        • Android Mobile SDK (Beta Release)
        • iOS Mobile SDK (Beta Release)
      • Flow Diagrams
      • Plugins
        • Magento
          • Rebilling with Magento
        • WooCommerce
          • Rebilling with WooCommerce
        • PrestaShop
          • PrestaShop with Web SDK
          • PrestaShop with Checkout
        • OpenCart
        • Shopify (via AsiaBill)
        • Mirakl
        • Salesforce
        • SAP
        • WIX
      • Marketplaces
    • Features
      • Authentication
      • Financial Operations
        • Refund
        • Void
        • Auth and Settle
        • Partial Approval
        • Currency Conversion (DCC and MCP)
        • Payout
      • Card Operations
        • Card-on-File
        • PCI and Tokenization
        • Zero-Authorization
        • Merchant-Initiated Transactions (MIT)
        • Blocking Cards
      • Subscription (Rebilling)
      • 3D-Secure
        • 3D-Secure Explained
        • 3DS Implementations
          • 3DS MPI-Only Web SDK
          • 3DS MPI-Only REST
          • 3DS External MPI
          • 3DS Responses
        • 3DS Functions
          • 3D-Secure Fingerprinting
          • 3D-Secure Authentication Challenge
      • Webhooks (DMNs)
        • Payment Transaction Requests
        • Control Panel Events API
    • Guides
      • Testing Cards, APIs and APMs
        • Testing Cards
        • Testing APIs with Postman
        • Testing APMs
      • Response Handling
      • Alternative Payment Guides (APMs)
      • Airline Ticket Guides
        • Airline Addendum
        • External Authorization Addendum
      • Payment Facilitators (PayFac)
      • Cashier
        • Cashier Events Guide
        • Cashier Features
      • Withdrawal Guide
      • Risk Guide
        • Nuvei Services
        • Transaction Types
        • Credits and Payouts
        • Fraud to Sale Programs
        • Compliance Programs
        • Chargebacks
      • eKYC Guide
      • Server SDKs
        • Java SDK
        • .NET SDK
        • PHP SDK
        • Node.JS SDK
      • Fast Track Onboarding Developer Guide
      • Currency Conversion Guides
        • Multiple Currency Pricing (MCP)
        • Dynamic Currency Conversion (DCC)
          • DCC in Cashier or Payment Page
          • DCC in REST API Workflows
          • DCC in Web SDK Workflows
      • Website Compliance Guides
    • Additional Links
      • FAQs
      • API Reference
      • Release Notes
      • Country and Currency Codes

    Node.JS SDK

    On this page:
    • Requirements
    • Setting NPM Dependencies
    • Initializing the SDK
    • Running Your First Request
    • Advanced Sample

    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"        : "deliveryEmail@somedomain.com",
                    "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"     : "someemail@somedomain.com",
            "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"     : "someemail@somedomain.com",
            "county"    : "Anchorage"
        },
        "deviceDetails"  : {
            "ipAddress"  : "192.168.1.54"
        },
    }, function (pErr, pResult) {
        console.log(pErr, pResult)
    });

     

    2022 Nuvei. All rights reserved.