Class: PayXML::PayXML

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paygate_id, paygate_password) ⇒ PayXML

Returns a new instance of PayXML.



14
15
16
17
# File 'lib/payxml.rb', line 14

def initialize(paygate_id, paygate_password)
  @paygate_id = paygate_id
  @paygate_password = paygate_password
end

Class Method Details

.checksum(values = []) ⇒ Object



39
40
41
42
43
# File 'lib/payxml.rb', line 39

def self.checksum(values=[])
  md5 = Digest::MD5.new
  md5 << values.map { |i| i.to_s }.join("|")
  md5.hexdigest
end

Instance Method Details

#purchase(options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/payxml.rb', line 19

def purchase(options = {})
  authtx = Auth::Request.new(@paygate_id, @paygate_password)
  authtx.customer_reference = options[:customer_reference]
  authtx.customer_name = options[:customer_name]
  authtx.credit_card_number = options[:credit_card_number]
  authtx.expiry_date = options[:expiry_date]
  authtx.currency = options[:currency]
  authtx.amount = options[:amount]
  authtx.cvv = options[:cvv]
  authtx.customer_ip_address = options[:customer_ip_address]
  authtx.notify_callback_url = options[:notify_callback_url]
  authtx.response_url = options[:response_url]

  response = post_request_body(authtx.xml_string)
  response_object = Auth::Response.allocate
  response_object.parse(response.body)

  response_object
end