Adyen / adyen-magento2

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

[PW-7619] - Unable to place order using Klarna Pay Over Time payment method when apply a promo code #1872

Closed shafeekb1 closed 3 months ago

shafeekb1 commented 1 year ago

Describe the bug Cannot place the Order using the 'Pay Over Time with Klarna' payment method when we apply a discount promo code to the Order.

To Reproduce Steps to reproduce the behavior:

  1. Add product to the cart, go to the cart page
  2. Apply a discount promo code (eg: 10% discount)
  3. Go to the checkout page and place the order with the 'Pay Over Time with Klarna' payment method

Expected behavior Redirecting to the klarna portal to complete the payment

Magento version 2.4.3-p3

Plugin version 8.8.0

Screenshots A2B6CCC4-0F0D-48F1-A9FC-919861711E09_1_201_a

Additional context Shows the below error on the Adyen portal _BAD_VALUE : order_lines[0].total_taxamount

Morerice commented 1 year ago

Hi @shafeekb,

Thanks for opening this issue. I've created an internal ticket to investigate this problem. We will keep you updated if we have any other questions related to it.

Regards, Jean Adyen

candemiralp commented 1 year ago

Hello @shafeekb1,

Thank you for your patience while we were investigating the issue. We were not able to reproduce the issue on our test environments and the plugin calculated the correct amounts for every test case, however we found some points that needs to be checked on your end.

We also examined carefully your Zendesk ticket, example request according to the PSP references and your patch suggestion. Unfortunately, applying this patch is not possible (I will explain after the explanation of the possible issue). With the given PSP reference we checked the request body and realised that amountIncludingTax in the lineItems array shows 1 USD less than the expected value according to the calculation with the given tax percentage 6.63%. For that one, I would like to suggest to check row_total_incl_tax column for the given order on the sales_order_item table for if those values are consistent or not. Since, that value is not correct, the given patch will calculate a wrong tax percentage, however values will be consistent in the row even though the line itself is not correct. Second suggestion is checking the actual tax percentage and cart rules according to the given example.

I saw you are using Magento 2.4.3-p3. After a quick search in the release notes of Magento 2, we figured out that there are couple of fixed issues that could be related to your issue especially in cart rules, discounts and tax applications. You can find the Magento 2.4.4 release notes from here, those may contain a fix for your issue.

If you can provide information after those checks on your end, we can conclude this ticket afterwards.

Best Regards, Can

shafeekb1 commented 1 year ago

Hi @candemiralp,

Thank you for your response. Did you configure the taxes before testing the issue on your test instances? this issue won't occur if the tax amount is zero.

If possible, can you please share the URL of your test environment?

Thanks & Regards, Shafeek B

candemiralp commented 1 year ago

Hello @shafeekb1,

Thank you for your response. Yes, we configured the tax with the same percentage as in your request. Discount was applied to the cart as 10%. If you have any extra information to help us to replicate the issue, please feel free to share the details.

Unfortunately it is not possible, since we are using our internal servers as test endpoints.

Best Regards, Can

shafeekb1 commented 1 year ago

Hi @candemiralp,

Can you share some screenshots of the subtotals on the checkout page?

During my investigation, I found that you are hardcoded zero in the getOpenInvoiceData() method on the CheckoutDataBuilder class (please check https://github.com/Adyen/adyen-magento2/blob/develop/Gateway/Request/CheckoutDataBuilder.php#L330). According to your documentation(https://docs.adyen.com/payment-methods/klarna/invoice-lines#discounted-amounts), there should be negative values instead of zero in case of a discount.

Thanks & Regards, Shafeek B

candemiralp commented 1 year ago

Hi @shafeekb1,

I will share the lineItem body below instead of the screenshots but I don't think they could be related to this issue. Because that specific issue occurs in the line item (row).

Did you check the possible reasons of the amountIncludingTax shows 1 USD less than the actual value in your request?

This is my request for the same amounts.

{
    "id": "51",
    "amountExcludingTax": 14999,
    "amountIncludingTax": 15994,
    "taxAmount": 994,
    "description": "Joust Duffle Bag",
    "quantity": 2,
    "taxPercentage": 663,
    "productUrl": "https:\/\/192.168.58.20\/index.php\/joust-duffle-bag.html",
    "imageUrl": "https:\/\/192.168.58.20\/media\/catalog\/product\/cache\/a6ecd04e088fd93e78093fb2512080f5\/m\/b\/mb01-blue-0.jpg"
}

Best Regards, Can

shafeekb1 commented 1 year ago

Hi @candemiralp,

I have already checked that, it is not 1 USD, it is just only 1 cent (the actual amount is 149.99 USD, not 14999), you can verify that if you check the order on the Adyen backend. It is happening because klarna considered the tax percentage is 663 instead of 6625 (the actual tax percentage is 6.625, I think klarna is using only 3 digits for the tax percentage), and klarna will tolerate the difference of 1 cent (https://docs.klarna.com/klarna-payments/in-depth-knowledge/tax-handling/). I am pretty sure this is not the reason for the issue (it would be the same behavior even if we didn't apply the discount).

Did you check the findings mentioned in my previous comment? can you please share the screenshot of the subtotals on the payment page?

Thanks & Regards, Shafeek B

candemiralp commented 1 year ago

Hi @shafeekb1,

Thank you for your response. My point was checking the amountIncludingTax in the line items in your end. You are right about the 1 cent difference and it is known, I am ignoring the 1 cent difference. However, when I checked your request from your PSP reference **************LNK82, I saw amountIncludingTax is 15894 whereas mine was 15994 for the same amounts (that makes 100 cents).

Could you please confirm this one also?

Best Regards, Can

shafeekb1 commented 1 year ago

Hi @candemiralp,

The PSP number **LNK82 belongs to a credit card order and we do not have any issues with credit card orders. Also, the klarna calculations are not applicable here since it is a credit card payment method.

Can you please answer my below questions?

  1. Can you share the screenshots of subtotals from the Admin sales order view page of the successful klarna (US pay over time) order with a discount from your test instance?

  2. Did you configure the tax when you tried to reproduce the issue? (we are using vertex tax).

  3. Are you sure this is correct?

Thanks & Regards, Shafeek B

candemiralp commented 1 year ago

Hello @shafeekb1,

Thank you for your response. I can confirm we are able to place an order with Klarna in US with the tax configured and discount applied to the cart.

Since the issue is not reproducible on our side and there is no error observed on the calculation of the line item amounts on the plugin, discussing this issue on the Zendesk would be more appropriate. As a follow-up to your previous Zendesk tickets, one of our support engineers will reach out to you to arrange a call. So that, we can discuss the details on the call.

Best Regards, Can

candemiralp commented 3 months ago

Closing this issue due to inactivity and lots of changes on open invoice payment methods. Please update to the latest version if you see any issues related to open invoice payment methods.

Best Regards, Can