Skip to content

Commit

Permalink
Adyen: Pass arbitrary riskData fields
Browse files Browse the repository at this point in the history
Closes #3089

Remote:
38 tests, 99 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Unit:
26 tests, 127 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
  • Loading branch information
curiousepic committed Jan 2, 2019
1 parent 3088619 commit 207c3df
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
== HEAD
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
* Braintree: Update gem to latest version [curiousepic] #3091
* Adyen: Pass arbitrary riskData fields [curiousepic] #3089

== Version 1.89.0 (December 17, 2018)
* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
Expand Down
8 changes: 8 additions & 0 deletions lib/active_merchant/billing/gateways/adyen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ def add_extra_data(post, payment, options)
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)
add_risk_data(post, options)
end

def add_risk_data(post, options)
risk_data = {}
risk_data.merge!(options[:risk_data]) if options[:risk_data]

post[:additionalData][:riskData] = risk_data unless risk_data.empty?
end

def add_shopper_interaction(post, payment, options={})
Expand Down
15 changes: 15 additions & 0 deletions test/remote/gateways/remote_adyen_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ def test_successful_purchase_with_more_options
assert_equal '[capture-received]', response.message
end

def test_successful_purchase_with_risk_data
options = @options.merge(
risk_data:
{
'operatingSystem' => 'HAL9000',
'destinationLatitude' => '77.641423',
'destinationLongitude' => '12.9503376'
}
)

response = @gateway.purchase(@amount, @credit_card, options)
assert_success response
assert_equal '[capture-received]', response.message
end

def test_successful_purchase_with_apple_pay
response = @gateway.purchase(@amount, @apple_pay_card, @options)
assert_success response
Expand Down
8 changes: 8 additions & 0 deletions test/unit/gateways/adyen_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ def test_custom_routing_sent
end.respond_with(successful_authorize_response)
end

def test_risk_data_sent
stub_comms do
@gateway.authorize(@amount, @credit_card, @options.merge({risk_data: {'operatingSystem' => 'HAL9000'}}))
end.check_request do |endpoint, data, headers|
assert_equal 'HAL9000', JSON.parse(data)['additionalData']['riskData']['operatingSystem']
end.respond_with(successful_authorize_response)
end

def test_failed_purchase
@gateway.expects(:ssl_post).returns(failed_purchase_response)

Expand Down

0 comments on commit 207c3df

Please sign in to comment.