Jump to content

[PS 1.7.6] Adding hookPaymentReturn in basic payment module: ContextErrorException Undefined index: layout


Recommended Posts

I'm developing a simple payment module starting from the basic one:
https://github.com/PrestaShop/paymentexample

I am trying to add a hookPaymentReturn
which allows me to add a tpl to the payment confirmation page (like ps_wirebank)
It fails with the following exception:

ContextErrorException Undefined index: layout

Attached the exception.

The added code has been simplified to the maximum to avoid errors

In Paymentexample.php

    public function hookPaymentReturn($params)
    {
        if (!$this->active) {
            return;
        }

        $state = $params['order']->getCurrentState();

        $this->smarty->assign(array(
            'shop_name' => $this->context->shop->name,
            'status' => 'ok'
        ));

/*        if (
        in_array(
            $state,
            array(
                Configuration::get('PS_OS_BANKWIRE'),
                Configuration::get('PS_OS_OUTOFSTOCK'),
                Configuration::get('PS_OS_OUTOFSTOCK_UNPAID'),
            )
        )) {

            $this->smarty->assign(array(
                'shop_name' => $this->context->shop->name,
//                'total' => Tools::displayPrice(
//                    $params['order']->getOrdersTotalPaid(),
//                    new Currency($params['order']->id_currency),
//                    false
//                ),
                'status' => 'ok'
//                'reference' => $params['order']->reference,
//                'contact_url' => $this->context->link->getPageLink('contact', true)
            ));
        } else {
            $this->smarty->assign(
                array(
                    'status' => 'failed'
//                    'contact_url' => $this->context->link->getPageLink('contact', true),
                )
            );
        }
*/

        return $this->fetch('module:paymentexample/views/templates/front/payment_return.tpl');
    }

 

In paymentexample/views/templates/front/payment_return.tpl

<div>pippo</div>

 

Screenshot 2020-04-02 at 11.46.47.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More