Sha256: a9395167646c6ab8c4512c89fd7aa441d65e78e6b408bb28b6eeefb4740579cf

Contents?: true

Size: 1.03 KB

Versions: 8

Compression:

Stored size: 1.03 KB

Contents

require 'logger'
require 'base64'
require 'rest-client'
require 'uri'

require 'openpay/open_pay_resource_factory'
require 'errors/openpay_exception'

LOG= Logger.new(STDOUT)
#change to Logger::DEBUG if need trace information
#due the nature of the information, we recommend to never use a log file when in debug
LOG.level=Logger::FATAL

class OpenpayApi
  #API Endpoints
  API_DEV='https://sandbox-api.openpay.mx/v1/'
  API_PROD='https://api.openpay.mx/v1/'

  #by default testing environment is used
  def initialize(merchant_id, private_key, production=false, timeout=90)
    @merchant_id=merchant_id
    @private_key=private_key
    @production=production
    @timeout=timeout
  end

  def create(resource)
    klass=OpenPayResourceFactory::create(resource, @merchant_id, @private_key, @production, @timeout)
    klass.api_hook=self
    klass
  end

  def OpenpayApi::base_url(production)
    if production
      API_PROD
    else
      API_DEV
    end
  end

  def env
    if @production
      :production
    else
      :test
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
openpay-2.0.1 lib/openpay/openpay_api.rb
openpay-2.0.0 lib/openpay/openpay_api.rb
openpay-2.0.0b lib/openpay/openpay_api.rb
openpay-1.0.10 lib/openpay/openpay_api.rb
openpay-1.0.8 lib/openpay/openpay_api.rb
openpay-1.0.7 lib/openpay/openpay_api.rb
openpay-1.0.6 lib/openpay/openpay_api.rb
openpay-1.0.5 lib/openpay/openpay_api.rb