Describe your bug or feature request.

If a payment method is deleted while a checkout is in progress, the checkout breaks with an exception. Instead, the checkout should revert to a previous step to select a new payment method.

While at first this seems like an incredible edge case (who would delete a payment method in a different tab?), it is more likely for customers who share accounts which is not uncommon unfortunately.

If a bug, provide steps to reproduce it from a clean install.

  1. Install Kickstart.
  2. Add a payment method at /user/1/payment-methods
  3. Start a checkout and get to the last step of the flow
  4. In a new tab, delete the saved payment method
  5. Submit the cart
  6. Enjoy your fresh exception!
The website encountered an unexpected error. Try again later.

InvalidArgumentException: The provided payment has no payment method referenced. in Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\PaymentGatewayBase->assertPaymentMethod() (line 518 of modules/contrib/commerce/modules/payment/src/Plugin/Commerce/PaymentGateway/PaymentGatewayBase.php).

Drupal\commerce_payment_example\Plugin\Commerce\PaymentGateway\Onsite->createPayment() (Line: 148)
Drupal\commerce_payment\Plugin\Commerce\CheckoutPane\PaymentProcess->buildPaneForm() (Line: 567)
Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowWithPanesBase->buildForm()
call_user_func_array() (Line: 528)
Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 279)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 219)
Drupal\Core\Form\FormBuilder->getForm() (Line: 143)
Drupal\commerce_checkout\Controller\CheckoutController->formPage()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 53)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 715)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Issue fork commerce-3544492

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

deviantintegral created an issue. See original summary.

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

jsacksick’s picture

Status: Active » Needs review

I'm now catching generic exceptions from the PaymentProcess pane, and I wrote a test to confirm the issue. I was able to confirm that the test is failing without the changes to the PaymentProcess pane. Thanks for reporting this.

Will merge once the tests are green.

  • jsacksick committed cd008b76 on 3.x
    Issue #3544492 by jsacksick, deviantintegral: Deleting a card in...
jsacksick’s picture

Version: 3.1.0 » 3.x-dev
Status: Needs review » Fixed

This is fixed! Thanks for the report.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

deviantintegral’s picture

Thank you!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.