| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | Copyright CiviCRM LLC. All rights reserved. | |
| 5 | | | |
| 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 | |
| 9 | +--------------------------------------------------------------------+ |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * @package CRM |
| 14 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
| 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. |
| 37 | */ |
| 38 | |
| 39 | if (defined('PANTHEON_ENVIRONMENT')) { |
| 40 | ini_set('session.save_handler', 'files'); |
| 41 | } |
| 42 | session_start(); |
| 43 | |
| 44 | require_once '../civicrm.config.php'; |
| 45 | |
| 46 | /* Cache the real UF, override it with the SOAP environment */ |
| 47 | |
| 48 | CRM_Core_Config::singleton(); |
| 49 | $log = new CRM_Utils_SystemLogger(); |
| 50 | if (empty($_GET)) { |
| 51 | $log->alert('payment_notification processor_name=PayPal', $_REQUEST); |
| 52 | $paypalIPN = new CRM_Core_Payment_PayPalProIPN($_REQUEST); |
| 53 | } |
| 54 | else { |
| 55 | $log->alert('payment_notification PayPal_Standard', $_REQUEST); |
| 56 | $paypalIPN = new CRM_Core_Payment_PayPalIPN($_REQUEST); |
| 57 | // @todo upgrade standard per Pro |
| 58 | } |
| 59 | try { |
| 60 | switch ($config->userFramework) { |
| 61 | case 'Joomla': |
| 62 | // CRM-18245 |
| 63 | CRM_Utils_System::loadBootStrap(); |
| 64 | break; |
| 65 | |
| 66 | default: |
| 67 | // Gitlab issues: #973, #1017 |
| 68 | CRM_Utils_System::loadBootStrap([], FALSE); |
| 69 | break; |
| 70 | |
| 71 | } |
| 72 | $paypalIPN->main(); |
| 73 | } |
| 74 | catch (CRM_Core_Exception $e) { |
| 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"; |
| 80 | } |