I'm trying to change the behavior of a payment module in Prestashop 1.6.x, in order to create a customer receipt from the approval source to the order confirmation page.
I would like a suggestion concerning the best method and some guidance to achieve it a the correct way.
More specifically, when the user completes the transaction using a specific payment module, I need to populate the order confirmation page with POST data from the external banking source which is available in the postProcess()
function, in order to use it as a kind of receipt.
As far as I can understand, after payment has been made:
the module validates the order and elaborates the external source's POST data through a
PostProcess()
function (part of an extendedModuleFrontController
class) and found in a controllers/front/validation.php file.Within
PostProcess()
, if external data is OK (i.e. transaction approved), it redirects to the order confirmation controller with the following:
public function postProcess() {
(...)
$somePostData = '';
//this is the variable that is populated from POST data and i need to show in the confirmation.tpl
$somePostData = Tools::getValue('postdata');
Tools::redirect('index.php?controller=order-confirmation&id_cart=' .
$this->context->cart->id . '&id_module=' .
$this->module->id . '&id_order=' .
$this->module->currentOrder . '&key=' .
$customer->secure_key
);
(...)
}
At some point
hookPaymentReturn()
is being called (resided in the main module php file), which loads a specific module template file related to the order confirmation page.In order to show some variables through the tpl file, the only solution i've found is to use a smarty variable just before returning the populated tpl as shown below:
public function hookPaymentReturn()
{
if (!$this->active) {
return;
}
//this is the variable that I want to populate from the above-mentioned $somePostData found in postProcess()
$receipt_display = 'some data';
$this->context->smarty->assign('receipt_display', $receipt_display);
return $this->display(__FILE__, 'views/templates/hook/confirmation.tpl');
}
So my question is how can I populate $receipt_display with data from $somePostData as shown in the two above-mentioned code sections?
Is there a different methodology that you could suggest if the above-mentioned is wrong?
Thank you, mmystery