Adyen / adyen-magento2

Adyen Payment plugin for Magento2
MIT License
155 stars 211 forks source link

[PW-5682] Adjustment refund is not working for orders paid with Klarna #1123

Closed jonathanribas closed 3 years ago

jonathanribas commented 3 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Place an order with Klarna (klarna_account) and wait for it to be captured
  2. Go to invoice and click on Credit Memo action button
  3. Scroll down to Adjustment Refund, set a value and do not refund any items.
  4. Click on "Refund Online" button
  5. You will have the following error:

Notice: Undefined index: pspReference in /var/www/html/vendor/adyen/module-payment/Gateway/Response/PaymentRefundDetailsHandler.php on line 43

Expected behavior Adjustment refund should work properly with Klarna too.

Magento version 2.3.7

Plugin version 7.0.1

Screenshots

Screenshot 2021-08-03 at 18 01 31

Desktop (please complete the following information):

acampos1916 commented 3 years ago

Hello @jonathanribas. Thanks for the detailed report.

Could you share the lines related to this order, capture and refund from var/log/adyen/info.log? My guess is that the refund response is not including the pspReference for you.

jonathanribas commented 3 years ago

Hi @acampos1916,

Initial request:

[2021-07-29 00:08:25] AdyenLoggerTest.INFO: JSON Request to Adyen:{"merchantAccount":"CaudalieUS","modificationAmount":{"currency":"USD","value":9548},"reference":"82000404328","originalReference":"1856275170911475","additionalData":{"openinvoicedata.line1.currencyCode":"USD","openinvoicedata.line1.description":"Beauty Elixir","openinvoicedata.line1.itemAmount":4900,"openinvoicedata.line1.itemVatAmount":416,"openinvoicedata.line1.itemVatPercentage":850,"openinvoicedata.line1.numberOfItems":1,"openinvoicedata.line1.vatCategory":"None","openinvoicedata.line2.currencyCode":"USD","openinvoicedata.line2.description":"Instant Detox Mask Vinergetic C+","openinvoicedata.line2.itemAmount":3900,"openinvoicedata.line2.itemVatAmount":332,"openinvoicedata.line2.itemVatPercentage":850,"openinvoicedata.line2.numberOfItems":1,"openinvoicedata.line2.vatCategory":"None","openinvoicedata.line3.currencyCode":"USD","openinvoicedata.line3.description":"Collection Sampler","openinvoicedata.line3.itemAmount":0,"openinvoicedata.line3.itemVatAmount":0,"openinvoicedata.line3.itemVatPercentage":850,"openinvoicedata.line3.numberOfItems":1,"openinvoicedata.line3.vatCategory":"None","openinvoicedata.numberOfLines":3},"applicationInfo":{"adyenLibrary":{"name":"adyen-php-api-library","version":"10.1.0"},"adyenPaymentSource":{"version":"7.0.1","name":"adyen-magento2"},"externalPlatform":{"version":"2.3.7","name":"Magento"}}} {"is_exception":false} []

I have the following log when I generate the Credit Memo:

var/log/adyen/info.log:[2021-08-02 16:48:48] AdyenLoggerTest.INFO: JSON Request to Adyen:{"modificationAmount":{"currency":"USD","value":531},"reference":"82000404328","originalReference":"1856275170911475","merchantAccount":"CaudalieUS","additionalData":{"openinvoicedata.numberOfLines":0,"acquirerReference":null},"applicationInfo":{"adyenLibrary":{"name":"adyen-php-api-library","version":"10.1.0"},"adyenPaymentSource":{"version":"7.0.1","name":"adyen-magento2"},"externalPlatform":{"version":"2.3.7","name":"Magento"}}} {"is_exception":false} []

acampos1916 commented 3 years ago

Thanks. Could you also share the response from info.log? Should be right after the 2021-08-02 16:48:48 line @jonathanribas

jonathanribas commented 3 years ago

@acampos1916, here you go sorry: [2021-07-29 00:05:37] AdyenLoggerTest.INFO: JSON Response to Adyen:{"additionalData":{"pspref":"1856275170911475","klarnapayments.session_id":"c7bf8d40-c681-435a-b18c-fc2c08119224","acquirerAccountId":"1258359"},"pspReference":"1856275170911475","resultCode":"Authorised","amount":{"currency":"USD","value":9548},"merchantReference":"82000404328"} {"is_exception":false} []

acampos1916 commented 3 years ago

Thanks for the log lines @jonathanribas. Then this could be related to the line item count while adjusting the refund amount. I've opened an internal ticket to look into it.

jonathanribas commented 3 years ago

Hi @acampos1916, we also have this issue for partial refunds on Credit Cards, it's becoming a serious issue for us with big impact on Customer Service. Do you think you guys could dig into it soon? Thanks!

cyattilakiss commented 3 years ago

Hi @jonathanribas ,

We are going to start working on this ticket in our next sprint which starts next week Monday. We are going to keep you updated.

Best, Attila Adyen

jonathanribas commented 3 years ago

Hi @cyattilakiss, thanks for the update!

Morerice commented 3 years ago

Hi @jonathanribas,

Apologies for our delay. We have been trying to recreate the problem by following the steps to reproduce, on Magento v2.3.7 and Plugin version v7.0.1, but unfortunately we weren't able to reproduce the same outcome.

Attached are two screenshots showing the inputs for the refund screen and the result page. Please note that the error shown in the result page was fixed in https://github.com/Adyen/adyen-magento2/pull/1055.

Could you confirm if the inputs for the refund screen are identical to yours and if not could you highlight what you are doing differently?

Best regards, Jean Adyen

Screen Shot 2021-08-23 at 9 51 59 AM

Screen Shot 2021-08-23 at 9 53 23 AM

jonathanribas commented 3 years ago

Hi @Morerice,

Thanks for the update!

Before opening this issue, we've already applied #1055 patch on our Adyen 7.0.1. We also set quantity to refund as 0 as your print screen and we have this PSP Reference issue.

Best regards, Jonathan.

manuel-EGO commented 3 years ago

This issue is also happening on adyen 7.1.0. Reproduced it for Clearpay.

When 'dumping' the $response, on vendor/adyen/module-payment/Gateway/Response/PaymentRefundDetailsHandler.php Response is an error: Invalid amount specified

Linking issue https://github.com/Adyen/adyen-magento2/issues/982

tnaber commented 3 years ago

Thank you @manuel-EGO for recreating the bug for a different payment method and linking a related issue. I managed to verify the issue (in 7.3.0) when the refund value is set to 0, this created the same error as indicated by @jonathanribas. However, I did not get the 'Invalid amount specified'. Could verify if this is indeed the same use case?

An internal ticket has been created which will be picked up shortly.

manuel-EGO commented 3 years ago

Hi @tnaber the error displayed on the top of the page is the same error @jonathanribas reported, but dumping the $response on module-payment/Gateway/Response/PaymentRefundDetailsHandler.php outputs the error: Invalid amount specified.

tnaber commented 3 years ago

@manuel-EGO so I'm right in assuming that you are trying to do a refund with a refund value of 0? Out of curiosity, why would you want to do that?

manuel-EGO commented 3 years ago

Hi @tnaber you are almost right, I am trying to refund an order, not refunding any items, but adding an adjustment refund. I have a link of a video of the issue but it has some sensitive data, can I send you the video in any other way? (I rather not put the url here)

tnaber commented 3 years ago

You can mail it to !

manuel-EGO commented 3 years ago

ty @tnaber email sent, many thanks

tnaber commented 3 years ago

@manuel-EGO, @jonathanribas #1213 should resolve this issue, feel free to add a review to the PR :) Let me know if this works for you!