Skip to content

Commit

Permalink
Shift hook call to be done in handlePaymentMethod function as per Eil…
Browse files Browse the repository at this point in the history
…een's comment and remove the hook from deprecated pathways and passbyrefeence in hook
  • Loading branch information
seamuslee001 committed Oct 16, 2018
1 parent 0ac40ff commit 6c6b5e4
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 10 deletions.
4 changes: 3 additions & 1 deletion CRM/Core/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ public static function logPaymentNotification($params) {
$message .= 'processor_id=' . $params['processor_id'];
}

CRM_Utils_Hook::alterIPNData($_REQUEST);
$log = new CRM_Utils_SystemLogger();
$log->alert($message, $_REQUEST);
}
Expand Down Expand Up @@ -1394,6 +1393,9 @@ public static function handlePaymentMethod($method, $params = array()) {
$extension_instance_found = TRUE;
}

// Call IPN alterIPNData hook to allow for custom processing of IPN data.
$IPNParams = array_merge($_GET, $_REQUEST);
CRM_Utils_Hook::alterIPNData($IPNParams);
if (!$extension_instance_found) {
$message = "No extension instances of the '%1' payment processor were found.<br />" .
"%2 method is unsupported in legacy payment processors.";
Expand Down
1 change: 0 additions & 1 deletion CRM/Core/Payment/PayPalImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,6 @@ public function cancelSubscription(&$message = '', $params = array()) {
*/
static public function handlePaymentNotification() {
$params = array_merge($_GET, $_REQUEST);
CRM_Utils_Hook::alterIPNData($_REQUEST);
$q = explode('/', CRM_Utils_Array::value('q', $params, ''));
$lastParam = array_pop($q);
if (is_numeric($lastParam)) {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Utils/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -2478,7 +2478,7 @@ public static function alterMailingRecipients(&$mailingObject, &$criteria, $cont
* @param array $IPNData - Array of IPN Data
* @return mixed
*/
public static function alterIPNData($IPNData) {
public static function alterIPNData(&$IPNData) {
return self::singleton()->invoke(array('IPNData'),
$IPNData, self::$_nullObject, self::$_nullObject,
self::$_nullObject, self::$_nullObject, self::$_nullObject,
Expand Down
1 change: 0 additions & 1 deletion extern/authorizeIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

require_once '../civicrm.config.php';
$config = CRM_Core_Config::singleton();
CRM_Utils_Hook::alterIPNData($_REQUEST);
$log = new CRM_Utils_SystemLogger();
$log->alert('payment_notification processor_name=AuthNet', $_REQUEST);

Expand Down
1 change: 0 additions & 1 deletion extern/ipn.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
/* Cache the real UF, override it with the SOAP environment */

$config = CRM_Core_Config::singleton();
CRM_Utils_Hook::alterIPNData($_REQUEST);
$log = new CRM_Utils_SystemLogger();
if (empty($_GET)) {
$log->alert('payment_notification processor_name=PayPal', $_REQUEST);
Expand Down
1 change: 0 additions & 1 deletion extern/pxIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
require_once 'CRM/Core/Config.php';

$config = CRM_Core_Config::singleton();
CRM_Utils_Hook::alterIPNData($_REQUEST);
$log = new CRM_Utils_SystemLogger();
$log->alert('payment_notification processor_name=Payment_Express', $_REQUEST);
/*
Expand Down
6 changes: 2 additions & 4 deletions tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,9 @@ public function testhookAlterIPNDataOnIPNPaymentSuccess() {
$this->hookClass->setHook('civicrm_alterIPNData', array($this, 'HookCiviCRMAlterIPNData'));
global $_REQUEST;
$_REQUEST = array('q' => CRM_Utils_System::url('civicrm/payment/ipn/' . $this->_paymentProcessorID)) + $this->getPaypalTransaction();

$mut = new CiviMailUtils($this, TRUE);
$paymentProcesors = civicrm_api3('PaymentProcessor', 'getsingle', array('id' => $this->_paymentProcessorID));
$payment = Civi\Payment\System::singleton()->getByProcessor($paymentProcesors);
$payment->handlePaymentNotification();
$payment = CRM_Core_Payment::handlePaymentMethod('PaymentNotification', ['processor_id' => $this->_paymentProcessorID]);

$contribution = $this->callAPISuccess('contribution', 'get', array('id' => $this->_contributionID, 'sequential' => 1));
// assert that contribution is completed after getting response from paypal standard which has transaction id set and completed status
Expand Down

0 comments on commit 6c6b5e4

Please sign in to comment.