lib/active_merchant/billing/gateways/realex.rb in activemerchant-1.2.1 vs lib/active_merchant/billing/gateways/realex.rb in activemerchant-1.3.0
- old
+ new
@@ -40,14 +40,10 @@
SUCCESS, DECLINED = "Successful", "Declined"
BANK_ERROR = REALEX_ERROR = "Gateway is in maintenance. Please try again later."
ERROR = CLIENT_DEACTIVATED = "Gateway Error"
- attr_reader :url
- attr_reader :response
- attr_reader :options
-
def initialize(options = {})
requires!(options, :login, :password)
@options = options
super
end
@@ -58,25 +54,17 @@
request = build_purchase_or_authorization_request(:purchase, money, credit_card, options)
commit(request)
end
private
- def commit(request)
- if result = test_result_from_cc_number(parse_credit_card_number(request))
- return result
- end
-
- data = ssl_post(URL, request)
-
- @response = parse(data)
+ def commit(request)
+ response = parse(ssl_post(URL, request))
- success = @response[:result] == "00"
- test = response[:message] =~ /\[ test system \]/
-
- Response.new(success, message_from(@response), @response,
- :test => test,
- :authorization => @response[:authcode]
+ Response.new(response[:result] == "00", message_from(response), response,
+ :test => response[:message] =~ /\[ test system \]/,
+ :authorization => response[:authcode],
+ :cvv_result => response[:cvnresult]
)
end
def parse(xml)
response = {}
@@ -135,10 +123,10 @@
xml.tag! 'comment', options[:description], 'id' => 1
xml.tag! 'comment', 'id' => 2
end
billing_address = options[:billing_address] || options[:address] || {}
- shipping_address = options[:shipping_address] || billing_address
+ shipping_address = options[:shipping_address] || {}
xml.tag! 'tssinfo' do
xml.tag! 'address', 'type' => 'billing' do
xml.tag! 'code', billing_address[:zip]
xml.tag! 'country', billing_address[:country]
\ No newline at end of file