paynl / magento2-plugin

The Pay. plugin for Magento 2
https://www.pay.nl
27 stars 31 forks source link

Exception in ShipmentSaveAfter observer with Klarna Payments #185

Closed marcoboom closed 11 months ago

marcoboom commented 11 months ago

@woutse There is an issue with the ShipmentSaveAfter observer when auto capturing is enabled for Klarna payments.

The pay order id which is saved as last_trans_id in the sales_order_payments table, contains a '-capture' suffix. So when the ShipmentSaveAfter is called, the Pay API throws an exception:

[2023-09-19T10:45:14.294357+00:00] main.CRITICAL: Paynl\Error\Api:  - Transaction not found in /home/releases/a9becff9/vendor/paynl/sdk/src/Api/Api.php:155
Stack trace:
#0 /home/releases/a9becff9/vendor/paynl/sdk/src/Api/Api.php(80): Paynl\Api\Api->processResult()
#1 /home/releases/a9becff9/vendor/paynl/sdk/src/Api/Transaction/Info.php(51): Paynl\Api\Api->doRequest()
#2 /home/releases/a9becff9/vendor/paynl/sdk/src/Transaction.php(290): Paynl\Api\Transaction\Info->doRequest()
#3 /home/releases/a9becff9/vendor/paynl/magento2-plugin/Observer/ShipmentSaveAfter.php(110): Paynl\Transaction::get()

I solved this by adding the same solution as in https://github.com/paynl/magento2-plugin/blob/master/Model/Paymentmethod/PaymentMethod.php#L428

escruickshank commented 11 months ago

Hi @marcoboom, thank you for flagging this. We will look into this.

escruickshank commented 11 months ago

Hi @marcoboom, thanks again for flagging this. We have fixed this in version 3.8.2 which is now live.