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.
- Install Kickstart.
- Add a payment method at /user/1/payment-methods
- Start a checkout and get to the last step of the flow
- In a new tab, delete the saved payment method
- Submit the cart
- 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
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 #4
jsacksick commentedI'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.
Comment #6
jsacksick commentedThis is fixed! Thanks for the report.
Comment #8
deviantintegral commentedThank you!