drupalcommerce / commerce-docs

Commerce 2.x documentation
http://docs.drupalcommerce.org
Other
38 stars 207 forks source link

Survive a fault payment method #459

Closed mohamed--abdel-maksoud closed 3 years ago

mohamed--abdel-maksoud commented 3 years ago

As it is now, if a method throws an exception/error, we get a white screen and a fatal error in logs. It is likely other payment methods work, we just need to remove the faulty one.

Here is my patch, I hope it makes it to mainstream.

$ diff PaymentOptionsBuilder.php modules/contrib/commerce/modules/payment/src/PaymentOptionsBuilder.php
63c63,64
<           $options[$payment_method_id] = new PaymentOption([
---
>           try {
>            $options[$payment_method_id] = new PaymentOption([
68c69,72
<           ]);
---
>            ]);
>           } catch(\Throwable $ex) {
>             \Drupal::logger('commerce_payment')->error("Error while adding payment option $payment_method_id: " . $ex);
>           }
lisastreeter commented 3 years ago

Thank you for your suggestion. However, this is an issue for changes to Commerce documentation, not code. If you want to create an issue for Commerce code, you need to do so here: https://www.drupal.org/project/issues/commerce?categories=All

Also, you may be interested in this documentation on creating issues in Drupal: https://www.drupal.org/community/contributor-guide/reference-information/quick-info/creating-or-updating-an-issue-report

And patch and merge request guidelines: https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupal/patch-and-merge-request-guidelines