From 9a1b1b8e57f8a942c2621d6b70d2b619a4f19edd Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Thu, 15 Oct 2015 23:03:51 +1300 Subject: [PATCH] CRM-17256 fixes to paypal-pro going down the paypal express path in confirm --- CRM/Event/Form/Registration/Confirm.php | 35 +++++++----------------- CRM/Event/Form/Registration/Register.php | 2 -- CRM/Utils/System.php | 1 - 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/CRM/Event/Form/Registration/Confirm.php b/CRM/Event/Form/Registration/Confirm.php index 8e32b256c5..b7348b067c 100644 --- a/CRM/Event/Form/Registration/Confirm.php +++ b/CRM/Event/Form/Registration/Confirm.php @@ -56,10 +56,9 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { /** * Set variables up before form is built. - * - * @return void */ public function preProcess() { + parent::preProcess(); // lineItem isn't set until Register postProcess @@ -85,28 +84,22 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { if ($this->_contributeMode == 'express') { $params = array(); // rfp == redirect from paypal + // rfp is probably not required - the getPreApprovalDetails should deal with any payment-processor specific 'stuff' $rfp = CRM_Utils_Request::retrieve('rfp', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET' ); //we lost rfp in case of additional participant. So set it explicitly. if ($rfp || CRM_Utils_Array::value('additional_participants', $this->_params[0], FALSE)) { - $payment = $this->_paymentProcessor['object']; - $paymentObjError = ts('The system did not record payment details for this payment and so could not process the transaction. Please report this error to the site administrator.'); - if (is_object($payment)) { - $expressParams = $payment->getExpressCheckoutDetails($this->get('token')); - } - else { - CRM_Core_Error::fatal($paymentObjError); + if (!empty($this->_paymentProcessor) && $this->_paymentProcessor['object']->supports('preApproval')) { + $preApprovalParams = $this->_paymentProcessor['object']->getPreApprovalDetails($this->get('pre_approval_parameters')); + $params = array_merge($this->_params, $preApprovalParams); } - $params['payer'] = CRM_Utils_Array::value('payer', $expressParams); - $params['payer_id'] = $expressParams['payer_id']; - $params['payer_status'] = $expressParams['payer_status']; - - CRM_Core_Payment_Form::mapParams($this->_bltID, $expressParams, $params, FALSE); + CRM_Core_Payment_Form::mapParams($this->_bltID, $params, $params, FALSE); // fix state and country id if present + // @todo - this is duplicated further down. if (isset($params["billing_state_province_id-{$this->_bltID}"])) { $params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($params["billing_state_province_id-{$this->_bltID}"]); } @@ -114,8 +107,8 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { $params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($params["billing_country_id-{$this->_bltID}"]); } - // set a few other parameters for PayPal - $params['token'] = $this->get('token'); + // set a few other parameters that are not really specific to this method because we don't know what + // will break if we change this. $params['amount'] = $this->_params[0]['amount']; if (!empty($this->_params[0]['discount'])) { $params['discount'] = $this->_params[0]['discount']; @@ -150,10 +143,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { } $this->set('getExpressCheckoutDetails', $params); } - else { - $params = $this->get('getExpressCheckoutDetails'); - } - $this->_params[0] = $params; + $this->_params[0] = array_merge($this->_params[0], $params); $this->_params[0]['is_primary'] = 1; } else { @@ -223,8 +213,6 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { /** * Build the form object. - * - * @return void */ public function buildQuickForm() { $this->assignToTemplate(); @@ -443,9 +431,6 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { /** * Process the form submission. - * - * - * @return void */ public function postProcess() { $now = date('YmdHis'); diff --git a/CRM/Event/Form/Registration/Register.php b/CRM/Event/Form/Registration/Register.php index 71a3576499..5c0f9055d9 100644 --- a/CRM/Event/Form/Registration/Register.php +++ b/CRM/Event/Form/Registration/Register.php @@ -266,8 +266,6 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { /** * Build the form object. - * - * @return void */ public function buildQuickForm() { // build profiles first so that we can determine address fields etc diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index 529358ba15..4501d01461 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -395,7 +395,6 @@ class CRM_Utils_System { if (!$url) { $url = self::url('civicrm/dashboard', 'reset=1'); } - // replace the & characters with & // this is kinda hackish but not sure how to do it right $url = str_replace('&', '&', $url); -- 2.25.1