$this->assign('hookDiscount', $this->_params[0]['discount']);
}
- // The concept of contributeMode is deprecated.
- if ($this->_contributeMode == 'express') {
- $params = [];
- // 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)) {
- 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);
- }
- CRM_Core_Payment_Form::mapParams($this->_bltID, $params, $params, FALSE);
-
- // 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'];
- $params['discountAmount'] = $this->_params[0]['discountAmount'];
- $params['discountMessage'] = $this->_params[0]['discountMessage'];
- }
-
- $params['amount_level'] = $this->_params[0]['amount_level'];
- $params['currencyID'] = $this->_params[0]['currencyID'];
-
- // also merge all the other values from the profile fields
- $values = $this->controller->exportValues('Register');
- $skipFields = [
- 'amount',
- "street_address-{$this->_bltID}",
- "city-{$this->_bltID}",
- "state_province_id-{$this->_bltID}",
- "postal_code-{$this->_bltID}",
- "country_id-{$this->_bltID}",
- ];
-
- foreach ($values as $name => $value) {
- // skip amount field
- if (!in_array($name, $skipFields)) {
- $params[$name] = $value;
- }
- if (substr($name, 0, 6) == 'price_') {
- $params[$name] = $this->_params[0][$name];
- }
- }
- $this->set('getExpressCheckoutDetails', $params);
- }
- $this->_params[0] = array_merge($this->_params[0], $params);
- $this->_params[0]['is_primary'] = 1;
- }
- else {
+ if (!$this->preProcessExpress()) {
//process only primary participant params.
$registerParams = $this->_params[0];
if (isset($registerParams["billing_state_province_id-{$this->_bltID}"])
$this->set('params', $this->_params);
}
+ /**
+ * Pre process function for Paypal Express confirm.
+ * @todo this is just a step in refactor as payment processor specific code does not belong in generic forms
+ *
+ * @return bool
+ * @throws \CRM_Core_Exception
+ */
+ private function preProcessExpress() {
+ if ($this->_contributeMode !== 'express') {
+ return FALSE;
+ }
+ $params = [];
+ // rfp == redirect from paypal
+ // @fixme 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)) {
+ 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);
+ }
+ CRM_Core_Payment_Form::mapParams($this->_bltID, $params, $params, FALSE);
+
+ // 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'];
+ $params['discountAmount'] = $this->_params[0]['discountAmount'];
+ $params['discountMessage'] = $this->_params[0]['discountMessage'];
+ }
+
+ $params['amount_level'] = $this->_params[0]['amount_level'];
+ $params['currencyID'] = $this->_params[0]['currencyID'];
+
+ // also merge all the other values from the profile fields
+ $values = $this->controller->exportValues('Register');
+ $skipFields = [
+ 'amount',
+ "street_address-{$this->_bltID}",
+ "city-{$this->_bltID}",
+ "state_province_id-{$this->_bltID}",
+ "postal_code-{$this->_bltID}",
+ "country_id-{$this->_bltID}",
+ ];
+
+ foreach ($values as $name => $value) {
+ // skip amount field
+ if (!in_array($name, $skipFields)) {
+ $params[$name] = $value;
+ }
+ if (substr($name, 0, 6) == 'price_') {
+ $params[$name] = $this->_params[0][$name];
+ }
+ }
+ $this->set('getExpressCheckoutDetails', $params);
+ }
+ $this->_params[0] = array_merge($this->_params[0], $params);
+ $this->_params[0]['is_primary'] = 1;
+ return TRUE;
+ }
+
/**
* Overwrite action, since we are only showing elements in frozen mode no help display needed.
*