Nervermind, I ended up fixing this issue by following another template for a payment method and it worked.
Hello, I am developing a payment module for PrestaShop and I am having a problem where after the button "Place Order" is pressed it goes to a white page, it is supposed to load a validation page (called "beamvalidation") that does all the necessary verifications and charges the money, then it should redirect to another page saying "You order has been placed!".
code for the hooks:
public function hookPaymentOptions($params) //Get PaymentOptions { /** Verify if this module is active */ if (!$this->active) { return; } /* Form action URL. The form data will be sent to the validation controller when the user finishes * the order process. */ $formAction = $this->context->link->getModuleLink($this->name, 'beamvalidation', array(), true); /* Assign the url form action to the template var $action */ $this->smarty->assign(['action' => $formAction]); /* Load form template to be displayed in the checkout step */ $paymentForm = $this->fetch('module:prestashopbeam/views/templates/payment_options.tpl'); /* Create a PaymentOption object containing the necessary data to display this module in the checkout */ $newOption = new PaymentOption; $newOption->setModuleName($this->displayName) ->setCallToActionText($this->displayName) ->setAction($formAction) ->setForm($paymentForm) /*->setLogo($this->_path .'views/img/'. 'logo.png')*/; $payment_options = array($newOption); return $payment_options; } /** Display Sucessfull Payment */ public function hookPaymentReturn($params) { if($this->active) { return; } $confirm = $this->fetch('module:prestashopbeam/views/templates/payment_return.tpl'); return $confirm; }
validation file (beamvalidation):
class PrestaShopBeamValidationModuleFrontController extends ModuleFrontController { public function postProcess() { $cart = $this->context->cart; $authorized = false; echo 'resultou!!'; if(!$this->module->active || $cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice==0) { Tools::redirect('index.php?controller=order&step1=1'); } /** * Verify if this payment module is authorized */ foreach (Module::getPaymentModules() as $module) { if ($module['name'] == 'prestashopbeam') { $authorized = true; break; } } if (!$authorized) { die($this->l('This payment method is not available.')); } /** @var CustomerCore $customer */ $customer = new Customer($cart->id_customer); /** * Check if this is a valid customer account */ if (!Validate::isLoadedObject($customer)) { Tools::redirect('index.php?controller=order&step=1'); } /** * Payment processing */ //A part of the code is missing because it is confidential and I cannot share it with anyone, but this is where we charge the money /** * Redirect the customer to the order confirmation page */ Tools::redirect('index.php?controller=order-confirmation&id_cart='.(int)$cart->id.'&id_module='.(int)$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key); } /** Find the current url and return it*/ protected function getCurrentURL() { return Tools::getCurrentUrlProtocolPrefix() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; } }