-
Notifications
You must be signed in to change notification settings - Fork 196
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
#GCC currency - saved amount on create adyen order #1385
Closed
Closed
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2b438c8
#GCC currency order authorization fix
61ea3d5
Merge branch 'develop' into gcc-currency-fix
tnaber 423ca52
Merge branch 'develop' into gcc-currency-fix
tnaber 0e867d7
Update AdyenOrderPayment.php
37b4da2
Update AdyenOrderPayment.php
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Would it be better to use
$notification->getAmountCurrency()
? Maybe that way the entity is created inadyen_order_payment
with the matching currency everytime.I see that @Morerice introduced this, do you know if we can make that change?
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.
Hi @acampos1916 ,
thanks for replying back.
Not sure if the question is directed to me but I took the liberty to respond:
Looking at the plugin code, I believe both options will work as expected.
However, I would stick to the Magento default $order->getOrderCurrencyCode() as that's following the formatting that Magento needs always.
If you use $notification->getAmountCurrency() and in the future, you decide to change the code how webhooks pass the currency code or decide not to pass it at all, it will break the function again.
In the end, it's a matter of preference :).
I applied my solution on our live website and so far we didn't experience any bugs or problems after applying the patch.
Best
Dejena
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.
Thanks @dejankar. If I get it right there are multiple scenarios to cover:
Base currency A, Display currency B (getOrderCurrencyCode != getAmountCurrency)
Base currency B, Display currency A (getOrderCurrencyCode != getAmountCurrency)
Base currency A, Display currency A (getOrderCurrencyCode == getAmountCurrency)
Base currency B, Display currency B (getOrderCurrencyCode == getAmountCurrency)
If the charged currency config included in the plugin is set to Display the payment will be processed with the Display currency, but the getOrderCurrencyCode would return the Base currency. I think it is safer to use
$notification->getAmountCurrency()
because of that, what do you think?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.
Hi Angel,
Extended solution committed that checks how the Adyen plugin is set.
If it's set to use display currency then we have only one scenario actually.
OrderCurrencyCode will always return the display currency code and will be matching Magento values.
If plugin is set to use base currency code , we can always return the base currency code with :
$order->getBaseCurrencyCode();
So the check I add will solve the concerns you have from the Magento side.
However, what you mentioned is not wrong and $notification->getAmountCurrency() can be used too if as mentioned you are not a plugin to change the data on your end and how data is passed from the webhooks back to Magento.
Great conversation btw 👍
Best Regards,
Dejan
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.
Hey @dejankar, of course! Thanks for helping us figure this out.
I'll test your patience a bit more 😄 since the notification is being processed after the payment has been completed there's a small chance that the plugin's config for charged currency has been modified between the order placement and the webhook being received, that would set the wrong currency with your updated approach.
I would indeed suggest to use the
$notification->getAmountCurrency()
, to my knowledge there are no plans at all to change the format from the Adyen side and hasn't been changed for a while. It is safe to use.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.
Hi @acampos1916 ,
Sure it's my pleasure.
Yeah, I agree there is a small chance for the mentioned use case but in such config, the whole process might be wrong.
There might be a problem if let's say the order was placed in base currency and then someone changes the charged currency setting and then webhooks returns the values with a different currency.
That might interfere with Magento's internal logic for let's say if someone invoice later and want to capture the amount in charged currency. Than anyway the order needs to be fixed from the M2 side.
But all in all, I'm really fine with the proposal from your side: $notification->getAmountCurrency(), especially as you mentioned that format won't be changed in the future, and the field will always be called like this.
I will leave the decision for you and your team!
It's been a pleasure chatting with all of you guys :)
Looking forward to the solution and all the great stuff that this plugin offer.
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.
@dejankar good point! We do have a mechanism in place so that orders are captured and refunded in the currency with which it was placed, see the docblock for this helper function.
I'm doing a suggestion with the use of the notification currency. Thank you!