lib/active_merchant/billing/gateways/epay.rb in activemerchant-1.97.0 vs lib/active_merchant/billing/gateways/epay.rb in activemerchant-1.98.0

- old
+ new

@@ -61,10 +61,11 @@ add_amount(post, money, options) add_invoice(post, options) add_creditcard_or_reference(post, credit_card_or_reference) add_instant_capture(post, false) + add_3ds_auth(post, options) commit(:authorize, post) end def purchase(money, credit_card_or_reference, options = {}) @@ -72,10 +73,11 @@ add_amount(post, money, options) add_creditcard_or_reference(post, credit_card_or_reference) add_invoice(post, options) add_instant_capture(post, true) + add_3ds_auth(post, options) commit(:authorize, post) end def capture(money, authorization, options = {}) @@ -156,10 +158,20 @@ def add_instant_capture(post, option) post[:instantcapture] = option ? 1 : 0 end + def add_3ds_auth(post, options) + if options[:three_d_secure] + post[:eci] = options.dig(:three_d_secure, :eci) + post[:xid] = options.dig(:three_d_secure, :xid) + post[:cavv] = options.dig(:three_d_secure, :cavv) + post[:threeds_version] = options.dig(:three_d_secure, :version) + post[:ds_transaction_id] = options.dig(:three_d_secure, :ds_transaction_id) + end + end + def commit(action, params) response = send("do_#{action}", params) if action == :authorize Response.new response['accept'].to_i == 1, @@ -191,11 +203,10 @@ def do_authorize(params) headers = {} headers['Referer'] = (options[:password] || 'activemerchant.org') response = raw_ssl_request(:post, live_url + 'auth/default.aspx', authorize_post_data(params), headers) - # Authorize gives the response back by redirecting with the values in # the URL query if location = response['Location'] query = CGI::parse(URI.parse(location.gsub(' ', '%20').gsub('<', '%3C').gsub('>', '%3E')).query) else @@ -266,10 +277,10 @@ xml.target! end def authorize_post_data(params = {}) params[:language] = '2' - params[:cms] = 'activemerchant' + params[:cms] = 'activemerchant_3ds' params[:accepturl] = live_url + 'auth/default.aspx?accept=1' params[:declineurl] = live_url + 'auth/default.aspx?decline=1' params[:merchantnumber] = @options[:login] params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')