Sha256: e9f843e83a06fa489a58bd11acc330cd7215d5f6f873a4f2b9c75a3a1c4c34c9

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

require 'paypalhttp'
require "base64"

module PayPal

  SANDBOXAPI = 'https://api.sandbox.paypal.com'
  LIVEAPI = 'https://api.paypal.com'
  SANDBOXWEB = 'https://sandbox.paypal.com'
  LIVEWEB = 'https://paypal.com'

  class PayPalEnvironment < PayPalHttp::Environment
    attr_accessor :client_id, :client_secret, :web_url

    def initialize(client_id, client_secret, base_url, web_url)
      super(base_url)
      @client_id = client_id
      @client_secret = client_secret
      @web_url = web_url
    end

    def authorizationString
      encoded = Base64.strict_encode64("#{@client_id}:#{@client_secret}")
      return "Basic #{encoded}"
    end
  end

  class SandboxEnvironment < PayPal::PayPalEnvironment
    def initialize(client_id, client_secret)
      super(client_id, client_secret, PayPal::SANDBOXAPI, PayPal::SANDBOXWEB)
    end
  end

  class LiveEnvironment < PayPal::PayPalEnvironment
    def initialize(client_id, client_secret)
      super(client_id, client_secret, PayPal::LIVEAPI, PayPal::LIVEWEB)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
paypal-checkout-sdk-1.0.6 lib/core/paypal_environment.rb
paypal-checkout-sdk-1.0.5 lib/core/paypal_environment.rb
paypal-checkout-sdk-1.0.4 lib/core/paypal_environment.rb
paypal-checkout-sdk-1.0.3 lib/core/paypal_environment.rb