Пример #1
0
 /**
  * Set variables up before form is built.
  *
  * @return void
  */
 public function preProcess()
 {
     parent::preProcess();
     // lineItem isn't set until Register postProcess
     $this->_lineItem = $this->get('lineItem');
     $this->_params = $this->get('params');
     $this->_params[0]['tax_amount'] = $this->get('tax_amount');
     $this->_params[0]['is_pay_later'] = $this->get('is_pay_later');
     $this->assign('is_pay_later', $this->_params[0]['is_pay_later']);
     if ($this->_params[0]['is_pay_later']) {
         $this->assign('pay_later_receipt', $this->_values['event']['pay_later_receipt']);
     }
     CRM_Utils_Hook::eventDiscount($this, $this->_params);
     if (!empty($this->_params[0]['discount']) && !empty($this->_params[0]['discount']['applied'])) {
         $this->set('hookDiscount', $this->_params[0]['discount']);
         $this->assign('hookDiscount', $this->_params[0]['discount']);
     }
     if ($this->_contributeMode == 'express') {
         $params = array();
         // rfp == redirect from paypal
         $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);
             }
             $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);
             // fix state and country id if present
             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}"]);
             }
             if (isset($params['billing_country_id'])) {
                 $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');
             $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'];
             }
             if (!empty($this->_params[0]['amount_priceset_level_radio'])) {
                 $params['amount_priceset_level_radio'] = $this->_params[0]['amount_priceset_level_radio'];
             }
             $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 = array('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);
         } else {
             $params = $this->get('getExpressCheckoutDetails');
         }
         $this->_params[0] = $params;
         $this->_params[0]['is_primary'] = 1;
     } else {
         //process only primary participant params.
         $registerParams = $this->_params[0];
         if (isset($registerParams["billing_state_province_id-{$this->_bltID}"]) && $registerParams["billing_state_province_id-{$this->_bltID}"]) {
             $registerParams["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($registerParams["billing_state_province_id-{$this->_bltID}"]);
         }
         if (isset($registerParams["billing_country_id-{$this->_bltID}"]) && $registerParams["billing_country_id-{$this->_bltID}"]) {
             $registerParams["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($registerParams["billing_country_id-{$this->_bltID}"]);
         }
         if (isset($registerParams['credit_card_exp_date'])) {
             $registerParams['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($registerParams);
             $registerParams['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($registerParams);
         }
         if ($this->_values['event']['is_monetary']) {
             $registerParams['ip_address'] = CRM_Utils_System::ipAddress();
             $registerParams['currencyID'] = $this->_params[0]['currencyID'];
         }
         //assign back primary participant params.
         $this->_params[0] = $registerParams;
     }
     if ($this->_values['event']['is_monetary']) {
         $this->_params[0]['invoiceID'] = $this->get('invoiceID');
     }
     $this->assign('defaultRole', FALSE);
     if (CRM_Utils_Array::value('defaultRole', $this->_params[0]) == 1) {
         $this->assign('defaultRole', TRUE);
     }
     if (empty($this->_params[0]['participant_role_id']) && $this->_values['event']['default_role_id']) {
         $this->_params[0]['participant_role_id'] = $this->_values['event']['default_role_id'];
     }
     if (isset($this->_values['event']['confirm_title'])) {
         CRM_Utils_System::setTitle($this->_values['event']['confirm_title']);
     }
     if ($this->_pcpId) {
         $params = CRM_Contribute_Form_Contribution_Confirm::processPcp($this, $this->_params[0]);
         $this->_params[0] = $params;
     }
     $this->set('params', $this->_params);
 }
Пример #2
0
 /**
  * Set variables up before form is built.
  */
 public function preProcess()
 {
     parent::preProcess();
     // lineItem isn't set until Register postProcess
     $this->_lineItem = $this->get('lineItem');
     $this->_params = $this->get('params');
     $this->_params[0]['tax_amount'] = $this->get('tax_amount');
     $this->_params[0]['is_pay_later'] = $this->get('is_pay_later');
     $this->assign('is_pay_later', $this->_params[0]['is_pay_later']);
     if ($this->_params[0]['is_pay_later']) {
         $this->assign('pay_later_receipt', $this->_values['event']['pay_later_receipt']);
     }
     CRM_Utils_Hook::eventDiscount($this, $this->_params);
     if (!empty($this->_params[0]['discount']) && !empty($this->_params[0]['discount']['applied'])) {
         $this->set('hookDiscount', $this->_params[0]['discount']);
         $this->assign('hookDiscount', $this->_params[0]['discount']);
     }
     // The concept of contributeMode is deprecated.
     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)) {
             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 = array('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 {
         //process only primary participant params.
         $registerParams = $this->_params[0];
         if (isset($registerParams["billing_state_province_id-{$this->_bltID}"]) && $registerParams["billing_state_province_id-{$this->_bltID}"]) {
             $registerParams["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($registerParams["billing_state_province_id-{$this->_bltID}"]);
         }
         if (isset($registerParams["billing_country_id-{$this->_bltID}"]) && $registerParams["billing_country_id-{$this->_bltID}"]) {
             $registerParams["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($registerParams["billing_country_id-{$this->_bltID}"]);
         }
         if (isset($registerParams['credit_card_exp_date'])) {
             $registerParams['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($registerParams);
             $registerParams['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($registerParams);
         }
         if ($this->_values['event']['is_monetary']) {
             $registerParams['ip_address'] = CRM_Utils_System::ipAddress();
             $registerParams['currencyID'] = $this->_params[0]['currencyID'];
         }
         //assign back primary participant params.
         $this->_params[0] = $registerParams;
     }
     if ($this->_values['event']['is_monetary']) {
         $this->_params[0]['invoiceID'] = $this->get('invoiceID');
     }
     $this->assign('defaultRole', FALSE);
     if (CRM_Utils_Array::value('defaultRole', $this->_params[0]) == 1) {
         $this->assign('defaultRole', TRUE);
     }
     if (empty($this->_params[0]['participant_role_id']) && $this->_values['event']['default_role_id']) {
         $this->_params[0]['participant_role_id'] = $this->_values['event']['default_role_id'];
     }
     if (isset($this->_values['event']['confirm_title'])) {
         CRM_Utils_System::setTitle($this->_values['event']['confirm_title']);
     }
     if ($this->_pcpId) {
         $params = CRM_Contribute_Form_Contribution_Confirm::processPcp($this, $this->_params[0]);
         $this->_params[0] = $params;
     }
     $this->set('params', $this->_params);
 }
Пример #3
0
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public 
  */
 function preProcess()
 {
     parent::preProcess();
     // lineItem isn't set until Register postProcess
     $this->_lineItem = $this->get('lineItem');
     $this->_params = $this->get('params');
     require_once 'CRM/Utils/Hook.php';
     CRM_Utils_Hook::eventDiscount($this, $this->_params);
     if (CRM_Utils_Array::value('discount', $this->_params[0]) && CRM_Utils_Array::value('applied', $this->_params[0]['discount'])) {
         $this->set('hookDiscount', $this->_params[0]['discount']);
         $this->assign('hookDiscount', $this->_params[0]['discount']);
     }
     $config =& CRM_Core_Config::singleton();
     if ($this->_contributeMode == 'express') {
         $params = array();
         // rfp == redirect from paypal
         $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)) {
             require_once 'CRM/Core/Payment.php';
             $payment =& CRM_Core_Payment::singleton($this->_mode, 'Event', $this->_paymentProcessor, $this);
             $expressParams = $payment->getExpressCheckoutDetails($this->get('token'));
             $params['payer'] = $expressParams['payer'];
             $params['payer_id'] = $expressParams['payer_id'];
             $params['payer_status'] = $expressParams['payer_status'];
             require_once 'CRM/Core/Payment/Form.php';
             CRM_Core_Payment_Form::mapParams($this->_bltID, $expressParams, $params, false);
             // fix state and country id if present
             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}"]);
             }
             if (isset($params['billing_country_id'])) {
                 $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');
             $params['amount'] = $this->_params[0]['amount'];
             if (CRM_Utils_Array::value('discount', $this->_params[0])) {
                 $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'];
             $params['payment_action'] = 'Sale';
             // also merge all the other values from the profile fields
             $values = $this->controller->exportValues('Register');
             $skipFields = array('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;
                 }
             }
             $this->set('getExpressCheckoutDetails', $params);
         } else {
             $params = $this->get('getExpressCheckoutDetails');
         }
         $this->_params[0] = $params;
         $this->_params[0]['is_primary'] = 1;
     } else {
         //process only primary participant params.
         $registerParams = $this->_params[0];
         if (isset($registerParams["billing_state_province_id-{$this->_bltID}"]) && $registerParams["billing_state_province_id-{$this->_bltID}"]) {
             $registerParams["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($registerParams["billing_state_province_id-{$this->_bltID}"]);
         }
         if (isset($registerParams["billing_country_id-{$this->_bltID}"]) && $registerParams["billing_country_id-{$this->_bltID}"]) {
             $registerParams["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($registerParams["billing_country_id-{$this->_bltID}"]);
         }
         if (isset($registerParams['credit_card_exp_date'])) {
             $registerParams['year'] = $registerParams['credit_card_exp_date']['Y'];
             $registerParams['month'] = $registerParams['credit_card_exp_date']['M'];
         }
         if ($this->_values['event']['is_monetary']) {
             $registerParams['ip_address'] = CRM_Utils_System::ipAddress();
             $registerParams['currencyID'] = $this->_params[0]['currencyID'];
             $registerParams['payment_action'] = 'Sale';
         }
         //assign back primary participant params.
         $this->_params[0] = $registerParams;
     }
     if ($this->_values['event']['is_monetary']) {
         $this->_params[0]['invoiceID'] = $this->get('invoiceID');
     }
     $this->assign('defaultRole', false);
     if (CRM_Utils_Array::value('defaultRole', $this->_params[0]) == 1) {
         $this->assign('defaultRole', true);
     }
     if (!CRM_Utils_Array::value('participant_role_id', $this->_params[0]) && $this->_values['event']['default_role_id']) {
         $this->_params[0]['participant_role_id'] = $this->_values['event']['default_role_id'];
     }
     if (isset($this->_values['event']['confirm_title'])) {
         CRM_Utils_System::setTitle($this->_values['event']['confirm_title']);
     }
     $this->set('params', $this->_params);
 }