Class: Paygate::Profile

Inherits:
Object
  • Object
show all
Defined in:
lib/paygate/profile.rb

Constant Summary collapse

PURCHASE_URL =
'https://service.paygate.net/INTL/pgtlProcess3.jsp'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(profile_no) ⇒ Profile

Returns a new instance of Profile.



13
14
15
# File 'lib/paygate/profile.rb', line 13

def initialize(profile_no)
  @profile_no = profile_no
end

Instance Attribute Details

#memberObject

Returns the value of attribute member.



11
12
13
# File 'lib/paygate/profile.rb', line 11

def member
  @member
end

#profile_noObject (readonly)

Returns the value of attribute profile_no.



10
11
12
# File 'lib/paygate/profile.rb', line 10

def profile_no
  @profile_no
end

Instance Method Details

#purchase(currency, amount) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/paygate/profile.rb', line 17

def purchase(currency, amount)
  # Prepare params
  params = { profile_no: profile_no,
             mid: member.mid,
             goodcurrency: currency,
             unitprice: amount }
  params.compact!

  # Make request
  uri = URI(PURCHASE_URL)
  uri.query = ::URI.encode_www_form(params)
  response = ::Net::HTTP.get_response(uri)

  Response.build_from_net_http_response(:profile_pay, response)
end