* @copyright 2007-2019 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ include_once _PS_MODULE_DIR_.'paypal/classes/AbstractMethodPaypal.php'; include_once _PS_MODULE_DIR_.'paypal/controllers/front/abstract.php'; /** * Validate BT payment */ class PaypalBtValidationModuleFrontController extends PaypalAbstarctModuleFrontController { public function init() { parent::init(); $this->values['payment_method_nonce'] = Tools::getvalue('payment_method_nonce'); $this->values['payment_method_bt'] = Tools::getvalue('payment_method_bt'); $this->values['bt_vaulting_token'] = Tools::getvalue('bt_vaulting_token'); $this->values['pbt_vaulting_token'] = Tools::getvalue('pbt_vaulting_token'); $this->values['save_card_in_vault'] = Tools::getvalue('save_card_in_vault'); $this->values['save_account_in_vault'] = Tools::getvalue('save_account_in_vault'); } public function postProcess() { $method_bt = AbstractMethodPaypal::load('BT'); try { $method_bt->setParameters($this->values); $method_bt->validation(); $cart = Context::getContext()->cart; $customer = new Customer($cart->id_customer); $paypal = Module::getInstanceByName($this->name); $this->redirectUrl = 'index.php?controller=order-confirmation&id_cart='.$cart->id.'&id_module='.$paypal->id.'&id_order='.$paypal->currentOrder.'&key='.$customer->secure_key; } catch (PaypalAddons\classes\PaypalException $e) { $this->errors['error_code'] = $e->getCode(); $this->errors['error_msg'] = $e->getMessage(); $this->errors['msg_long'] = $e->getMessageLong(); } catch (Exception $e) { $this->errors['error_code'] = $e->getCode(); $this->errors['error_msg'] = $e->getMessage(); } finally { $this->transaction_detail = $method_bt->getDetailsTransaction(); } if (!empty($this->errors)) { $this->redirectUrl = Context::getContext()->link->getModuleLink($this->name, 'error', $this->errors); } } }