File indexing completed on 2025-08-03 05:34:04

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 Local_Payment_PayPal_SubscriptionSignup_Response implements Local_Payment_PayPal_SubscriptionSignupInterface
0024 {
0025 
0026     /** @var array|null */
0027     protected $_rawResponse;
0028 
0029     /**
0030      * @param array|null $rawResponse
0031      */
0032     function __construct($rawResponse = null)
0033     {
0034         if (isset($rawResponse)) {
0035             $this->_rawResponse = $rawResponse;
0036         }
0037     }
0038 
0039     
0040 
0041     /**
0042      * @return mixed
0043      */
0044     public function getCustom()
0045     {
0046         return strtoupper($this->_rawResponse['custom']);
0047     }
0048     
0049     /**
0050      * @return mixed
0051      */
0052     public function getSubscriptionDate()
0053     {
0054         return strtoupper($this->_rawResponse['subscr_date']);
0055     }
0056     
0057     
0058 
0059     /**
0060      * @param $name
0061      *
0062      * @return mixed
0063      */
0064     public function getField($name)
0065     {
0066         return $this->_rawResponse[$name];
0067     }
0068 
0069     /**
0070      * @return array|null
0071      */
0072     public function getRawMessage()
0073     {
0074         return $this->_rawResponse;
0075     }
0076 
0077     /**
0078      * @return string
0079      */
0080     public function getProviderName()
0081     {
0082         return 'paypal';
0083     }
0084 
0085     public function getSubscriptionAmount() {
0086         $period = null;
0087         
0088         for ($index = 0; $index < 6; $index++) {
0089             if(array_key_exists('amount'.$index, $this->_rawResponse)) {
0090                 $period = $this->_rawResponse['amount'.$index];
0091             }
0092                     
0093         }
0094         
0095         return $period;
0096     }
0097 
0098     public function getSubscriptionId() {
0099         return strtoupper($this->_rawResponse['subscr_id']);
0100     }
0101 
0102     public function getSubscriptionPeriod() {
0103         $period = null;
0104         
0105         for ($index = 0; $index < 6; $index++) {
0106             if(array_key_exists('period'.$index, $this->_rawResponse)) {
0107                 $period = $this->_rawResponse['period'.$index];
0108             }
0109                     
0110         }
0111         
0112         return $period;
0113     }
0114 
0115     
0116 }