Getting Started

Download the SDK

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

Installation

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

bundle install

Ruby Setup on Windows

On Windows, to be able to perform HTTPS operations, set the following environment variable to point to a valid CA certificate on your system:

SSL_CERT_FILE

Launch the Sample Application

  1. From the root Ruby folder, navigate to the folder:
    \sample_rails_app\config\environments
  2. 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.
    Key Value

    currency_code

    The appropriate currency code, for example, USD

    currency_base_units

    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.

    paysafe_account_number

    Your Paysafe Account Number

    paysafe_api_key

    Your Paysafe API Key username

    paysafe_api_secret

    Your Paysafe API Key password


    In a production environment, you should edit production.rb.
  3. Execute the following commands to start the Ruby server:
    rails server
  4. Open a web browser and navigate to http://localhost:3000.

Initializing the SDK in Your Application

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

  1. From the root Ruby folder, open the configuration file:
    \sample_rails_app\config\environments\development.rb
  2. 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.

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.

Did you find this page useful?