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
- Check out and complete an order as a customer
- Delete the saved payment method used
- Log in as an admin and go to /admin/commerce/orders/{order_id}/payments
- 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
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | deleting_payment_method_breaks_payment_functions-3539260.patch | 820 bytes | alanhdev |
Issue fork commerce_stripe-3539260
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 #2
alanhdev commentedAdding a patch
Comment #4
alanhdev commentedComment #6
anybodyThe 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)