checkout / checkout-magento2-plugin

Checkout.com Magento 2 official extension
MIT License
32 stars 33 forks source link

Impossible to create invoice for order placed using Klarna APM in sandbox mode #495

Open Mr0Bread opened 2 years ago

Mr0Bread commented 2 years ago

There is an error when you try to invoice an order and consequently capture it when your order is placed using Klarna APM

After debugging I found out that there is two issues in code that leads to incorrect API request:

  1. Incorrect API endpoint. In documentation is described klarna-external/orders/{payment_id}/captures but in code it uses payments/{payment_id}/capture inside of Checkout\Models\Payments\Capture set on MODEL_REQUEST_URL constant

image

  1. Lack of klarna field in request body. Documentation says that klarna field is required but any field inside of it is optional, so it is enough to add empty object under klarna field

I tried to deliver fixes for that and request worked fine and order was captured correctly. Also tried using Postman and request performed successfully