I'm trying to create a custom payment method with direct action as well as in magento 1

here is the code i'm trying to do the redirect after clicked "place order button"

 /*jshint jquery:true*/
    function ($, quote, urlBuilder, storage, errorProcessor, customer, fullScreenLoader) {
        'use strict';
        return function (messageContainer) {

            $.mage.redirect("/test/redirect"); //url is your url

but my question is how to get the order details in /test/redirect controller?


At /test/redirect/index action you can get the order increment id from

Checkout session Magento\Checkout\Model\Session

Inject this class on your controller __construct function and get data from getLastOrderId

 * @var \Magento\Customer\Model\Session
protected $_customerSession;
 * @var \Magento\Sales\Model\OrderFactory
protected $_orderFactory;

public function __construct(
\Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Checkout\Model\Session $checkoutSession,
    $this->_checkoutSession = $checkoutSession;
    $this->_orderFactory = $orderFactory;

public function orderdetails()
    $orderincrementId = $this->_checkoutSession->getLastOrderId();

    $order = $this->_orderFactory->create();    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.