【问题标题】:Magento 2 - Can't get order data in custom controller for payment gateway integrationMagento 2 - 无法在自定义控制器中获取订单数据以进行支付网关集成
【发布时间】:2017-01-04 14:15:14
【问题描述】:

我正在为支付网关开发一个模块。

  1. 我使用模块创建者提供的here 创建了模块骨架。
  2. 我使用了this中给出的重定向解决方案。
  3. 我编写了要重定向的自定义控制器。

现在在我的自定义控制器中,我需要创建数据以发布到支付网关,然后将该数据发布到支付网关 url。 在这里,我需要我在结帐会话中没有得到的订单数据。我提到了他们使用类似方法的其他扩展,但我没有得到任何数据。

protected function _getOrder()
{
    if (!$this->_order) {

        $incrementId = $this->_getCheckout()->getLastRealOrderId();
        var_dump($incrementId);
        $this->_orderFactory = $this->_objectManager->get('Magento\Sales\Model\OrderFactory');
        $this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
    }
    return $this->_order;
}


protected function _getCheckout() {
    return $this->_objectManager->get('Magento\Checkout\Model\Session');
}

【问题讨论】:

  • 您是如何解决问题的?我也有这个问题,能解释一下吗?

标签: magento redirect payment magento2 gateway


【解决方案1】:

您可以使用以下加载顺序的方法。

$order = $this->_objectManager->create('Magento\Sales\Model\Order')->load($orderId);

【讨论】:

  • 但我也没有得到 OrderId。
猜你喜欢
  • 1970-01-01
  • 2018-12-07
  • 2012-01-27
  • 2011-09-08
  • 2013-01-21
  • 1970-01-01
  • 1970-01-01
  • 2020-03-06
  • 1970-01-01
相关资源
最近更新 更多