From 41b5794df466e588ef685f6fc7dc36f7ab749c7a Mon Sep 17 00:00:00 2001 From: Alma Malambo Date: Mon, 30 Sep 2024 14:28:04 -0500 Subject: [PATCH] DLocal: Add X-Dlocal-Payment-Source to header Remote 40 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/d_local.rb | 1 + test/remote/gateways/remote_d_local_test.rb | 2 +- test/unit/gateways/d_local_test.rb | 4 +++- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8babce4c02a..7f8dc2c95b6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -59,6 +59,7 @@ * Orbital: Update alternate_ucaf_flow [almalee24] #5282 * Adyen: Remove cryptogram flag [almalee24] #5300 * Cecabank: Include Apple Pay and Google Pay for recurring payments [gasn150] #5295 +* DLocal: Add X-Dlocal-Payment-Source to header [almalee24] #5281 == Version 1.137.0 (August 2, 2024) * Unlock dependency on `rexml` to allow fixing a CVE (#5181). diff --git a/lib/active_merchant/billing/gateways/d_local.rb b/lib/active_merchant/billing/gateways/d_local.rb index 1301bb625d6..8c29d5820ad 100644 --- a/lib/active_merchant/billing/gateways/d_local.rb +++ b/lib/active_merchant/billing/gateways/d_local.rb @@ -299,6 +299,7 @@ def headers(post, options = {}) 'Authorization' => signature(post, timestamp) } headers['X-Idempotency-Key'] = options[:idempotency_key] if options[:idempotency_key] + headers['X-Dlocal-Payment-Source'] = application_id if application_id headers end diff --git a/test/remote/gateways/remote_d_local_test.rb b/test/remote/gateways/remote_d_local_test.rb index 5784a488f90..e0397c93051 100644 --- a/test/remote/gateways/remote_d_local_test.rb +++ b/test/remote/gateways/remote_d_local_test.rb @@ -1,5 +1,5 @@ require 'test_helper' - +ActiveMerchant::Billing::DLocalGateway.application_id = 'ActiveMerchant' class RemoteDLocalTest < Test::Unit::TestCase def setup @gateway = DLocalGateway.new(fixtures(:d_local)) diff --git a/test/unit/gateways/d_local_test.rb b/test/unit/gateways/d_local_test.rb index 6f45a82f9c6..96c7ecd42a4 100644 --- a/test/unit/gateways/d_local_test.rb +++ b/test/unit/gateways/d_local_test.rb @@ -37,10 +37,12 @@ def test_successful_purchase end def test_purchase_with_save + DLocalGateway.application_id = 'ActiveMerchant' stub_comms do @gateway.purchase(@amount, @credit_card, @options.merge(save: true)) - end.check_request do |_endpoint, data, _headers| + end.check_request do |_endpoint, data, headers| assert_equal true, JSON.parse(data)['card']['save'] + assert_equal 'ActiveMerchant', headers['X-Dlocal-Payment-Source'] end.respond_with(successful_purchase_response) end