response "CAPTURE_NOT_ALLOWED" leads to WSOD

Created on 6 June 2024, 5 months ago
Updated 5 July 2024, 4 months ago

Problem/Motivation

When checking out an order, we got an WSOD. The watchdog log shows us:

Drupal\commerce_payment\Exception\PaymentGatewayException: [403] Client error: `POST https://api.klarna.com/ordermanagement/v1/orders/ORDER_ID/captures` resulted in a `403 Forbidden` response: {"error_code":"CAPTURE_NOT_ALLOWED","error_messages":["Captured amount is higher than the remaining authorized amount. C (truncated...) in Drupal\commerce_klarna_payments\Plugin\Commerce\PaymentGateway\Klarna->capturePayment() (Zeile 363 in /var/www/html/web/modules/contrib/commerce_klarna_payments/src/Plugin/Commerce/PaymentGateway/Klarna.php).

Proposed resolution

Drupal should show a meaningful error message, that the payment was not possible instead of an WSOD.

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇩🇪Germany onfire84

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @onfire84
  • 🇫🇮Finland tuutti

    Hi, is there an easy way to reproduce this?

    By "checking out an order", do you mean the admin order view or the customer facing checkout?

  • 🇩🇪Germany onfire84

    Hi tuutti, the order is in state fulfillment and the WSOD commes up when clicking on the fullfill order button in the admin order view.

  • 🇫🇮Finland tuutti

    Hi! Have you done manual captures via Klarna Portal or how did you end up having different authorization amount from capture amount?

    I'll look into this, but I don't think there is much we can do because as far as I know, the only way to fail payments in capturePayment() is to throw an exception.

Production build 0.71.5 2024