Class: OpenpayApi

Inherits:
Object
  • Object
show all
Defined in:
lib/openpay/openpay_api.rb

Constant Summary collapse

API_DEV =

API Endpoints

'https://sandbox-api.openpay.mx/v1/'
API_PROD =
'https://api.openpay.mx/v1/'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(merchant_id, private_key, production = false, timeout = 90) ⇒ OpenpayApi

by default testing environment is used



20
21
22
23
24
25
# File 'lib/openpay/openpay_api.rb', line 20

def initialize(merchant_id, private_key, production=false, timeout=90)
  @merchant_id=merchant_id
  @private_key=private_key
  @production=production
  @timeout=timeout
end

Class Method Details

.base_url(production) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/openpay/openpay_api.rb', line 33

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

Instance Method Details

#create(resource) ⇒ Object



27
28
29
30
31
# File 'lib/openpay/openpay_api.rb', line 27

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

#envObject



41
42
43
44
45
46
47
# File 'lib/openpay/openpay_api.rb', line 41

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