2

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*/
define(
    [
        'jquery',
        'Magento_Checkout/js/model/quote',
        'Magento_Checkout/js/model/url-builder',
        'mage/storage',
        'Magento_Checkout/js/model/error-processor',
        'Magento_Customer/js/model/customer',
        'Magento_Checkout/js/model/full-screen-loader'
    ],
    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?

0

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();    
    $order->loadByIncrementId($orderId);
}

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.