Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
f299f7db | 6 | | Copyright CiviCRM LLC (c) 2004-2020 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * @package CRM | |
f299f7db | 30 | * @copyright CiviCRM LLC (c) 2004-2020 |
6a488035 | 31 | * $Id$ |
35eab129 RL |
32 | * |
33 | * This script processes "Instant Payment Notifications" (IPNs). Modern | |
34 | * Payment Processors use the /civicrm/payment/ipn/123 endpoint instead (where | |
35 | * 123 is the payment processor ID), however a quirk in the way PayPal works | |
36 | * means that we need to maintain this script. | |
37 | * | |
38 | * Note on PayPal. | |
39 | * | |
40 | * Using PayPal Website Standard (which uses the old PayPal button API) the IPN | |
41 | * endpoint is passed to PayPal with every transaction, and it is then stored | |
42 | * by PayPal who unhelpfully do not give you any way to retrieve or change | |
43 | * this. | |
44 | * | |
45 | * This means that if you provide URL1 when setting up a recurring | |
46 | * contribution, then you will always need to maintain URL1 because all | |
47 | * recurring payments against that will be sent to URL1. | |
48 | * | |
49 | * Note that this also affects you if you were to move your CiviCRM instance to | |
50 | * another domain (if you do, get the webserver at the original domain to emit | |
51 | * a 307 redirect to the new one, PayPal will re-send). | |
52 | * | |
53 | * Therefore, for the sake of these old recurring contributions, CiviCRM should | |
54 | * maintain this script as part of core. | |
6a488035 TO |
55 | */ |
56 | ||
ba1e1ab6 | 57 | if (defined('PANTHEON_ENVIRONMENT')) { |
2af2cd60 | 58 | ini_set('session.save_handler', 'files'); |
59 | } | |
6a488035 TO |
60 | session_start(); |
61 | ||
62 | require_once '../civicrm.config.php'; | |
63 | ||
64 | /* Cache the real UF, override it with the SOAP environment */ | |
65 | ||
66 | $config = CRM_Core_Config::singleton(); | |
414e3596 | 67 | $log = new CRM_Utils_SystemLogger(); |
6a488035 | 68 | if (empty($_GET)) { |
6c8d1617 | 69 | $log->alert('payment_notification processor_name=PayPal', $_REQUEST); |
c8aa607b | 70 | $paypalIPN = new CRM_Core_Payment_PayPalProIPN($_REQUEST); |
6a488035 TO |
71 | } |
72 | else { | |
6c8d1617 | 73 | $log->alert('payment_notification PayPal_Standard', $_REQUEST); |
f78c9258 | 74 | $paypalIPN = new CRM_Core_Payment_PayPalIPN($_REQUEST); |
c8aa607b | 75 | // @todo upgrade standard per Pro |
76 | } | |
92e4c2a5 | 77 | try { |
35eab129 RL |
78 | switch ($config->userFramework) { |
79 | case 'Joomla': | |
80 | // CRM-18245 | |
81 | CRM_Utils_System::loadBootStrap(); | |
82 | break; | |
83 | ||
7aca4a01 FW |
84 | default: |
85 | // Gitlab issues: #973, #1017 | |
35eab129 RL |
86 | CRM_Utils_System::loadBootStrap([], FALSE); |
87 | break; | |
88 | ||
6ad50bf5 | 89 | } |
c8aa607b | 90 | $paypalIPN->main(); |
91 | } | |
56fdfc52 | 92 | catch (CRM_Core_Exception $e) { |
c8aa607b | 93 | CRM_Core_Error::debug_log_message($e->getMessage()); |
94 | CRM_Core_Error::debug_var('error data', $e->getErrorData(), TRUE, TRUE); | |
95 | CRM_Core_Error::debug_var('REQUEST', $_REQUEST, TRUE, TRUE); | |
96 | //@todo give better info to logged in user - ie dev | |
97 | echo "The transaction has failed. Please review the log for more detail"; | |
6a488035 | 98 | } |