diff --git a/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowWithPanesBase.php b/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowWithPanesBase.php index 5ef34b4b..1cc63bd6 100644 --- a/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowWithPanesBase.php +++ b/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowWithPanesBase.php @@ -124,6 +124,15 @@ abstract class CheckoutFlowWithPanesBase extends CheckoutFlowBase implements Che return $panes[$pane_id] ?? NULL; } + + /** + * {@inheritdoc} + */ + public function getPaymentPaneId() { + // Return default payment pane id. + return 'payment_information'; + } + /** * {@inheritdoc} */ diff --git a/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowWithPanesInterface.php b/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowWithPanesInterface.php index 2d783ce5..a507d057 100644 --- a/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowWithPanesInterface.php +++ b/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowWithPanesInterface.php @@ -37,4 +37,12 @@ interface CheckoutFlowWithPanesInterface extends CheckoutFlowInterface { */ public function getPane($pane_id); + /** + * Get the payment pane id for the current checkout flow. + * + * @return string + * The pane id for the payment information pane. + */ + public function getPaymentPaneId(); + } diff --git a/modules/payment/src/Plugin/Commerce/CheckoutPane/PaymentProcess.php b/modules/payment/src/Plugin/Commerce/CheckoutPane/PaymentProcess.php index 51480526..547c3854 100644 --- a/modules/payment/src/Plugin/Commerce/CheckoutPane/PaymentProcess.php +++ b/modules/payment/src/Plugin/Commerce/CheckoutPane/PaymentProcess.php @@ -110,8 +110,9 @@ class PaymentProcess extends PaymentCheckoutPaneBase { * {@inheritdoc} */ public function isVisible() { - $payment_info_pane = $this->checkoutFlow->getPane('payment_information'); - if (!$payment_info_pane->isVisible() || $payment_info_pane->getStepId() == '_disabled') { + $payment_info_id = $this->checkoutFlow->getPaymentPaneId(); + $payment_info_pane = $this->checkoutFlow->getPane($payment_info_id); + if (!$payment_info_pane || !$payment_info_pane->isVisible() || $payment_info_pane->getStepId() == '_disabled') { // Hide the pane if the PaymentInformation pane has been disabled. return FALSE; } @@ -238,12 +239,18 @@ class PaymentProcess extends PaymentCheckoutPaneBase { */ protected function getErrorStepId() { // Default to the step that contains the PaymentInformation pane. - $step_id = $this->checkoutFlow->getPane('payment_information')->getStepId(); + $payment_info_id = $this->checkoutFlow->getPaymentPaneId(); + $payment_info_pane = $this->checkoutFlow->getPane($payment_info_id); + if ($payment_info_pane === NULL) { + // Can't find the payment information pane provided by the checkout. + throw new \RuntimeException(sprintf('Cannot get the payment information pane with id "%s" for checkout flow "%s".', $payment_info_id, $this->checkoutFlow->getPluginId())); + } + $step_id = $payment_info_pane->getStepId(); if ($step_id == '_disabled') { // Can't redirect to the _disabled step. This could mean that isVisible() // was overridden to allow PaymentProcess to be used without a // payment_information pane, but this method was not modified. - throw new \RuntimeException('Cannot get the step ID for the payment_information pane. The pane is disabled.'); + throw new \RuntimeException(sprintf('Cannot get the step ID for the payment information pane "%s". The pane is disabled.', $payment_info_id)); } return $step_id;