Download the Paysafe Ruby SDK from GitHub
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.
The sections that follow include commands you should enter at the command prompt.
Before you can install the Ruby SDK, you must first download the latest version of Ruby from https://www.ruby-lang.org/en/downloads.
Navigate to the root project folder and execute the following commands to build and install the gem and rails, to update JSON to the correct version, and install the software required for the SDK:
gem build paysafe.gemspec
gem install paysafe
gem install rails
bundle update json
On Windows, to be able to perform HTTPS operations, set the following environment variable to point to a valid CA certificate on your system:
- From the root Ruby folder, navigate to the folder:
- In a text editor, open development.rb and update the following parameters with your own credentials, ensuring that each value is enclosed within matching quotes.
The appropriate currency code, for example, USD
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.
Your Paysafe Account Number
Your Paysafe API Key username
Your Paysafe API Key password
In a production environment, you should edit production.rb.
- Execute the following commands to start the Ruby server:
- Open a web browser and navigate to http://localhost:3000.
To initialize the Paysafe SDK in your application use the following commands:
- From the root Ruby folder, open the configuration file:
Create the Paysafe client object, using the parameters in the table above.
client = Paysafe::Paysafe:PaysafeApiClient.new(config.paysafe_api_key,config.paysafe_api_secret, Paysafe::Environment::TEST,config.paysafe_account_number )
The Ruby SDK uses default values for server parameters like connection_timeout and max_connections, which you cannot change 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.