Skip to content
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

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

almalee24
Copy link

Remote
40 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed

@almalee24 almalee24 requested a review from a team September 30, 2024 19:29
@@ -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]
Copy link
Contributor

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

Copy link
Author

@almalee24 almalee24 Sep 30, 2024

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

Copy link
Contributor

@aenand aenand Sep 30, 2024

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!

@almalee24 almalee24 requested review from aenand and a team October 4, 2024 18:22
@@ -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]
Copy link
Contributor

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

Suggested change
headers['X-Dlocal-Payment-Source'] = options[:application_id] if options[:application_id]
headers['X-Dlocal-Payment-Source'] = application_id if application_id

@@ -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' }))
Copy link
Contributor

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'

Remote
40 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
@almalee24 almalee24 merged commit 41b5794 into master Oct 16, 2024
5 checks passed
@almalee24 almalee24 deleted the dlocal_payment_source_header branch October 16, 2024 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants