Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
6b7eb9df | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
6b7eb9df TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * @package CRM | |
ca5cec67 | 14 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
35eab129 RL |
15 | * This script processes "Instant Payment Notifications" (IPNs). Modern |
16 | * Payment Processors use the /civicrm/payment/ipn/123 endpoint instead (where | |
17 | * 123 is the payment processor ID), however a quirk in the way PayPal works | |
18 | * means that we need to maintain this script. | |
19 | * | |
20 | * Note on PayPal. | |
21 | * | |
22 | * Using PayPal Website Standard (which uses the old PayPal button API) the IPN | |
23 | * endpoint is passed to PayPal with every transaction, and it is then stored | |
24 | * by PayPal who unhelpfully do not give you any way to retrieve or change | |
25 | * this. | |
26 | * | |
27 | * This means that if you provide URL1 when setting up a recurring | |
28 | * contribution, then you will always need to maintain URL1 because all | |
29 | * recurring payments against that will be sent to URL1. | |
30 | * | |
31 | * Note that this also affects you if you were to move your CiviCRM instance to | |
32 | * another domain (if you do, get the webserver at the original domain to emit | |
33 | * a 307 redirect to the new one, PayPal will re-send). | |
34 | * | |
35 | * Therefore, for the sake of these old recurring contributions, CiviCRM should | |
36 | * maintain this script as part of core. | |
6a488035 TO |
37 | */ |
38 | ||
ba1e1ab6 | 39 | if (defined('PANTHEON_ENVIRONMENT')) { |
2af2cd60 | 40 | ini_set('session.save_handler', 'files'); |
41 | } | |
6a488035 TO |
42 | session_start(); |
43 | ||
44 | require_once '../civicrm.config.php'; | |
45 | ||
46 | /* Cache the real UF, override it with the SOAP environment */ | |
47 | ||
d523d24a | 48 | CRM_Core_Config::singleton(); |
414e3596 | 49 | $log = new CRM_Utils_SystemLogger(); |
6a488035 | 50 | if (empty($_GET)) { |
6c8d1617 | 51 | $log->alert('payment_notification processor_name=PayPal', $_REQUEST); |
c8aa607b | 52 | $paypalIPN = new CRM_Core_Payment_PayPalProIPN($_REQUEST); |
6a488035 TO |
53 | } |
54 | else { | |
6c8d1617 | 55 | $log->alert('payment_notification PayPal_Standard', $_REQUEST); |
f78c9258 | 56 | $paypalIPN = new CRM_Core_Payment_PayPalIPN($_REQUEST); |
c8aa607b | 57 | // @todo upgrade standard per Pro |
58 | } | |
92e4c2a5 | 59 | try { |
35eab129 RL |
60 | switch ($config->userFramework) { |
61 | case 'Joomla': | |
62 | // CRM-18245 | |
63 | CRM_Utils_System::loadBootStrap(); | |
64 | break; | |
65 | ||
7aca4a01 FW |
66 | default: |
67 | // Gitlab issues: #973, #1017 | |
35eab129 RL |
68 | CRM_Utils_System::loadBootStrap([], FALSE); |
69 | break; | |
70 | ||
6ad50bf5 | 71 | } |
c8aa607b | 72 | $paypalIPN->main(); |
73 | } | |
56fdfc52 | 74 | catch (CRM_Core_Exception $e) { |
c8aa607b | 75 | CRM_Core_Error::debug_log_message($e->getMessage()); |
76 | CRM_Core_Error::debug_var('error data', $e->getErrorData(), TRUE, TRUE); | |
77 | CRM_Core_Error::debug_var('REQUEST', $_REQUEST, TRUE, TRUE); | |
78 | //@todo give better info to logged in user - ie dev | |
79 | echo "The transaction has failed. Please review the log for more detail"; | |
6a488035 | 80 | } |