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 More about Authentication for more information.
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.
- Install Gradle by executing the following command:
sudo Gradle build
- Open the configuration file from Java SDK/samples /samples/src/main/resources/config.properties and update the following details:
Your Paysafe Account Number
Your Paysafe API Key user name
Your Paysafe API Key password
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.
The appropriate currency code, for example, USD
Launch the Sample Application
- In your command-line interface, navigate to the SDK root directory and execute the following command:
sudo Gradle jettyRun
- Open a Web browser and navigate to http://localhost:8181/samples.
- 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.
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.