Search Overlay

Getting Started

Download the SDK

Download the Paysafe Node.js SDK from GitHub

Before You Begin

Before you use an SDK, you’ll need the API credentials (API Key) that it uses to make JSON requests to our server via the Paysafe REST API.

  • Your Paysafe API Key Username
  • Your Paysafe API Key Password
  • Your Paysafe Account Number

To get your test account, if you intend to use the Direct Debit SDK, contact Paysafe support, otherwise click Sign Up above. Once logged in to the Back Office you can retrieve your Account Number (choose Accounts and copy it from the Account column) and your API Key User name and Password (choose Settings > API Key). See Authentication for more information.


Launch the Sample Application

  1. Navigate to the sample_application folder.
  2. Update the following parameters in config.js with your own credentials, ensuring that each value is enclosed within matching quotes.
    Key Value

    Transactions are actually measured in fractions of the currency specified in the currency_code; for example, USD transactions are measured in cents. This multiplier is how many of these smaller units make up one of the specified currency. For example, with the currency_code USD the value is 100 but for Japanese YEN the multiplier would be 1 as there is no smaller unit.

    currency_code The currency for your account, such as USD

    Your Paysafe Account Number


    Your Paysafe API Key username


    Your Paysafe API Key password


    TEST or LIVE. See Initializing the SDK in Your Application for details.

  3. Use the package manager, npm, to install the Request module to use for HTTP calls by executing the following:
    npm install request
  4. Use npm to install the Node Express web application framework by executing the following:
    npm install express
  5. By default the server uses port 3000. If you do not want to use this port, execute the following:
    set PORT=required-server-port
    export PORT=required-server-port
  6. Type the following command to start the server:
    node server.js
  7. If your Node.js server is running on port 3000, open a browser and navigate to the sample URLs below, substituting actual attribute values for the placeholders delimited by angle brackets, <>. If you changed the port number in the step above also substitute your chosen number for 3000.
    • http://localhost:3000/createProfile – for creating a profile using dummy data
    • http://localhost:3000/createCard?profileId=<profile_id>&cardNumber=<card_number> – for creating a card using dummy data
    • http://localhost:3000/silentHosted – for executing a Silent Post using dummy data
    • http://localhost:3000/simpleHosted – for executing a Hosted Payment order using dummy data
    • http://localhost:3000/cardPayment?cardNumber=<card_number> – for processing a card payment using dummy data
    • http://localhost:3000/cardCustomer?paymentToken=<card_payment_token> – for processing a payment using a dummy token

Initializing the SDK in Your Application

For the Paysafe Node.js SDK to work with your merchant application, the server hosting the application must be able to connect to the relevant Paysafe server, either:

  • TEST – The Paysafe Test server
  • LIVE – The Paysafe Production server

The URLs of these servers, and the following environment configuration parameters for both, are defined in the script file, /bin/Environment.js.

Parameter Default Value Description
host Paysafe REST API Endpoint.
maxSockets 10 The maximum number of connections per connection pool.
timeOut 30000 The maximum time (in ms) the SDK will wait for a response from the Paysafe Servers.

To initialize the Paysafe SDK in your application use the following commands:

  1. Import the Paysafe SDK:
    var paysafeApiClient = require("PaysafeApiClient");
  2. Import the configuration file containing your API key, etc.
    var config = require("./config");
  3. Create the Paysafe API Client object.
    var paysafeApiClient = new paysafeApiClient(config.paysafeApiKeyId, config.paysafeApiKeySecret, config.paysafeEnvironment, config.paysafeAccountNumber);

To change the environment configuration settings use:
paysafeApiClient.updateConfig(host, maxSockets, timeOut);

Example Code

The following topics contain example code for each API:

  • Card Payments API – Process all major credit cards through the Paysafe payment gateway.
  • Direct Debit API – Process purchases and credits through a variety of bank schemes.
  • Customer Vault API – Make repeat payments without having to directly access the cardholder information.
  • 3D Secure API – Mitigate fraud while providing additional security for customers using their cards online.
  • Exceptions – Handle various exceptions to ensure accurate payment processing.

The above examples do not include initialization.

To download a French version of this guide in PDF, click here.