File indexing completed on 2024-05-12 05:58:40

0001 <?php
0002 
0003 /**
0004  *  ocs-webserver
0005  *
0006  *  Copyright 2016 by pling GmbH.
0007  *
0008  *    This file is part of ocs-webserver.
0009  *
0010  *    This program is free software: you can redistribute it and/or modify
0011  *    it under the terms of the GNU Affero General Public License as
0012  *    published by the Free Software Foundation, either version 3 of the
0013  *    License, or (at your option) any later version.
0014  *
0015  *    This program is distributed in the hope that it will be useful,
0016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0018  *    GNU Affero General Public License for more details.
0019  *
0020  *    You should have received a copy of the GNU Affero General Public License
0021  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0022  **/
0023 class SubscriptionController extends Local_Controller_Action_DomainSwitch
0024 {
0025 
0026     /**
0027      * Zend_Controller_Request_Abstract object wrapping the request environment
0028      *
0029      * @var Zend_Controller_Request_Http
0030      */
0031     protected $_request = null;
0032     /** @var  int */
0033     /** @var  Zend_Auth */
0034     protected $_auth;
0035     
0036     public static $SUPPORT_OPTIONS = array(  'Option1' => array(
0037                                             "name" => "Option1",                                            
0038                                             "amount" => 0.99,
0039                                             "checked" =>"checked",
0040                                             "period" => "monthly",
0041                                             "period_short" => "M",
0042                                             "period_frequency" => "1",
0043                                         ),
0044                                     'Option2' => array(
0045                                             "name" => "Option2",                                            
0046                                             "amount" => 2,
0047                                             "checked" =>"",                                            
0048                                             "period" => "monthly",
0049                                             "period_short" => "M",
0050                                             "period_frequency" => "1",
0051                                         ),
0052                                     'Option3' => array(
0053                                             "name" => "Option3",                                            
0054                                             "amount" => 5,
0055                                             "checked" =>"",
0056                                             "period" => "monthly",
0057                                             "period_short" => "M",
0058                                             "period_frequency" => "1",
0059                                         ),
0060                                     'Option4' => array(
0061                                             "name" => "Option4",                                            
0062                                             "amount" => 10,                                            
0063                                             "checked" =>"",
0064                                             "islast" => true,
0065                                             "period" => "monthly",
0066                                             "period_short" => "M",
0067                                             "period_frequency" => "1",
0068                                         ),
0069                                     'Option5' => array(
0070                                             "name" => "Option5",                                            
0071                                             "amount" => 0.99,
0072                                             "checked" =>"",                                            
0073                                             "period" => "yearly",
0074                                             "period_short" => "Y",
0075                                             "period_frequency" => "1",
0076                                             
0077                                         ),
0078                                     'Option6' => array(
0079                                             "name" => "Option6",                                            
0080                                             "amount" => 2,
0081                                             "checked" =>"",                                           
0082                                             "period" => "yearly",
0083                                             "period_short" => "Y",
0084                                             "period_frequency" => "1",
0085                                         ),
0086                                     'Option7' => array(
0087                                             "name" => "Option7",                                            
0088                                             "amount" => 0,
0089                                             "checked" =>"",                                            
0090                                             "period" => "yearly",
0091                                             "period_short" => "Y",
0092                                             "period_frequency" => "1",
0093                                         ),
0094                                     'Option8' => array(
0095                                             "name" => "Option8",                                            
0096                                             "amount" => 5,
0097                                             "checked" =>"",                                            
0098                                             "period" => "yearly",
0099                                             "period_short" => "Y",
0100                                             "period_frequency" => "1",
0101                                         ),
0102                                     'Option9' => array(
0103                                             "name" => "Option9",                                            
0104                                             "amount" => 10,
0105                                             "checked" =>"",                                            
0106                                             "period" => "yearly",
0107                                             "period_short" => "Y",
0108                                             "period_frequency" => "1",
0109                                         )
0110 
0111                                     
0112         );
0113 
0114     public function init()
0115     {
0116         parent::init();
0117         $this->_auth = Zend_Auth::getInstance();
0118         $this->view->payment_options = $this::$SUPPORT_OPTIONS;
0119         $this->view->noheader = true;
0120     }
0121 
0122     public function indexAction()
0123     {
0124         $this->view->authMember = $this->_authMember;
0125         $this->view->headTitle('Become a supporter - ' . $this->getHeadTitle(), 'SET');
0126         $httpHost = $this->getRequest()->getHttpHost();
0127         $this->view->urlPay =  '/support/pay';
0128         
0129         $sectionsTable = new Default_Model_Section();
0130         $sections = $sectionsTable->fetchAllSections();
0131         $this->view->sections = $sections;
0132 
0133         
0134     }
0135     
0136     public function supportpredefindedAction() {
0137         $this->view->authMember = $this->_authMember;
0138         $this->view->headTitle('Become a supporter - ' . $this->getHeadTitle(), 'SET');
0139         $httpHost = $this->getRequest()->getHttpHost();
0140         $this->view->urlPay =  '/support/paypredefined';
0141         
0142         $amount_predefined = (float)$this->getParam('amount_predefined', null);
0143         $section_id = (float)$this->getParam('section_id', null);
0144         $project_id = (float)$this->getParam('project_id', null);
0145         $support_amount = (float)$this->getParam('support_amount', null);
0146         
0147         $sectionsTable = new Default_Model_Section();
0148         $section = $sectionsTable->fetchSection($section_id);
0149         
0150         $referer = $this->getParam('referer', null);
0151         if (null == $referer && !empty($_SERVER['HTTP_REFERER'])) {
0152             $referer = $_SERVER['HTTP_REFERER'];
0153         }
0154         
0155         $this->view->amount_predefined = $amount_predefined;
0156         $this->view->support_amount = $support_amount;
0157         $this->view->section_id = $section_id;
0158         $this->view->project_id = $project_id;
0159         $this->view->referer = urlencode($referer);
0160         $this->view->section = $section;
0161     }
0162     
0163     public function support2Action()
0164     {
0165         $this->view->authMember = $this->_authMember;
0166         $this->view->headTitle('Become a supporter - ' . $this->getHeadTitle(), 'SET');
0167         $httpHost = $this->getRequest()->getHttpHost();
0168         $this->view->urlPay =  '/support/pay';
0169         $creator_id = $this->getParam('creator_id', null);
0170         $this->view->creator_id = $creator_id;
0171         
0172         $sectionsTable = new Default_Model_Section();
0173         $sections = $sectionsTable->fetchAllSections();
0174         $this->view->sections = $sections;
0175         
0176     }
0177 
0178     public function showAction()
0179     {
0180         $this->view->authMember = $this->_authMember;
0181         $this->view->headTitle('Become a supporter - ' . $this->getHeadTitle(), 'SET');
0182         $this->_helper->viewRenderer('index');
0183         $this->indexAction();
0184     }
0185 
0186 
0187     public function supportAction()
0188     {
0189 
0190         $this->view->authMember = $this->_authMember;
0191         $this->view->headTitle('Become a supporter - ' . $this->getHeadTitle(), 'SET');
0192 
0193         $request = Zend_Controller_Front::getInstance()->getRequest();
0194 
0195         $httpHost = $this->getRequest()->getHttpHost();
0196         $this->view->urlPay =  'https://' . $httpHost . '/support/pay';
0197         $this->view->amount = (float)$this->getParam('amount', 1);
0198         $this->view->comment = html_entity_decode(strip_tags($this->getParam('comment'), null), ENT_QUOTES, 'utf-8');
0199         $this->view->provider =
0200             mb_strtolower(html_entity_decode(strip_tags($this->getParam('provider'), null), ENT_QUOTES, 'utf-8'),
0201                 'utf-8');
0202 
0203     }
0204     
0205     public function payAction()
0206     {
0207         $this->_helper->layout()->disableLayout();
0208         $this->view->headTitle('Become a supporter - ' . $this->getHeadTitle(), 'SET');
0209         
0210         //get parameter
0211         $paymentOption = $this->getParam('amount_predefined');
0212         $amount_predefined = (float)$this->getParam('amount_predefined', 1);
0213         $amount_handish  = (float)$this->getParam('amount_handish', 1);
0214         
0215         $isHandish = false;
0216         
0217         $amount = 0;
0218         if(null != ($this->getParam('amount_predefined') && $amount_predefined > 0)) {
0219             $amount = $amount_predefined;
0220         } else {
0221             $isHandish = true;
0222             $amount = $amount_handish;
0223         }
0224         
0225         
0226         
0227         $comment = Default_Model_HtmlPurify::purify($this->getParam('comment'));
0228         $paymentProvider =
0229             mb_strtolower(html_entity_decode(strip_tags($this->getParam('provider'), null), ENT_QUOTES, 'utf-8'),
0230                 'utf-8');
0231         $httpHost = $this->getRequest()->getHttpHost();
0232         $config = Zend_Registry::get('config');
0233         
0234         $form_url = $config->third_party->paypal->form->endpoint . '/cgi-bin/webscr';
0235         $ipn_endpoint =  'http://'.$httpHost.'/gateway/paypal';
0236         $return_url_success =  'http://'.$httpHost.'/support/paymentok';
0237         $return_url_cancel =   'http://'.$httpHost.'/support/paymentcancel';
0238         $merchantid = $config->third_party->paypal->merchantid;
0239         
0240         $this->view->form_endpoint = $form_url;
0241         $this->view->form_ipn_endpoint = $ipn_endpoint;
0242         $this->view->form_return_url_ok = $return_url_success;
0243         $this->view->form_return_url_cancel = $return_url_cancel;
0244         $this->view->form_merchant = $merchantid;
0245         $this->view->member_id = $this->_authMember->member_id;
0246         $this->view->transaction_id = $this->_authMember->member_id . '_' . time();
0247         
0248         $this->view->amount = $amount;
0249         $this->view->payment_option = $paymentOption;
0250         
0251         //Add pling
0252         $modelSupport = new Default_Model_DbTable_Support();
0253         //$supportId = $modelSupport->createNewSupport($this->view->transaction_id, $this->_authMember->member_id, $amount);
0254         if($paymentOption == "Option7") {
0255             $supportId = $modelSupport->createNewSupportSubscriptionSignup($this->view->transaction_id
0256                 , $this->_authMember->member_id
0257                 , $amount
0258                 ,null
0259                 ,$this::$SUPPORT_OPTIONS[$paymentOption]['period_short']
0260                 ,$this::$SUPPORT_OPTIONS[$paymentOption]['period_frequency']
0261                 );
0262         } else {
0263 
0264             $calModel = new Default_View_Helper_CalcDonation();
0265             if($this::$SUPPORT_OPTIONS[$paymentOption]['period_short']=='Y')
0266             {
0267                 $v = $calModel->calcDonation($this::$SUPPORT_OPTIONS[$paymentOption]['amount']*12);
0268             }else{
0269                 $v = $calModel->calcDonation($this::$SUPPORT_OPTIONS[$paymentOption]['amount']);    
0270             }        
0271             $supportId = $modelSupport->createNewSupportSubscriptionSignup($this->view->transaction_id
0272                 ,$this->_authMember->member_id
0273                 ,$v
0274                 ,$this::$SUPPORT_OPTIONS[$paymentOption]['amount']                
0275                 ,$this::$SUPPORT_OPTIONS[$paymentOption]['period_short']
0276                 ,$this::$SUPPORT_OPTIONS[$paymentOption]['period_frequency']);
0277         }
0278         
0279         
0280         
0281         /**
0282         $paymentGateway = $this->createPaymentGateway($paymentProvider);
0283         //Receiver Data
0284         $opendesktopdata = array();
0285         $opendesktopdata['mail'] = $config->resources->mail->defaultFrom->email;
0286         //$opendesktopdata['firstname'] = "";
0287         $opendesktopdata['lastname'] = $config->resources->mail->defaultFrom->name;
0288         $opendesktopdata['paypal_mail'] = $config->third_party->paypal->facilitator_fee_receiver;
0289         $opendesktopdata['project_id'] = 0;
0290         $opendesktopdata['title'] = $config->resources->mail->defaultFrom->name;
0291         
0292         $paymentGateway->getUserDataStore()->generateFromArray($opendesktopdata);
0293 
0294         $requestMessage = 'Thank you for supporting: ' . $paymentGateway->getUserDataStore()->getProductTitle();
0295 
0296         $response = null;
0297         try {
0298             $response = $paymentGateway->requestPayment($amount, $requestMessage);
0299             $this->view->checkoutEndpoint = $paymentGateway->getCheckoutEndpoint();
0300             $this->view->paymentKey = $response->getPaymentId();
0301             $this->_helper->viewRenderer->setRender('pay_' . $paymentProvider);
0302         } catch (Exception $e) {
0303             throw new Zend_Controller_Action_Exception('payment error', 500, $e);
0304         }
0305 
0306         if (false === $response->isSuccessful()) {
0307             throw new Zend_Controller_Action_Exception('payment failure', 500);
0308         }
0309 
0310         $memberId = $this->_authMember->member_id;
0311 
0312         //Add pling
0313         $modelDonation = new Default_Model_DbTable_Donation();
0314         $donationId = $modelDonation->createNewDonationFromResponse($response, $memberId, $amount);
0315 
0316         if (false == empty($comment)) {
0317             $modelComments = new Default_Model_ProjectComments();
0318             $dataComment = array(
0319                 'comment_type'      => Default_Model_DbTable_Comments::COMMENT_TYPE_DONATION,
0320                 'comment_target_id' => 0,
0321                 'comment_member_id' => $memberId,
0322                 'comment_pling_id'  => $donationId,
0323                 'comment_text'      => $comment
0324             );
0325             $modelComments->save($dataComment);
0326         }
0327         **/
0328     }
0329     
0330     public function pay2Action()
0331     {
0332         $this->_helper->layout()->disableLayout();
0333         $this->view->headTitle('Become a supporter - ' . $this->getHeadTitle(), 'SET');
0334         
0335         $sectionsTable = new Default_Model_Section();
0336         $sections = $sectionsTable->fetchAllSections();
0337         
0338         $amount = 0;
0339         
0340         $paymentFrequenz = $this->getParam('paymentFrequenz', 'Y');
0341         $creator_id = $this->getParam('creator_id', null);
0342         $this->view->creator_id = $creator_id;
0343         
0344         //get parameter for every section
0345         $supportArray = array();
0346         foreach ($sections as $section) {
0347             
0348             $paymentOption = $this->getParam('amount_predefined-'.$section['section_id'], null);
0349             $amount_predefined = (float)$this->getParam('amount_predefined-'.$section['section_id'], null);
0350             $amount_handish  = (float)$this->getParam('amount_handish-'.$section['section_id'], null);
0351             $calModel = new Default_View_Helper_CalcDonation();
0352             
0353             if(null != $paymentOption) {
0354                 $isHandish = false;
0355                 $data = array();
0356                 if(null != $paymentOption && $paymentOption != 'Option7') {
0357                     
0358                     $amount += 0.99;
0359                     
0360                     $data['section_id'] = $section['section_id'];
0361                     $data['amount'] = 0.99;
0362                     $data['tier'] = 0.99;
0363                     $data['period'] = $paymentFrequenz;
0364                     $data['period_frequency'] = 1;
0365                 } else {
0366                     if(null != $amount_handish) {
0367                         $isHandish = true;
0368                         $amount += $amount_handish;
0369                         
0370                         $data['section_id'] = $section['section_id'];
0371                         $data['amount'] = $amount_handish;
0372                         $data['tier'] = $amount_handish;
0373                         $data['period'] = $paymentFrequenz;
0374                         $data['period_frequency'] = 1;
0375                     }
0376                     
0377                 }
0378                 $supportArray[] = $data;
0379             }
0380         }
0381         
0382         $amountTier = $amount;
0383         
0384         if($paymentFrequenz=='Y')
0385         {
0386             $amount = $calModel->calcDonation($amount*12);
0387         }else{
0388             $amount = $calModel->calcDonation($amount);    
0389         }   
0390         
0391         $comment = Default_Model_HtmlPurify::purify($this->getParam('comment'));
0392         $paymentProvider =
0393             mb_strtolower(html_entity_decode(strip_tags($this->getParam('provider'), null), ENT_QUOTES, 'utf-8'),
0394                 'utf-8');
0395         $httpHost = $this->getRequest()->getHttpHost();
0396         $config = Zend_Registry::get('config');
0397         
0398         $form_url = $config->third_party->paypal->form->endpoint . '/cgi-bin/webscr';
0399         $ipn_endpoint =  'http://'.$httpHost.'/gateway/paypal';
0400         $return_url_success =  'http://'.$httpHost.'/support/paymentok';
0401         $return_url_cancel =   'http://'.$httpHost.'/support/paymentcancel';
0402         $merchantid = $config->third_party->paypal->merchantid;
0403         
0404         $this->view->form_endpoint = $form_url;
0405         $this->view->form_ipn_endpoint = $ipn_endpoint;
0406         $this->view->form_return_url_ok = $return_url_success;
0407         $this->view->form_return_url_cancel = $return_url_cancel;
0408         $this->view->form_merchant = $merchantid;
0409         $this->view->member_id = $this->_authMember->member_id;
0410         $this->view->transaction_id = $this->_authMember->member_id . '_' . time();
0411         
0412         $this->view->amount = $amount;
0413         $this->view->amountTier = $amountTier;
0414         $this->view->paymentFrequenz = $paymentFrequenz;
0415         $this->view->payment_option = $paymentOption;
0416         
0417         
0418         //Add pling
0419         $modelSupport = new Default_Model_DbTable_Support();
0420         $supportId = $modelSupport->createNewSupportSubscriptionSignup($this->view->transaction_id
0421             , $this->_authMember->member_id
0422             , $amount
0423             , $amountTier
0424             ,$paymentFrequenz
0425             ,1
0426         );
0427         
0428         //Save Section-Support
0429         foreach ($supportArray as $support) {
0430             $modelSectionSupport = new Default_Model_DbTable_SectionSupport();
0431             $sectionSupportId = $modelSectionSupport->createNewSectionSupport(
0432                 $supportId
0433                 , $support['section_id']
0434                 , $support['amount']
0435                 ,$support['tier']
0436                 ,$support['period']
0437                 ,$support['period_frequency']
0438                 ,null
0439                 ,$creator_id
0440                 ,null
0441                 ,null
0442             );
0443         }
0444     }
0445     
0446     
0447     public function paypredefinedAction()
0448     {
0449         $this->_helper->layout()->disableLayout();
0450         $this->view->headTitle('Become a supporter - ' . $this->getHeadTitle(), 'SET');
0451         
0452         $amount = 0;
0453         
0454         
0455         
0456         //get parameter
0457         $paymentFrequenz = $this->getParam('paymentFrequenz', 'Y');
0458         $section_id = $this->getParam('section_id', null);
0459         
0460         $project_id = $this->getParam('project_id', null);
0461         $referer = $this->getParam('referer', null);
0462         
0463         $creator_id = $this->getParam('creator_id', null);
0464         
0465         $project = null;
0466         
0467         $project_category_id = null;
0468         
0469         if(null != $project_id) {
0470             $projectTable = new Default_Model_Project();
0471             $project = $projectTable->fetchProductInfo($project_id);
0472             if($project) {
0473                 $creator_id = $project->project_member_id;
0474                 $project_category_id = $project->project_category_id;
0475             }
0476 
0477         }
0478         
0479         $amount_predefined = (float)$this->getParam('amount_predefined', null);
0480         $amount_handish  = (float)$this->getParam('amount_handish', null);
0481 
0482         
0483         $this->_helper->layout()->disableLayout();
0484         $this->view->headTitle('Become a supporter - ' . $this->getHeadTitle(), 'SET');
0485         
0486         
0487         $isHandish = false;
0488         
0489         $amount = 0;
0490         if(null != ($this->getParam('amount_predefined') && $amount_predefined > 0)) {
0491             $amount = $amount_predefined;
0492         } else {
0493             $isHandish = true;
0494             $amount = $amount_handish;
0495         }
0496         
0497         $paymentProvider =
0498             mb_strtolower(html_entity_decode(strip_tags($this->getParam('provider'), null), ENT_QUOTES, 'utf-8'),
0499                 'utf-8');
0500         $httpHost = $this->getRequest()->getHttpHost();
0501         $config = Zend_Registry::get('config');
0502         
0503         $form_url = $config->third_party->paypal->form->endpoint . '/cgi-bin/webscr';
0504         $ipn_endpoint =  'http://'.$httpHost.'/gateway/paypal';
0505         $return_url_success =  'http://'.$httpHost.'/support/paymentok';
0506         $return_url_cancel =   'http://'.$httpHost.'/support/paymentcancel';
0507         $merchantid = $config->third_party->paypal->merchantid;
0508         
0509         $this->view->form_endpoint = $form_url;
0510         $this->view->form_ipn_endpoint = $ipn_endpoint;
0511         $this->view->form_return_url_ok = $return_url_success;
0512         $this->view->form_return_url_cancel = $return_url_cancel;
0513         $this->view->form_merchant = $merchantid;
0514         $this->view->member_id = $this->_authMember->member_id;
0515         $this->view->transaction_id = $this->_authMember->member_id . '_' . time();
0516         
0517         $this->view->amount = $amount;
0518         $this->view->paymentFrequenz = $paymentFrequenz;
0519         
0520         //Add pling
0521         $modelSupport = new Default_Model_DbTable_Support();
0522         //$supportId = $modelSupport->createNewSupport($this->view->transaction_id, $this->_authMember->member_id, $amount);
0523         $calModel = new Default_View_Helper_CalcDonation();
0524         
0525         if($paymentFrequenz=='Y')
0526         {
0527             $v = $calModel->calcDonation($amount*12);
0528         }else{
0529             $v = $calModel->calcDonation($amount);    
0530         } 
0531         $this->view->amountPay = $v;
0532         
0533         $supportId = $modelSupport->createNewSupportSubscriptionSignup($this->view->transaction_id
0534             ,$this->_authMember->member_id
0535             ,$v
0536             ,$amount               
0537             ,$paymentFrequenz
0538             ,1);
0539         
0540         
0541         $modelSectionSupport = new Default_Model_DbTable_SectionSupport();
0542         $sectionSupportId = $modelSectionSupport->createNewSectionSupport(
0543             $supportId
0544             , $section_id
0545             , $v
0546             , $amount
0547             , $paymentFrequenz
0548             , 1
0549             , $project_id
0550             , $creator_id
0551             , $project_category_id
0552             , urldecode($referer)
0553                 
0554         );
0555     }
0556 
0557     /**
0558      * @param string $paymentProvider
0559      *
0560      * @throws Zend_Controller_Exception
0561      * @return Local_Payment_GatewayInterface
0562      */
0563     protected function createPaymentGateway($paymentProvider)
0564     {
0565         $httpHost = $this->getRequest()->getHttpHost();
0566         /** @var Zend_Config $config */
0567         $config = Zend_Registry::get('config');
0568         $helperBuildProductUrl = new Default_View_Helper_BuildProductUrl();
0569         switch ($paymentProvider) {
0570             case 'paypal':
0571                 $paymentGateway = new Default_Model_PayPal_Gateway($config->third_party->paypal);
0572                 $paymentGateway->setIpnNotificationUrl('http://' . $httpHost . '/gateway/paypal');
0573                 //                $paymentGateway->setIpnNotificationUrl('http://' . $httpHost . '/gateway/paypal?XDEBUG_SESSION_START=1');
0574                 $paymentGateway->setCancelUrl('http://' . $httpHost . '/donate/paymentcancel');
0575                 $paymentGateway->setReturnUrl('http://' . $httpHost . '/donate/paymentok');
0576                 break;
0577 
0578             case 'dwolla':
0579                 $paymentGateway = new Default_Model_Dwolla_Gateway($config->third_party->dwolla);
0580                 $paymentGateway->setIpnNotificationUrl('http://' . $httpHost . '/gateway/dwolla');
0581                 $paymentGateway->setReturnUrl('http://' . $httpHost . '/donate/dwolla');
0582                 break;
0583 
0584             case 'amazon':
0585                 $paymentGateway = new Default_Model_Amazon_Gateway($config->third_party->amazon);
0586                 $paymentGateway->setIpnNotificationUrl('http://' . $httpHost . '/gateway/amazon');
0587                 $paymentGateway->setCancelUrl('http://' . $httpHost . '/donate/paymentcancel');
0588                 $paymentGateway->setReturnUrl('http://' . $httpHost . '/donate/paymentok');
0589                 break;
0590 
0591             default:
0592                 throw new Zend_Controller_Exception('No known payment provider found in parameters.');
0593                 break;
0594         }
0595 
0596         return $paymentGateway;
0597     }
0598 
0599     public function dwollaAction()
0600     {
0601         $modelPling = new Default_Model_DbTable_Plings();
0602         $plingData = $modelPling->fetchRow(array('payment_reference_key = ?' => $this->getParam('checkoutId')));
0603         $plingData->payment_transaction_id = (int)$this->getParam('transaction');
0604         $plingData->save();
0605 
0606         if ($this->_getParam('status') == 'Completed') {
0607             $this->_helper->viewRenderer('paymentok');
0608             $this->paymentokAction();
0609         } else {
0610             $this->_helper->viewRenderer('paymentcancel');
0611             $this->paymentcancelAction();
0612         }
0613     }
0614 
0615     public function paymentokAction()
0616     {
0617         //$this->_helper->layout()->disableLayout();
0618         $this->view->paymentStatus = 'success';
0619         $this->view->paymentMessage = 'Payment successful.';
0620         $this->view->headTitle('Thank you for your support - ' . $this->getHeadTitle(), 'SET');
0621     }
0622 
0623     public function paymentcancelAction()
0624     {
0625         //$this->_helper->layout()->disableLayout();
0626         $this->view->paymentStatus = 'danger';
0627         $this->view->paymentMessage = 'Payment cancelled.';
0628         $this->view->headTitle('Become a supporter - ' . $this->getHeadTitle(), 'SET');
0629     }
0630 
0631 
0632     /**
0633      * @param $errors
0634      *
0635      * @return array
0636      */
0637     protected function getErrorMessages($errors)
0638     {
0639         $messages = array();
0640         foreach ($errors as $element => $row) {
0641             if (!empty($row) && $element != 'submit') {
0642                 foreach ($row as $validator => $message) {
0643                     $messages[$element][] = $message;
0644                 }
0645             }
0646         }
0647 
0648         return $messages;
0649     }
0650 
0651     protected function _initResponseHeader()
0652     {
0653         $duration = 1800; // in seconds
0654         $expires = gmdate("D, d M Y H:i:s", time() + $duration) . " GMT";
0655 
0656         $this->getResponse()->setHeader('X-FRAME-OPTIONS', 'ALLOWALL',
0657                 true)//            ->setHeader('Last-Modified', $modifiedTime, true)
0658              ->setHeader('Expires', $expires, true)->setHeader('Pragma', 'no-cache', true)
0659              ->setHeader('Cache-Control', 'private, no-cache, must-revalidate', true)
0660         ;
0661     }
0662 
0663 
0664 }