Update the view context using a custom payment provider
Posted: 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
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.
I also tried using the service decorator as outlined in https://aimeos.org/docs/Developers/Libr ... _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
...
...
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
=============VERSIONS==========
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';
...
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;
}
}
Here is my process() method for the payment provider
...
Code: Select all
public 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
=============VERSIONS==========
Code: Select all
PHP => 7.0
Laravel => 5.4
Aimeos => ~2017.1
System => Ubuntu Linux 16.04.3