* @copyright PayPal * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ use PaypalAddons\classes\AbstractMethodPaypal; /** * Update PPP payment request before initialize it. */ class PaypalPppPatchModuleFrontController extends PaypalAbstarctModuleFrontController { public function postProcess() { $method_ppp = AbstractMethodPaypal::load('PPP'); $idPayment = Tools::getValue('idPayment') ? Tools::getValue('idPayment') : Context::getContext()->cookie->paypal_plus_payment; $method_ppp->setPaymentId($idPayment); if ($idPayment) { try { $resultPath = $method_ppp->doOrderPatch(); if ($resultPath->isSuccess()) { $this->jsonValues = array('success' => $resultPath->isSuccess()); Context::getContext()->cookie->__unset('paypal_plus_payment'); } else { $this->errors['error_msg'] = $resultPath->getError()->getMessage(); $this->jsonValues = array('success' => false, 'redirect_link' => Context::getContext()->link->getModuleLink($this->name, 'error', $this->errors)); } } catch (Exception $e) { $this->errors['error_code'] = $e->getCode(); $this->errors['error_msg'] = $e->getMessage(); $this->jsonValues = array('success' => false, 'redirect_link' => Context::getContext()->link->getModuleLink($this->name, 'error', $this->errors)); } } } }