Class: OpenpayApi
- Inherits:
-
Object
- Object
- OpenpayApi
- 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/'
- API_DEV_CO =
'https://sandbox-api.openpay.co/v1/'
- API_PROD_CO =
'https://api.openpay.co/v1/'
- API_DEV_PE =
'https://sandbox-api.openpay.pe/v1/'
- API_PROD_PE =
'https://api.openpay.pe/v1/'
Class Method Summary collapse
Instance Method Summary collapse
- #create(resource) ⇒ Object
- #env ⇒ Object
-
#initialize(merchant_id, private_key, country = "mx", production = false, timeout = 90) ⇒ OpenpayApi
constructor
by default testing environment is used country can take value ‘mx’ (Mexico) or ‘co’ Colombia.
Constructor Details
#initialize(merchant_id, private_key, country = "mx", production = false, timeout = 90) ⇒ OpenpayApi
by default testing environment is used country can take value ‘mx’ (Mexico) or ‘co’ Colombia
25 26 27 28 29 30 31 |
# File 'lib/openpay/openpay_api.rb', line 25 def initialize(merchant_id, private_key, country = "mx", production = false, timeout = 90) @merchant_id = merchant_id @private_key = private_key @production = production @timeout = timeout @country = country end |
Class Method Details
.base_url(production, country) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/openpay/openpay_api.rb', line 39 def OpenpayApi::base_url(production, country) if country == "mx" if production API_PROD else API_DEV end elsif country == "co" if production API_PROD_CO else API_DEV_CO end elsif country == "pe" if production API_PROD_PE else API_DEV_PE end else LOG.error "Country not found, only mx (México) or co (Colombia)" raise OpenpayException.new "Country not found, only 'mx' (México) or 'co' (Colombia)", false end end |
Instance Method Details
#create(resource) ⇒ Object
33 34 35 36 37 |
# File 'lib/openpay/openpay_api.rb', line 33 def create(resource) klass = OpenPayResourceFactory::create(resource, @merchant_id, @private_key, @production, @timeout, @country) klass.api_hook = self klass end |
#env ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/openpay/openpay_api.rb', line 64 def env if @production :production else :test end end |