@@ -170,7 +170,7 @@ public function buildPaneForm(array $pane_form, FormStateInterface $form_state,
170170 try {
171171 $ payment ->payment_method = $ this ->order ->payment_method ->entity ;
172172 $ payment_gateway_plugin ->createPayment ($ payment , $ this ->configuration ['capture ' ]);
173- $ this ->checkoutFlow -> redirectToStep ($ next_step_id );
173+ $ this ->redirectToStep ($ next_step_id );
174174 }
175175 catch (DeclineException $ e ) {
176176 $ message = $ this ->t ('We encountered an error processing your payment method. Please verify your details and try again. ' );
@@ -212,7 +212,7 @@ public function buildPaneForm(array $pane_form, FormStateInterface $form_state,
212212 elseif ($ payment_gateway_plugin instanceof ManualPaymentGatewayInterface) {
213213 try {
214214 $ payment_gateway_plugin ->createPayment ($ payment );
215- $ this ->checkoutFlow -> redirectToStep ($ next_step_id );
215+ $ this ->redirectToStep ($ next_step_id );
216216 }
217217 catch (PaymentGatewayException $ e ) {
218218 \Drupal::logger ('commerce_payment ' )->error ($ e ->getMessage ());
@@ -222,7 +222,7 @@ public function buildPaneForm(array $pane_form, FormStateInterface $form_state,
222222 }
223223 }
224224 else {
225- $ this ->checkoutFlow -> redirectToStep ($ next_step_id );
225+ $ this ->redirectToStep ($ next_step_id );
226226 }
227227 }
228228
@@ -265,14 +265,26 @@ protected function buildPaymentInformationStepUrl() {
265265 ], ['absolute ' => TRUE ]);
266266 }
267267
268+ /**
269+ * Redirects to a specific checkout step.
270+ *
271+ * @param string $step_id
272+ * The step ID to redirect to.
273+ *
274+ * @throws \Drupal\commerce\Response\NeedsRedirectException
275+ */
276+ protected function redirectToStep ($ step_id ) {
277+ $ this ->checkoutFlow ->redirectToStep ($ step_id );
278+ }
279+
268280 /**
269281 * Redirects to a previous checkout step on error.
270282 *
271283 * @throws \Drupal\commerce\Response\NeedsRedirectException
272284 */
273285 protected function redirectToPreviousStep () {
274286 $ step_id = $ this ->checkoutFlow ->getPane ('payment_information ' )->getStepId ();
275- return $ this ->checkoutFlow -> redirectToStep ($ step_id );
287+ return $ this ->redirectToStep ($ step_id );
276288 }
277289
278290}
0 commit comments