Created
February 7, 2018 09:21
-
-
Save xuxucode/b8296340e90fe47bcbcb15e15d6896ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/modules/payment/src/Controller/PaymentCheckoutController.php b/modules/payment/src/Controller/PaymentCheckoutController.php | |
index a60605d..2a9e246 100644 | |
--- a/modules/payment/src/Controller/PaymentCheckoutController.php | |
+++ b/modules/payment/src/Controller/PaymentCheckoutController.php | |
@@ -2,12 +2,14 @@ | |
namespace Drupal\commerce_payment\Controller; | |
+use Drupal\commerce\Response\NeedsRedirectException; | |
use Drupal\commerce_checkout\CheckoutOrderManagerInterface; | |
use Drupal\commerce_order\Entity\OrderInterface; | |
use Drupal\commerce_payment\Exception\PaymentGatewayException; | |
use Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\OffsitePaymentGatewayInterface; | |
use Drupal\Core\Access\AccessException; | |
use Drupal\Core\DependencyInjection\ContainerInjectionInterface; | |
+use Drupal\Core\Url; | |
use Symfony\Component\DependencyInjection\ContainerInterface; | |
use Symfony\Component\HttpFoundation\Request; | |
@@ -64,6 +66,15 @@ class PaymentCheckoutController implements ContainerInjectionInterface { | |
$checkout_flow_plugin = $checkout_flow->getPlugin(); | |
$step_id = $this->checkoutOrderManager->getCheckoutStepId($commerce_order); | |
+ // Redirect to 'complete' step while the order is placed. | |
+ if ($commerce_order->getState()->value != 'draft' && $step_id == 'complete') { | |
+ $checkout_flow_plugin->redirectToStep('complete'); | |
+ throw new NeedsRedirectException(Url::fromRoute('commerce_checkout.form', [ | |
+ 'commerce_order' => $commerce_order->id(), | |
+ 'step' => $step_id, | |
+ ])->toString()); | |
+ } | |
+ | |
try { | |
$payment_gateway_plugin->onReturn($commerce_order, $request); | |
$redirect_step_id = $checkout_flow_plugin->getNextStepId($step_id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment