Class: Epayments::API

Inherits:
Object
  • Object
show all
Defined in:
lib/epayments/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(partner_id, partner_secret) ⇒ API

Returns a new instance of API.



12
13
14
15
16
17
# File 'lib/epayments/api.rb', line 12

def initialize(partner_id, partner_secret)
  @partner_id = partner_id
  @partner_secret = partner_secret
  @access_token = nil
  @token_expires_at = nil
end

Instance Attribute Details

#partner_idObject

Returns the value of attribute partner_id.



10
11
12
# File 'lib/epayments/api.rb', line 10

def partner_id
  @partner_id
end

#partner_secretObject

Returns the value of attribute partner_secret.



10
11
12
# File 'lib/epayments/api.rb', line 10

def partner_secret
  @partner_secret
end

Instance Method Details

#currency_exchange(params) ⇒ Object



49
50
51
52
53
# File 'lib/epayments/api.rb', line 49

def currency_exchange(params)
  check_token

  Request.perform(:post, URI.parse(Urls::CURRENCY_EXCHANGE_URL), headers_for_other, params.to_json)
end

#ewalletObject



43
44
45
46
47
# File 'lib/epayments/api.rb', line 43

def ewallet
  check_token

  Request.perform(:get, URI.parse(Urls::EWALLET_URL), headers_for_other, '')
end

#payment(params) ⇒ Object

requisites is the array of requisites hashes



24
25
26
27
28
# File 'lib/epayments/api.rb', line 24

def payment(params)
  check_token

  Request.perform(:post, URI.parse(Urls::PAYMENTS_URL), headers_for_other, params.to_json)
end

#payment_info(payment_id) ⇒ Object



30
31
32
33
34
# File 'lib/epayments/api.rb', line 30

def payment_info(payment_id)
  check_token

  Request.perform(:get, URI.parse(Urls::PAYMENTS_URL + "/#{payment_id}"), headers_for_other, '')
end

#preflight(params) ⇒ Object

test payment with no actual processing, to view errors if they exists



37
38
39
40
41
# File 'lib/epayments/api.rb', line 37

def preflight(params)
  check_token

  Request.perform(:post, URI.parse(Urls::PREFLIGHT_URL), headers_for_other, params.to_json)
end

#token(params) ⇒ Object



19
20
21
# File 'lib/epayments/api.rb', line 19

def token(params)
  Request.perform(:post, URI.parse(Urls::TOKEN_URL), headers_for_token, params.to_s)
end