Class: Pay2go::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/pay2go/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amt, options = {}) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
# File 'lib/pay2go/client.rb', line 9

def initialize amt, options = {}
  @amt = amt
  @item_desc = options[:item_desc] || ""
  @email = options[:email] || ""
  @mode = options[:mode] || "test"
  @secret = PAY2GO_CONFIG[@mode]
end

Instance Attribute Details

#secretObject (readonly)

Returns the value of attribute secret.



7
8
9
# File 'lib/pay2go/client.rb', line 7

def secret
  @secret
end

Instance Method Details

#api_hostObject



17
18
19
# File 'lib/pay2go/client.rb', line 17

def api_host
  secret["host"]
end

#request(path = "", params = {}) ⇒ Object



21
22
23
24
# File 'lib/pay2go/client.rb', line 21

def request path="", params = {}
  api_url = URI.join(api_host, path)
  Net::HTTP.post_form api_url, payment_params
end

#responseObject



26
27
28
29
# File 'lib/pay2go/client.rb', line 26

def response
  res = request
  return res.body
end