Download the SDK
Download the Paysafe PHP 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.
To use the PHP SDK that you must have PHP 5.5 or later and cURL installed. Also, you must be able to use cURL to complete an SSL connection to the API endpoints from within your hosting environment. If any cURL errors are returned, perform connectivity troubleshooting within your hosting environment.
The PHP SDK runs under the following operation systems:
- MS Windows XP/7/8
- Ubuntu 14.04 (Linux)
- Mac OS X 10.9.5
The instructions in this topic apply to all operating systems except where specified.
Additional Setup on Windows
To be able to perform HTTPS operations, set the following environment variable to point to a valid CA certificate on your system:
Alternatively, you can make a call in your application to the following static method using the path to your CA certificate:
- Navigate to the /sample folder and update the following parameters in config.php with your own credentials, ensuring that each value is enclosed within matching quotes.
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
Your Paysafe Account Number
Your Paysafe API Key username
Your Paysafe API Key password
For the PHP 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
By default, the sample applications use the TEST server. This is defined near the start of each application configuration file in the /sample folder (the *.php files other than config.php).
The PHP SDK uses default values for server parameters like connection_timeout and max_connections, which you cannot change externally.
- To run the sample application using the PHP built-in web server and index.html, type the following command:
php -S localhost:8081
- Open a Web browser and navigate to: http://localhost:8081/.
- In the page that is displayed, use the links to run the sample applications.
Initializing the SDK in Your Application
To initialize the Paysafe SDK in your application use the following commands:
- Import the configuration file containing your API key, etc.
- Make the server environments available to your application:
- Create the Paysafe API client. For example, To use the Test server include the line:
$Paysafe_api_object = new PaysafeApiClient($paysafeApiKeyId, $paysafeApiKeySecret, Environment::TEST, $paysafeAccountNumber);
To use the Live server, replace TEST with LIVE.
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.
Note: The above examples do not include initialization.
To download a French version of this guide in PDF, click here.