lib/active_merchant/billing/gateways/adyen.rb in activemerchant-1.88.0 vs lib/active_merchant/billing/gateways/adyen.rb in activemerchant-1.89.0

- old
+ new

@@ -31,13 +31,17 @@ @username, @password, @merchant_account = options.values_at(:username, :password, :merchant_account) super end def purchase(money, payment, options={}) - MultiResponse.run do |r| - r.process { authorize(money, payment, options) } - r.process { capture(money, r.authorization, options) } + if options[:execute_threed] + authorize(money, payment, options) + else + MultiResponse.run do |r| + r.process { authorize(money, payment, options) } + r.process { capture(money, r.authorization, options) } + end end end def authorize(money, payment, options={}) requires!(options, :order_id) @@ -46,10 +50,11 @@ add_payment(post, payment) add_extra_data(post, payment, options) add_shopper_interaction(post, payment, options) add_address(post, options) add_installments(post, options) if options[:installments] + add_3ds(post, options) if options[:execute_threed] commit('authorise', post) end def capture(money, authorization, options={}) post = init_post(options) @@ -256,10 +261,15 @@ post[:installments] = { value: options[:installments] } end + def add_3ds(post, options) + post[:additionalData] = { executeThreeD: 'true' } + post[:browserInfo] = { userAgent: options[:user_agent], acceptHeader: options[:accept_header] } + end + def parse(body) return {} if body.blank? JSON.parse(body) end @@ -313,10 +323,10 @@ } end def success_from(action, response) case action.to_s - when 'authorise' + when 'authorise', 'authorise3d' ['Authorised', 'Received', 'RedirectShopper'].include?(response['resultCode']) when 'capture', 'refund', 'cancel' response['response'] == "[#{action}-received]" else false