lib/active_merchant/billing/gateways/adyen.rb in activemerchant-1.93.0 vs lib/active_merchant/billing/gateways/adyen.rb in activemerchant-1.94.0

- old
+ new

@@ -78,10 +78,11 @@ def adjust(money, authorization, options={}) post = init_post(options) add_invoice_for_modification(post, money, options) add_reference(post, authorization, options) + add_extra_data(post, nil, options) commit('adjustAuthorisation', post, options) end def store(credit_card, options={}) requires!(options, :order_id) @@ -172,10 +173,13 @@ post[:merchantOrderReference] = options[:merchant_order_reference] if options[:merchant_order_reference] post[:additionalData] ||= {} post[:additionalData][:overwriteBrand] = normalize(options[:overwrite_brand]) if options[:overwrite_brand] post[:additionalData][:customRoutingFlag] = options[:custom_routing_flag] if options[:custom_routing_flag] post[:additionalData]['paymentdatasource.type'] = NETWORK_TOKENIZATION_CARD_SOURCE[payment.source.to_s] if payment.is_a?(NetworkTokenizationCreditCard) + post[:additionalData][:authorisationType] = options[:authorisation_type] if options[:authorisation_type] + post[:additionalData][:adjustAuthorisationData] = options[:adjust_authorisation_data] if options[:adjust_authorisation_data] + post[:additionalData][:RequestedTestAcquirerResponseCode] = options[:requested_test_acquirer_response_code] if options[:requested_test_acquirer_response_code] && test? post[:deviceFingerprint] = options[:device_fingerprint] if options[:device_fingerprint] add_risk_data(post, options) end def add_risk_data(post, options) @@ -212,17 +216,17 @@ end def add_address(post, options) return unless post[:card]&.kind_of?(Hash) if (address = options[:billing_address] || options[:address]) && address[:country] - post[:card][:billingAddress] = {} - post[:card][:billingAddress][:street] = address[:address1] || 'N/A' - post[:card][:billingAddress][:houseNumberOrName] = address[:address2] || 'N/A' - post[:card][:billingAddress][:postalCode] = address[:zip] if address[:zip] - post[:card][:billingAddress][:city] = address[:city] || 'N/A' - post[:card][:billingAddress][:stateOrProvince] = address[:state] || 'N/A' - post[:card][:billingAddress][:country] = address[:country] if address[:country] + post[:billingAddress] = {} + post[:billingAddress][:street] = address[:address1] || 'N/A' + post[:billingAddress][:houseNumberOrName] = address[:address2] || 'N/A' + post[:billingAddress][:postalCode] = address[:zip] if address[:zip] + post[:billingAddress][:city] = address[:city] || 'N/A' + post[:billingAddress][:stateOrProvince] = address[:state] || 'N/A' + post[:billingAddress][:country] = address[:country] if address[:country] end end def add_invoice(post, money, options) amount = { @@ -306,13 +310,35 @@ value: options[:installments] } end def add_3ds(post, options) - return unless options[:execute_threed] || options[:threed_dynamic] - post[:browserInfo] = { userAgent: options[:user_agent], acceptHeader: options[:accept_header] } - post[:additionalData] = { executeThreeD: 'true' } if options[:execute_threed] + if three_ds_2_options = options[:three_ds_2] + if browser_info = three_ds_2_options[:browser_info] + post[:browserInfo] = { + acceptHeader: browser_info[:accept_header], + colorDepth: browser_info[:depth], + javaEnabled: browser_info[:java], + language: browser_info[:language], + screenHeight: browser_info[:height], + screenWidth: browser_info[:width], + timeZoneOffset: browser_info[:timezone], + userAgent: browser_info[:user_agent] + } + + if device_channel = three_ds_2_options[:channel] + post[:threeDS2RequestData] = { + deviceChannel: device_channel, + notificationURL: three_ds_2_options[:notification_url] || 'https://example.com/notification' + } + end + end + else + return unless options[:execute_threed] || options[:threed_dynamic] + post[:browserInfo] = { userAgent: options[:user_agent], acceptHeader: options[:accept_header] } + post[:additionalData] = { executeThreeD: 'true' } if options[:execute_threed] + end end def parse(body) return {} if body.blank? JSON.parse(body) @@ -372,11 +398,13 @@ def success_from(action, response) case action.to_s when 'authorise', 'authorise3d' ['Authorised', 'Received', 'RedirectShopper'].include?(response['resultCode']) - when 'capture', 'refund', 'cancel', 'adjustAuthorisation' + when 'capture', 'refund', 'cancel' response['response'] == "[#{action}-received]" + when 'adjustAuthorisation' + response['response'] == 'Authorised' || response['response'] == '[adjustAuthorisation-received]' else false end end