Warning, file /webapps/ocs-webserver/library/Local/Payment/PayPal/Response.php was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 Local_Payment_PayPal_Response
0024 {
0025 
0026     /**
0027      * @param array|null $rawResponse
0028      * @throws Local_Payment_Exception
0029      * @return Local_Payment_ResponseInterface
0030      */
0031     public static function buildResponse($rawResponse = null)
0032     {
0033         if (isset($rawResponse['txn_type']) AND ($rawResponse['txn_type'] == 'masspay')) {
0034             return new Local_Payment_PayPal_Masspay_ResponseMasspay($rawResponse);
0035         } else    
0036         if (isset($rawResponse['txn_type']) AND ($rawResponse['txn_type'] == 'subscr_payment')) {
0037             return new Local_Payment_PayPal_SubscriptionPayment_Response($rawResponse);
0038         } else    
0039         if (isset($rawResponse['txn_type']) AND ($rawResponse['txn_type'] == 'subscr_signup')) {
0040             return new Local_Payment_PayPal_SubscriptionSignup_Response($rawResponse);
0041         } else    
0042         if (isset($rawResponse['txn_type']) AND (($rawResponse['txn_type'] == 'subscr_cancel') || ($rawResponse['txn_type'] == 'subscr_failed')  || ($rawResponse['txn_type'] == 'recurring_payment_suspended_due_to_max_failed_paym'))) {
0043             return new Local_Payment_PayPal_SubscriptionCancel_Response($rawResponse);
0044         } else    
0045         if (isset($rawResponse['responseEnvelope_ack'])) {
0046             return new Local_Payment_PayPal_AdaptivePayment_ResponsePayRequest($rawResponse);
0047         } else 
0048         if (isset($rawResponse['transaction_type']) AND ($rawResponse['transaction_type'] == 'Adaptive Payment PAY')) {
0049             return new Local_Payment_PayPal_AdaptivePayment_ResponsePay($rawResponse);
0050         } else         
0051         if (isset($rawResponse['action_type']) AND ($rawResponse['action_type'] == 'PAY')) {
0052             return new Local_Payment_PayPal_AdaptivePayment_ResponsePay($rawResponse);
0053         } else 
0054         if (isset($rawResponse['transaction_type']) AND ($rawResponse['transaction_type'] == 'Adjustment')) {
0055             return new Local_Payment_PayPal_AdaptivePayment_ResponseAdjustment($rawResponse);
0056         } else 
0057         if (isset($rawResponse['txn_type']) AND ($rawResponse['txn_type'] == 'web_accept')) {
0058             return new Local_Payment_PayPal_Support_ResponseSupport($rawResponse);
0059         } else 
0060         if ($rawResponse['transaction_subject'] == '' AND $rawResponse['payment_status'] == 'Refunded') {
0061             return new Local_Payment_PayPal_AdaptivePayment_ResponseChargeback($rawResponse);
0062         } else {
0063             //Unknown response from PayPal. Raw message
0064             //throw new Local_Payment_Exception('Unknown response from PayPal. Raw message:' . print_r($rawResponse, true) . "\n");
0065             return null;
0066         }
0067     }
0068 
0069 }