Problem/Motivation

If an API-Request fails, the user faces an uncaught exception (Server Error). There are exception which can be thrown for better error handling in \Drupal\commerce_payment\Exception

Steps to reproduce

  1. To trigger a API error, you can set the your mail address to an invalid mail e.g. test@example.c.
  2. Complete the checkout to the payment.
  3. The Drupal-Server throws an uncaught exception.

Proposed resolution

Use the exception from postfinance SDK to determine the correct commerce_payment Exception.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

coffeemakr created an issue. See original summary.

znerol made their first commit to this issue’s fork.

znerol’s picture

Status: Active » Needs review

Moved the mapException() method to PostFinanceCheckout class and also use it in ::createPayment() to map exceptions thrown by ::createTransactionNoUserInteraction().

znerol’s picture

Tested this with an invalid email and invalid API credentials. In both cases, the user is redirected to the order information page and a generic message is displayed.

The specific exception message is recorded in the logs.

  • znerol committed b3c54d10 on 1.x
    Issue #3374169: Improve Exception Handling
    
znerol’s picture

Status: Needs review » Fixed
znerol’s picture

Thanks @coffeemakr

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.