mollie / magento2

Mollie Payments for Magento 2
https://www.mollie.com
Other
100 stars 53 forks source link

Error when creating a credit memo for order with payment method Klarna After Pay #611

Closed gjportegies closed 1 year ago

gjportegies commented 1 year ago

Describe the bug When creating a credit memo, for an order with payment method Klarna After Pay, we're getting a hard error with the following message:

[2023-02-06 13:04:03] main.CRITICAL: You can not refund shipping if there is no shipping amount. {"report_id":"<report-id>","exception":"[object] (Magento\\Framework\\Exception\\LocalizedException(code: 0): You can not refund shipping if there is no shipping amount. at /<path-to-webshop>/vendor/magento/module-sales/Model/Order/Creditmemo/Total/Discount.php:62)"} []

Used versions

To Reproduce Steps to reproduce the behavior:

  1. Go to Sales -> Order Grid
  2. Open a completed order with the payment method Klarna After Pay.
  3. Try to create a credit memo.
  4. See error

Expected behavior A credit memo should be created.

Actual behavior An error is thrown.

Screenshots If applicable, add screenshots to help explain your problem.

order-invoices order-creditmemo-error

Additional context Lately we've experienced a lot of issues with Klarna payment methods (both Klarna Pay Later and Klarna Slice It).

Frank-Magmodules commented 1 year ago

Hi @gjportegies , based on our investigation, this issue also appears to be related to the webhook firing faster than before, which results in an update before the order is saved into Magento and seems to created extra order lines as result. 

To address this, we have implemented a solution that involves appending an encrypted order ID to the webhook URL. This will serve as a fallback in situations where the transaction ID is not found in Magento.

In such cases, we will compare the order ID from the metadata in the loaded transaction on the Mollie side and set the transaction ID to the order to process the webhook. This will ensure that the order is properly processed and any necessary actions are taken. This solution is now available within our new [2.22.0](https://github.com/mollie/magento2/releases/tag/v2.22.0) release.

We understand the importance of timely and accurate order processing and appreciate your patience as we work to resolve this issue. Please let us know if you have any further questions or concerns.

We are closing this issue now but please feel free to reopen the issue if this still occurs.