Merge pull request #1950 from pratik-joshi/CRM-13735
[civicrm-core.git] / extern / ipn.php
index 9a09ed35822956253c809ea5448738d2ad854070..8cbea934617181538d46d7447d2e78696d68b160 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
@@ -40,32 +40,20 @@ require_once '../civicrm.config.php';
 $config = CRM_Core_Config::singleton();
 
 if (empty($_GET)) {
-  $rpInvoiceArray = array();
-  $rpInvoiceArray = explode('&', $_POST['rp_invoice_id']);
-  foreach ($rpInvoiceArray as $rpInvoiceValue) {
-    $rpValueArray = explode('=', $rpInvoiceValue);
-    if ($rpValueArray[0] == 'm') {
-      $value = $rpValueArray[1];
-    }
-  }
-  $paypalIPN = new CRM_Core_Payment_PayPalProIPN();
+  $paypalIPN = new CRM_Core_Payment_PayPalProIPN($_REQUEST);
 }
 else {
-  $value = CRM_Utils_Array::value('module', $_GET);
   $paypalIPN = new CRM_Core_Payment_PayPalIPN();
+  // @todo upgrade standard per Pro
 }
-
-switch ($value) {
-  case 'contribute':
-    $paypalIPN->main('contribute');
-    break;
-
-  case 'event':
-    $paypalIPN->main('event');
-    break;
-
-  default:
-    CRM_Core_Error::debug_log_message("Could not get module name from request url");
-    echo "Could not get module name from request url<p>";
-    break;
+try{
+  $paypalIPN->main();
 }
+catch(CRM_Core_Exception $e) {
+  CRM_Core_Error::debug_log_message($e->getMessage());
+  CRM_Core_Error::debug_var('error data', $e->getErrorData(), TRUE, TRUE);
+  CRM_Core_Error::debug_var('REQUEST', $_REQUEST, TRUE, TRUE);
+  //@todo give better info to logged in user - ie dev
+  echo "The transaction has failed. Please review the log for more detail";
+}
+