*/ /** * Klasa stPrzelewy24FrontendActions * * @package stPrzelewy24Plugin * @subpackage actions */ class stPrzelewy24FrontendActions extends stActions { /** * Pozytywny powrót z płatności */ public function executeReturnSuccess() { $this->smarty = new stSmarty($this->getModuleName()); } /** * Negatywny powrót z płatności */ public function executeReturnFail() { $this->smarty = new stSmarty('stPrzelewy24Frontend'); $webpage = WebpagePeer::retrieveByState('CONTACT'); if ($webpage) { sfLoader::loadHelpers(array('Helper', 'stUrl')); $this->smarty->assign('contact_url', st_url_for('stWebpageFrontend/index?url='.$webpage->getFriendlyUrl())); } } public function executeProcessPayment() { $request = $this->getRequest(); $order = OrderPeer::retrieveByIdAndHashCode($this->getRequestParameter('id'), $this->getRequestParameter('hash')); if ($order) { $this->api = new stPrzelewy24(); try { $url = $this->api->getPaymentUrl($order); stPayment::log("przelewy24", "Generate payment url for order with id {$order->getId()}: $url"); if ($url) { return $this->renderJSON(array('redirect' => $url)); } } catch (Exception $e) { stPayment::log("przelewy24", "Generate payment url exception for order with id {$order->getId()}: {$e->getMessage()}"); } } return $this->renderJSON(array('redirect' => $this->getController()->genUrl('stPrzelewy24Frontend/returnFail'))); } public function executeStatus() { $request = $this->getRequest(); $order = OrderPeer::retrieveByIdAndHashCode($request->getParameter('id'), $request->getParameter('hash')); if ($order) { $api = new stPrzelewy24(); try { if ($api->verify($order, $request)) { $payment = $order->getOrderPayment(); if ($payment) { $payment->setStatus(true); $payment->save(); stPayment::log("przelewy24", "Payment status update for order with id {$order->getId()}: successful"); } else { stPayment::log("przelewy24", "Payment status update: Payment for order with id {$order->getId()} does not exist"); } } } catch (Exception $e) { stPayment::log("przelewy24", "Payment status update exception for order with id {$order->getId()}: ". $e->getMessage()); } } else { stPayment::log("przelewy24", "Payment status update: Order with id {$request->getParameter('id')} does not exist"); } return $this->renderText("OK"); } }