Problem/Motivation

If a customer deletes a payment method, a fatal error occurs when the canCapturePayment() method is called when accessing back-office functions such as viewing payments on the order or attempting a refund.

Error is:

Error: Call to a member function canCapturePayment() on null in Drupal\commerce_stripe\Plugin\Commerce\PaymentGateway\StripePaymentElement->canCapturePayment() (line 1453 of /var/www/html/docroot/modules/contrib/commerce_stripe/src/Plugin/Commerce/PaymentGateway/StripePaymentElement.php)

(Ignore the line number as this is on 2.0.1)

Steps to reproduce

  1. Check out and complete an order as a customer
  2. Delete the saved payment method used
  3. Log in as an admin and go to /admin/commerce/orders/{order_id}/payments
  4. Error is encountered as above

Proposed resolution

Extend the checking to ensure that, we don't call the canCapturePayment() method on a PaymentType that is NULL

Remaining tasks

Requires review

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

alanhdev created an issue. See original summary.

alanhdev’s picture

Adding a patch

alanhdev’s picture

Status: Active » Needs review

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

anybody’s picture

The approach taken in #3562275: $payment_method_type can be null in StripePaymentElement::canCapturePayment might be cleaner, maybe this one should be closed as duplicate (while crediting @alanhdev)