From 05c302ecb028ab8f7b335cd216ac5eb4f07763a8 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 20 Jul 2015 21:55:04 +1200 Subject: [PATCH] CRM-16808 paypal refactoring, fix enotice on generating url Fix misnamed var (from prev commit) --- CRM/Contribute/Form/Contribution/Main.php | 1 + CRM/Core/Payment.php | 13 ++++++++++++- CRM/Core/Payment/PayPalImpl.php | 1 + CRM/Event/Form/Registration/Register.php | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index fb50237948..171b2d45b3 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -1358,6 +1358,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu protected function handlePreApproval(&$params) { try { $payment = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor); + $params['component'] = 'contribute'; $result = $payment->doPreApproval($params); } catch (\Civi\Payment\Exception\PaymentProcessorException $e) { diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index 4e48979733..d07478e712 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -39,7 +39,17 @@ use Civi\Payment\Exception\PaymentProcessorException; abstract class CRM_Core_Payment { /** - * How are we getting billing information? + * Component - ie. event or contribute. + * + * This is used for setting return urls. + * + * @var string + */ + protected $_component; + /** + * How are we getting billing information. + * + * We are trying to completely deprecate these parameters. * * FORM - we collect it on the same page * BUTTON - the processor collects it and sends it back to us via some protocol @@ -660,6 +670,7 @@ abstract class CRM_Core_Payment { * @throws \Civi\Payment\Exception\PaymentProcessorException */ public function doPayment(&$params, $component = 'contribute') { + $this->_component = $component; $statuses = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id'); if ($this->_paymentProcessor['billing_mode'] == 4) { $result = $this->doTransferCheckout($params, $component); diff --git a/CRM/Core/Payment/PayPalImpl.php b/CRM/Core/Payment/PayPalImpl.php index 6dd7432d89..1bacf20c24 100644 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@ -638,6 +638,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { * - redirect_url (if set the browser will be redirected to this. */ public function doPreApproval(&$params) { + $this->_component = $params['component']; $token = $this->setExpressCheckOut($params); return array( 'pre_approval_parameters' => array('token' => $token), diff --git a/CRM/Event/Form/Registration/Register.php b/CRM/Event/Form/Registration/Register.php index 8100e4e7ee..f4a7c8baa2 100644 --- a/CRM/Event/Form/Registration/Register.php +++ b/CRM/Event/Form/Registration/Register.php @@ -1170,6 +1170,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { ); $params['invoiceID'] = $invoiceID; + $params['component'] = 'event'; $token = $payment->doPreApproval($params); if (is_a($token, 'CRM_Core_Error')) { CRM_Core_Error::displaySessionError($token); -- 2.25.1