I just developed a Payment Gateway module and I'm finding it hard to display the success page. A brief of the transaction flow:

Customer selects the payment gateway and gets redirected to the payment gateway where payments is made. On redirecting back to the magento site, the payment gateway posts back the transaction id to the returnurl. The transaction is supposed to be used to query the payment gateway so as to get the transaction status and other details. My questions are:

I have been able to get the transaction id in a controller on the merchants site but I/m having difficulting in displaying the successpage and also querying the payment gateway with the transaction id, kindly assist

My code so far...

Block OnePage Controller to query payment gateway

class Success extends \Magento\Checkout\Block\Onepage\Success

public function scopeCon()
        return \Magento\Store\Model\ScopeInterface::SCOPE_STORES;

    public function getGatewayStatusUrl(){

        return $this->_scopeConfig->getValue('payment/payment-method/trxStatus_url', $this->scopeCon());


    public function getTransactionStatus(){
        $this->_logger->info("I'm here");
        $url = $this->getGatewayStatusUrl();
        $tranxId = $this->_checkoutSession->getSessionId();

         -----make get request to payment gateway--------
         ------return json result----------


/** @var $block \Vendor\Module\Block\Success */ 
    <div class="checkout-success">
            <th collapse="2">TRANSACTION RECEIPT</th>
                    $result = $block->getTransactionStatus();
                    foreach($result as $key=>$row){
                        echo "<tr><td>" . $key . "</td><td>" . $row . "</td></tr>";


<?xml version="1.0"?>
    <referenceContainer name="order.success.additional.info">
        <block class="Vendor\MyModule\Block\Success" name="order.success" template="Vendor_MyModule::order/success.phtml" after="-">

You can do the following things.

  1. When Payment made successfully and you get back to the Controller, you need to save that transection ID either in session or create one new field in order and set data into that.

  2. You can get those detail easily either from session or order table and show on page.

| improve this answer | |
  • My success page is not even displaying, from controller it displays checkout cart page where customer will be able to edit order details, how do i fix this? – Olanrewaju Damilare Apr 26 '18 at 15:05
  • Have you set successpage URL for the payment request made? – Dhiren Vasoya Apr 27 '18 at 3:03
  • Yes I have. What I did was redirect to a controller from the payment gateway and then return $resultRedirect = $this->resultRedirectFactory->create()->setPath('checkout/onepage/success'); – Olanrewaju Damilare Apr 27 '18 at 7:45

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.