Skip to content

Commit

Permalink
DLocal: Add X-Dlocal-Payment-Source to header
Browse files Browse the repository at this point in the history
Remote
40 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
  • Loading branch information
Alma Malambo committed Sep 30, 2024
1 parent 8575398 commit 92cdf72
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/active_merchant/billing/gateways/d_local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,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'] = options[:payment_source] if options[:payment_source]
headers
end

Expand Down
3 changes: 2 additions & 1 deletion test/remote/gateways/remote_d_local_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def setup
@options = {
billing_address: address(country: 'Brazil'),
document: '71575743221',
currency: 'BRL'
currency: 'BRL',
payment_source: 'ActiveMerchant'
}
@options_colombia = {
billing_address: address(country: 'Colombia'),
Expand Down
5 changes: 3 additions & 2 deletions test/unit/gateways/d_local_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ def test_successful_purchase

def test_purchase_with_save
stub_comms do
@gateway.purchase(@amount, @credit_card, @options.merge(save: true))
end.check_request do |_endpoint, data, _headers|
@gateway.purchase(@amount, @credit_card, @options.merge({ save: true, payment_source: 'ActiveMerchant' }))
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

Expand Down

0 comments on commit 92cdf72

Please sign in to comment.