lib/active_merchant/billing/gateways/eway.rb in activemerchant-1.2.1 vs lib/active_merchant/billing/gateways/eway.rb in activemerchant-1.3.0
- old
+ new
@@ -127,14 +127,10 @@
"93" => "Cannot Complete, Violation Of The Law",
"94" => "Duplicate Transaction",
"96" => "System Error"
}
- attr_reader :url
- attr_reader :response
- attr_reader :options
-
self.money_format = :cents
self.supported_countries = ['AU']
self.supported_cardtypes = [:visa, :master]
self.homepage_url = 'http://www.eway.com.au/'
self.display_name = 'eWAY'
@@ -193,29 +189,22 @@
post[:Option1] = nil
post[:Option2] = nil
post[:Option3] = nil
end
- def commit(money, parameters)
-
+ def commit(money, parameters)
parameters[:TotalAmount] = amount(money)
-
- if result = test_result_from_cc_number(parameters[:CardNumber])
- return result
- end
- data = ssl_post gateway_url(parameters[:CVN], test?), post_data(parameters)
-
- @response = parse(data)
+ response = parse( ssl_post(gateway_url(parameters[:CVN], test?), post_data(parameters)) )
- success = (response[:ewaytrxnstatus] == "True")
- message = message_from(response[:ewaytrxnerror])
- test = /\(Test( CVN)? Gateway\)/ === response[:ewaytrxnerror]
-
- Response.new(success, message, @response,
+ Response.new(success?(response), message_from(response[:ewaytrxnerror]), response,
:authorization => response[:ewayauthcode],
- :test => test
+ :test => /\(Test( CVN)? Gateway\)/ === response[:ewaytrxnerror]
)
+ end
+
+ def success?(response)
+ response[:ewaytrxnstatus] == "True"
end
# Parse eway response xml into a convinient hash
def parse(xml)
# "<?xml version=\"1.0\"?>".