Help for integrating the Laravel package
Forum rules: Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#5418 by gideon-maina
15 Jan 2018, 15:25
I am developing a new payment provider for the Aimeos shop Laravel package. I have followed all the instructions well and I have been able to add the payment provider and also override some confirmation templates.

Specifically the pay_pending confimation page template. However, I want to generate some code and show it to the user on the confirmation page. I have generated it on my process() method of the provider but I have not been successful in updating the view context so that I can display the code to the customer.

I tried adding new items to the $params array as shown below but with no avail

Code: Select all...
$params['my_code']= 'CKDLIOOK';

I have also tried using the normal decorators to update the context as shown below. This works but I cannot get it to link with the process() method for my Payment Provider.

Code: Select all<?php
namespace Aimeos\Client\Html\Common\Decorator;
class Mydecorator
    extends \Aimeos\Client\Html\Common\Decorator\Base
    implements \Aimeos\Client\Html\Common\Decorator\Iface
    private $view;
    public function getBody( $uid = '', array &$tags = array(), &$expire = null )
        $this->setView( $this->setViewParams( $this->getView(), $tags, $expire ) );
        return $this->getClient()->getBody( $uid, $tags, $expire );
    public function getHeader( $uid = '', array &$tags = array(), &$expire = null )
        $this->setView( $this->setViewParams( $this->getView(), $tags, $expire ) );
        return $this->getClient()->getHeader( $uid, $tags, $expire );
    protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null )
        if( $this->view === null )
            // fetch the supplier item from the database
            $view->mydecorator_account_number = 'HEllo World';
            $view->mydecoratorTotal = '24000';
            $this->view = $view;
        return $this->view;

I also tried using the service decorator as outlined in ... _decorator, but realized that the base classes does not have methods to update the view context.

Here is my process() method for the payment provider

Code: Select allpublic function process( \Aimeos\MShop\Order\Item\Iface $order, array $params = array() )
    // send the payment details to an external payment gateway
    $order_id = $order->getBaseId();
    $basket = $this->getOrderBase( $order_id );
    $total = $basket->getPrice()->getValue() + $basket->getPrice()->getCosts();

    $my_code = uniqid($more_entropy=true);

    $status = \Aimeos\MShop\Order\Item\Base::PAY_PENDING;
    $order->setPaymentStatus( $status );
    $this->saveOrder( $order );


    return parent::process( $order, $params );

How do i update the context to include $my_code above in the checkout/confirm/4/intro.body-default.php tempalate context and display it

Code: Select allPHP => 7.0
Laravel => 5.4
Aimeos => ~2017.1
System => Ubuntu Linux 16.04.3
#5420 by aimeos
15 Jan 2018, 22:55
The process() method of the service provider has no access to the view. If you want to show something in the view, you have to add that data in the HTML client. The decorator you've implemented doesn't work because addData() is new in 2018.01 and not available in 2017.x. Instead, 2017.x uses the setViewParams() method but it's not public and therefore, a decorator doesn't work for what you want to do. If you need to add data either in the setViewParams() or process() method of your own HTML client class with extends the "Standard" class.