Search Overlay

Getting Started

Download the SDK

Download the Paysafe Java 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.

Installation

In order to install the Java SDK, you must have JDK 1.6 or greater installed. All other requirements will be automatically downloaded upon launching the sample application.

The following steps describe how to configure and launch the sample application on a Unix system.

Configure Your Setup

Once you have installed the SDK, you will need to modify your configuration file with your Paysafe credentials.

  1. Install Gradle by executing the following command:
    sudo Gradle build
  2. Open the configuration file from Java SDK/samples /samples/src/main/resources/config.properties and update the following details:
Key Value
accountNumber

Your Paysafe Account Number

apiKey

Your Paysafe API Key user name

apiPassword

Your Paysafe API Key password

currencyBaseUnitsMultiplier

Transactions are actually measured in fractions of the currency specified in the currencyCode; 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 currencyCode USD the value is 100 but for Japanese YEN the multiplier would be 1 as there is no smaller unit.

currencyCode

The appropriate currency code, for example, USD

Launch the Sample Application

  1. In your command-line interface, navigate to the SDK root directory and execute the following command:
    sudo Gradle jettyRun
  2. Open a Web browser and navigate to http://localhost:8181/samples.
  3. Use the links to run the sample application.

Initialize the SDK in Your Application

To initialize the server environment parameters and API credentials in your application, use the command

PaysafeApiClient apiClient = new PaysafeApiClient(this.apiKey, this.apiPassword, Environment.TEST, this.accountNumber);

The Java SDK uses default configurations for parameters like connection_timeoutand max_connections. These settings cannot be configured externally.

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.