-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DLocal: Add X-Dlocal-Payment-Source to header #5281
Conversation
@@ -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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this static? If so you may want to use the existing pattern that application_id
offers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update it, I knew we had a field like that but I could remember the name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
application_id
is not a field in option, it's a class attribute. So in the gateway class you can access it by calling application_id
and then it's set on the class (ActiveMerchant::Billing::{{gateway}}.application_id = 'xyz'
).
AuthorizeNet seems to follow a similar pattern to this and uses application_id if you'd like to use it!
92cdf72
to
66cad60
Compare
@@ -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[:application_id] if options[:application_id] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not how application_id gets passed in.
application_id is a class variable so it would be passed in like
headers['X-Dlocal-Payment-Source'] = options[:application_id] if options[:application_id] | |
headers['X-Dlocal-Payment-Source'] = application_id if application_id |
test/unit/gateways/d_local_test.rb
Outdated
@@ -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, application_id: 'ActiveMerchant' })) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
application_id
does not get passed in via options. It is a class variable so you should set it like ActiveMerchant::Billing::DLocalGateway.application_id = 'ActiveMerchant'
66cad60
to
71107d6
Compare
Remote 40 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed
71107d6
to
41b5794
Compare
Remote
40 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed