lib/active_merchant/billing/gateways/optimal_payment.rb in activemerchant-1.29.3 vs lib/active_merchant/billing/gateways/optimal_payment.rb in activemerchant-1.30.0
- old
+ new
@@ -88,11 +88,13 @@
txnRequest = URI.encode(xml)
response = parse(ssl_post(test? ? self.test_url : self.live_url, "txnMode=#{action}&txnRequest=#{txnRequest}"))
Response.new(successful?(response), message_from(response), hash_from_xml(response),
:test => test?,
- :authorization => authorization_from(response)
+ :authorization => authorization_from(response),
+ :avs_result => { :code => avs_result_from(response) },
+ :cvv_result => cvv_result_from(response)
)
end
def successful?(response)
REXML::XPath.first(response, '//decision').text == 'ACCEPTED' rescue false
@@ -106,13 +108,21 @@
end
nil
end
def authorization_from(response)
- REXML::XPath.first(response, '//confirmationNumber').text rescue nil
+ get_text_from_document(response, '//confirmationNumber')
end
+ def avs_result_from(response)
+ get_text_from_document(response, '//avsResponse')
+ end
+
+ def cvv_result_from(response)
+ get_text_from_document(response, '//cvdResponse')
+ end
+
def hash_from_xml(response)
hsh = {}
%w(confirmationNumber authCode
decision code description
actionCode avsResponse cvdResponse
@@ -136,10 +146,15 @@
yield xml
end
xml.target!
end
+ def get_text_from_document(document, node)
+ node = REXML::XPath.first(document, node)
+ node && node.text
+ end
+
def cc_auth_request(money, opts)
xml_document('ccAuthRequestV1') do |xml|
build_merchant_account(xml, @options)
xml.merchantRefNum opts[:order_id]
xml.amount(money/100.0)
@@ -249,10 +264,10 @@
xml.tag! state_tag, CGI.escape(addr[:state])
end
xml.tag! 'country', CGI.escape(addr[:country] ) if addr[:country].present?
xml.tag! 'zip' , CGI.escape(addr[:zip] ) # this one's actually required
xml.tag! 'phone' , CGI.escape(addr[:phone] ) if addr[:phone].present?
- #xml.tag! 'email' , ''
+ xml.tag! 'email', CGI.escape(opts[:email]) if opts[:email]
end
end
def card_type(key)
{ 'visa' => 'VI',