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

- old
+ new

@@ -35,10 +35,12 @@ post = payment_request(money, options) post[:amount] = amount_hash(money, options[:currency]) post[:card] = credit_card_hash(creditcard) post[:billingAddress] = billing_address_hash(options) if options[:billing_address] post[:deliveryAddress] = shipping_address_hash(options) if options[:shipping_address] + post[:shopperStatement] = options[:shopper_statement] if options[:shopper_statement] + add_3ds(post, options) commit('authorise', post) end def capture(money, authorization, options = {}) @@ -348,33 +350,35 @@ hash.keep_if { |_, v| v } end def add_3ds(post, options) 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] - } - end + device_channel = three_ds_2_options[:channel] + if device_channel == 'app' + post[:threeDS2RequestData] = { deviceChannel: device_channel } + else + add_browser_info(three_ds_2_options[:browser_info], post) + post[:threeDS2RequestData] = { deviceChannel: device_channel, notificationURL: three_ds_2_options[:notification_url] } 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 add_browser_info(browser_info, post) + return unless 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] + } end end end end