lib/active_merchant/billing/gateways/vanco.rb in activemerchant-1.60.0 vs lib/active_merchant/billing/gateways/vanco.rb in activemerchant-1.61.0
- old
+ new
@@ -20,19 +20,19 @@
super
end
def purchase(money, payment_method, options={})
MultiResponse.run do |r|
- r.process { commit(login_request) }
- r.process { commit(purchase_request(money, payment_method, r.params["response_sessionid"], options)) }
+ r.process { login }
+ r.process { commit(purchase_request(money, payment_method, r.params["response_sessionid"], options), :response_transactionref) }
end
end
def refund(money, authorization, options={})
MultiResponse.run do |r|
- r.process { commit(login_request) }
- r.process { commit(refund_request(money, authorization, r.params["response_sessionid"])) }
+ r.process { login }
+ r.process { commit(refund_request(money, authorization, r.params["response_sessionid"]), :response_creditrequestreceived) }
end
end
def supports_scrubbing?
true
@@ -87,25 +87,25 @@
response[:error_message] = "#{error_str}."
response[:error_codes] = error_codes
end
end
- def commit(request)
+ def commit(request, success_field_name)
response = parse(ssl_post(url, request, headers))
+ succeeded = success_from(response, success_field_name)
- succeeded = success_from(response)
Response.new(
succeeded,
message_from(succeeded, response),
response,
authorization: authorization_from(response),
test: test?
)
end
- def success_from(response)
- !response[:response_errors]
+ def success_from(response, success_field_name)
+ !empty?(response[success_field_name])
end
def message_from(succeeded, response)
return "Success" if succeeded
response[:error_message]
@@ -248,9 +248,13 @@
doc.CustomerIPAddress(options[:ip]) if options[:ip]
end
def add_client_id(doc)
doc.ClientID(@options[:client_id])
+ end
+
+ def login
+ commit(login_request, :response_sessionid)
end
def login_request
build_xml_request do |doc|
doc.Auth do