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
- To trigger a API error, you can set the your mail address to an invalid mail e.g.
test@example.c. - Complete the checkout to the payment.
- The Drupal-Server throws an uncaught exception.
Proposed resolution
Use the exception from postfinance SDK to determine the correct commerce_payment Exception.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | Screenshot 2023-08-08 at 15-57-52 Order information Drupal.png | 59.06 KB | znerol |
Issue fork commerce_postfinance_checkout-3374169
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
Comment #4
znerol commentedMoved the
mapException()method toPostFinanceCheckoutclass and also use it in::createPayment()to map exceptions thrown by::createTransactionNoUserInteraction().Comment #5
znerol commentedTested 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.
Comment #7
znerol commentedComment #8
znerol commentedThanks @coffeemakr