File indexing completed on 2025-05-04 05:29:11
0001 <?php 0002 /** 0003 * ocs-webserver 0004 * 0005 * Copyright 2016 by pling GmbH. 0006 * 0007 * This file is part of ocs-webserver. 0008 * 0009 * This program is free software: you can redistribute it and/or modify 0010 * it under the terms of the GNU Affero General Public License as 0011 * published by the Free Software Foundation, either version 3 of the 0012 * License, or (at your option) any later version. 0013 * 0014 * This program is distributed in the hope that it will be useful, 0015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 * GNU Affero General Public License for more details. 0018 * 0019 * You should have received a copy of the GNU Affero General Public License 0020 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 **/ 0022 0023 class Default_Model_PayPal_SupportIpnMessage extends Local_Payment_PayPal_Support_Ipn 0024 { 0025 0026 /** @var \Default_Model_DbTable_Support */ 0027 protected $_tableSupport; 0028 0029 function __construct($config = null, $logger = null) 0030 { 0031 if (null == $logger) { 0032 $logger = Zend_Registry::get('logger'); 0033 } 0034 0035 if (null == $config) { 0036 $config = Zend_Registry::get('config'); 0037 } 0038 0039 parent::__construct($config->third_party->paypal, $logger); 0040 0041 $this->_tableSupport = new Default_Model_DbTable_Support; 0042 } 0043 0044 protected function validateTransaction() 0045 { 0046 $donation = $this->_tableSupport->fetchSupportFromResponse($this->_ipnMessage); 0047 0048 if (empty($donation)) { 0049 $this->_logger->err(__METHOD__ . ' - ' . 'No transaction found for IPN message.' . print_r($this->_ipnMessage, true)); 0050 return false; 0051 } else { 0052 $this->_dataIpn = $donation->toArray(); 0053 } 0054 0055 return $this->_checkAmount() && $this->_checkEmail(); 0056 } 0057 0058 protected function _checkAmount() 0059 { 0060 return true; 0061 } 0062 0063 protected function _checkEmail() 0064 { 0065 return true; 0066 } 0067 0068 protected function _statusCompleted() 0069 { 0070 $this->_processTransactionStatusCompleted(); 0071 } 0072 0073 protected function _statusError() 0074 { 0075 $this->_tableSupport->deactivateSupportFromResponse($this->_ipnMessage); 0076 } 0077 0078 protected function _processTransactionStatusCompleted() 0079 { 0080 $this->_tableSupport->activateSupportFromResponse($this->_ipnMessage); 0081 } 0082 0083 protected function _processTransactionStatusPending() 0084 { 0085 //$this->_tableDonation->activateDonationFromResponse($this->_ipnMessage); 0086 } 0087 0088 protected function _processTransactionStatusRefunded() 0089 { 0090 $this->_tableSupport->deactivateSupportFromResponse($this->_ipnMessage); 0091 } 0092 0093 protected function _processTransactionStatusDenied() 0094 { 0095 $this->_tableSupport->deactivateSupportFromResponse($this->_ipnMessage); 0096 } 0097 0098 }