Deleting a payment method, breaks order payments page

Created on 11 April 2025, 16 days ago

Steps to reproduce , when the option of saving cards for future usage is enabled

  1. Create an order and pay using stripe card element
  2. Go to user/{uid}/payment-methods and delete the payment method that was just created
  3. Clear caches
  4. As administrator go to the order payments page provided by commerce core /admin/commerce/orders/{order_id}/payments

you will get this error
Error: Call to a member function getType() on null in Drupal\commerce_stripe\Plugin\Commerce\PaymentGateway\StripePaymentElement->canCapturePayment()

Traceback of the error points to this line
https://git.drupalcode.org/project/commerce_stripe/-/blob/8.x-1.2/src/Pl...
because it couldn't retrieve the deleted payment method

the function canCapturePayment is called in the context of the order payments page because it is needed to build the operations associated with the payment which includes the capture operation

🐛 Bug report
Status

Active

Version

1.2

Component

Code

Created by

🇪🇬Egypt Ahmed Eldesoky

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024