Sha256: 3cc0bf8e2ca9916619690b27dbb6c875c65f34b28d3a1aabeb171b1865df01a7

Contents?: true

Size: 1008 Bytes

Versions: 1

Compression:

Stored size: 1008 Bytes

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)
    @merchant_id=merchant_id
    @private_key=private_key
    @production=production
  end

  def create(resource)
    klass=OpenPayResourceFactory::create(resource, @merchant_id, @private_key, @production)
    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

1 entries across 1 versions & 1 rubygems

Version Path
openpay-1.0.4 lib/openpay/openpay_api.rb