本文整理汇总了PHP中CRM_Core_Payment::paypalRedirect方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Payment::paypalRedirect方法的具体用法?PHP CRM_Core_Payment::paypalRedirect怎么用?PHP CRM_Core_Payment::paypalRedirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Payment
的用法示例。
在下文中一共展示了CRM_Core_Payment::paypalRedirect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* @param CRM_Core_Form $form
* @param null $type
* @param null $mode
*
* @throws Exception
*/
public static function preProcess(&$form, $type = NULL, $mode = NULL)
{
if ($type) {
$form->_type = $type;
} else {
$form->_type = CRM_Utils_Request::retrieve('type', 'String', $form);
}
if ($form->_type) {
$form->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($form->_type, $form->_mode);
}
$form->set('paymentProcessor', $form->_paymentProcessor);
// also set cancel subscription url
if (!empty($form->_paymentProcessor['is_recur']) && !empty($form->_values['is_recur'])) {
$form->_paymentObject = CRM_Core_Payment::singleton($mode, $form->_paymentProcessor, $form);
$form->_values['cancelSubscriptionUrl'] = $form->_paymentObject->subscriptionURL();
}
//checks after setting $form->_paymentProcessor
// we do this outside of the above conditional to avoid
// saving the country/state list in the session (which could be huge)
CRM_Core_Payment_Form::setPaymentFieldsByProcessor($form, $form->_paymentProcessor);
$form->assign_by_ref('paymentProcessor', $form->_paymentProcessor);
// check if this is a paypal auto return and redirect accordingly
//@todo - determine if this is legacy and remove
if (CRM_Core_Payment::paypalRedirect($form->_paymentProcessor)) {
$url = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_ThankYou_display=1&qfKey={$form->controller->_key}");
CRM_Utils_System::redirect($url);
}
// make sure we have a valid payment class, else abort
if (!empty($form->_values['is_monetary']) && !$form->_paymentProcessor['class_name'] && empty($form->_values['is_pay_later'])) {
CRM_Core_Error::fatal(ts('Payment processor is not set for this page'));
}
if (!empty($form->_membershipBlock) && !empty($form->_membershipBlock['is_separate_payment']) && (!empty($form->_paymentProcessor['class_name']) && !(CRM_Utils_Array::value('billing_mode', $form->_paymentProcessor) & CRM_Core_Payment::BILLING_MODE_FORM))) {
CRM_Core_Error::fatal(ts('This contribution page is configured to support separate contribution and membership payments. This %1 plugin does not currently support multiple simultaneous payments, or the option to "Execute real-time monetary transactions" is disabled. Please contact the site administrator and notify them of this error', array(1 => $form->_paymentProcessor['payment_processor_type'])));
}
}
示例2: preProcess
/**
* @param CRM_Contribute_Form_Contribution_Main|CRM_Event_Form_Registration_Register|CRM_Financial_Form_Payment $form
* @param null $type
* @param null $mode
*
* @throws Exception
*/
public static function preProcess(&$form, $type = NULL, $mode = NULL)
{
if ($type) {
$form->_type = $type;
} else {
$form->_type = CRM_Utils_Request::retrieve('type', 'String', $form);
}
if ($form->_type) {
$form->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($form->_type, $form->_mode);
}
if (empty($form->_paymentProcessor)) {
// This would happen when hitting the back-button on a multi-page form with a $0 selection in play.
return;
}
$form->set('paymentProcessor', $form->_paymentProcessor);
$form->_paymentObject = System::singleton()->getByProcessor($form->_paymentProcessor);
$form->assign('suppressSubmitButton', $form->_paymentObject->isSuppressSubmitButtons());
$form->assign('currency', CRM_Utils_Array::value('currency', $form->_values));
// also set cancel subscription url
if (!empty($form->_paymentProcessor['is_recur']) && !empty($form->_values['is_recur'])) {
$form->_values['cancelSubscriptionUrl'] = $form->_paymentObject->subscriptionURL(NULL, NULL, 'cancel');
}
if (!empty($form->_values['custom_pre_id'])) {
$profileAddressFields = array();
$fields = CRM_Core_BAO_UFGroup::getFields($form->_values['custom_pre_id'], FALSE, CRM_Core_Action::ADD, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL);
foreach ((array) $fields as $key => $value) {
CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields, array('uf_group_id' => $form->_values['custom_pre_id']));
}
if (count($profileAddressFields)) {
$form->set('profileAddressFields', $profileAddressFields);
}
}
//checks after setting $form->_paymentProcessor
// we do this outside of the above conditional to avoid
// saving the country/state list in the session (which could be huge)
CRM_Core_Payment_Form::setPaymentFieldsByProcessor($form, $form->_paymentProcessor, CRM_Utils_Request::retrieve('billing_profile_id', 'String'));
$form->assign_by_ref('paymentProcessor', $form->_paymentProcessor);
// check if this is a paypal auto return and redirect accordingly
//@todo - determine if this is legacy and remove
if (CRM_Core_Payment::paypalRedirect($form->_paymentProcessor)) {
$url = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_ThankYou_display=1&qfKey={$form->controller->_key}");
CRM_Utils_System::redirect($url);
}
// make sure we have a valid payment class, else abort
if (!empty($form->_values['is_monetary']) && !$form->_paymentProcessor['class_name'] && empty($form->_values['is_pay_later'])) {
CRM_Core_Error::fatal(ts('Payment processor is not set for this page'));
}
if (!empty($form->_membershipBlock) && !empty($form->_membershipBlock['is_separate_payment']) && (!empty($form->_paymentProcessor['class_name']) && !$form->_paymentObject->supports('MultipleConcurrentPayments'))) {
CRM_Core_Error::fatal(ts('This contribution page is configured to support separate contribution and membership payments. This %1 plugin does not currently support multiple simultaneous payments, or the option to "Execute real-time monetary transactions" is disabled. Please contact the site administrator and notify them of this error', array(1 => $form->_paymentProcessor['payment_processor_type'])));
}
}
示例3: preProcess
//.........这里部分代码省略.........
$this->set('requireApproval', $this->_requireApproval);
if (isset($this->_values['event']['default_role_id'])) {
$participant_role = CRM_Core_OptionGroup::values('participant_role');
$this->_values['event']['participant_role'] = $participant_role["{$this->_values['event']['default_role_id']}"];
}
$isPayLater = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eventId, 'is_pay_later');
//check for various combinations for paylater, payment
//process with paid event.
if ($isMonetary && (!$isPayLater || !empty($this->_values['event']['payment_processor']))) {
$this->_paymentProcessorIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('payment_processor', $this->_values['event']));
$this->assignPaymentProcessor($isPayLater);
}
//init event fee.
self::initEventFee($this, $this->_eventId);
// get the profile ids
$ufJoinParams = array('entity_table' => 'civicrm_event', 'module' => 'CiviEvent', 'entity_id' => $this->_eventId);
list($this->_values['custom_pre_id'], $this->_values['custom_post_id']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
// set profiles for additional participants
if ($this->_values['event']['is_multiple_registrations']) {
// CRM-4377: CiviEvent for the main participant, CiviEvent_Additional for additional participants
$ufJoinParams['module'] = 'CiviEvent_Additional';
list($this->_values['additional_custom_pre_id'], $this->_values['additional_custom_post_id'], $preActive, $postActive) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
// CRM-4377: we need to maintain backward compatibility, hence if there is profile for main contact
// set same profile for additional contacts.
if ($this->_values['custom_pre_id'] && !$this->_values['additional_custom_pre_id']) {
$this->_values['additional_custom_pre_id'] = $this->_values['custom_pre_id'];
}
if ($this->_values['custom_post_id'] && !$this->_values['additional_custom_post_id']) {
$this->_values['additional_custom_post_id'] = $this->_values['custom_post_id'];
}
// now check for no profile condition, in that case is_active = 0
if (isset($preActive) && !$preActive) {
unset($this->_values['additional_custom_pre_id']);
}
if (isset($postActive) && !$postActive) {
unset($this->_values['additional_custom_post_id']);
}
}
$this->assignBillingType();
if ($this->_values['event']['is_monetary']) {
CRM_Core_Payment_Form::setPaymentFieldsByProcessor($this, $this->_paymentProcessor);
}
$params = array('entity_id' => $this->_eventId, 'entity_table' => 'civicrm_event');
$this->_values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE);
$this->set('values', $this->_values);
$this->set('fields', $this->_fields);
$this->_availableRegistrations = CRM_Event_BAO_Participant::eventFull($this->_values['event']['id'], TRUE, CRM_Utils_Array::value('has_waitlist', $this->_values['event']));
$this->set('availableRegistrations', $this->_availableRegistrations);
}
$this->assign_by_ref('paymentProcessor', $this->_paymentProcessor);
// check if this is a paypal auto return and redirect accordingly
if (CRM_Core_Payment::paypalRedirect($this->_paymentProcessor)) {
$url = CRM_Utils_System::url('civicrm/event/register', "_qf_ThankYou_display=1&qfKey={$this->controller->_key}");
CRM_Utils_System::redirect($url);
}
// The concept of contributeMode is deprecated.
$this->_contributeMode = $this->get('contributeMode');
$this->assign('contributeMode', $this->_contributeMode);
// setting CMS page title
CRM_Utils_System::setTitle($this->_values['event']['title']);
$this->assign('title', $this->_values['event']['title']);
$this->assign('paidEvent', $this->_values['event']['is_monetary']);
// we do not want to display recently viewed items on Registration pages
$this->assign('displayRecent', FALSE);
// Registration page values are cleared from session, so can't use normal Printer Friendly view.
// Use Browser Print instead.
$this->assign('browserPrint', TRUE);
$isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']);
$this->assign('isShowLocation', $isShowLocation);
// Handle PCP
$pcpId = CRM_Utils_Request::retrieve('pcpId', 'Positive', $this);
if ($pcpId) {
$pcp = CRM_PCP_BAO_PCP::handlePcp($pcpId, 'event', $this->_values['event']);
$this->_pcpId = $pcp['pcpId'];
$this->_values['event']['intro_text'] = CRM_Utils_Array::value('intro_text', $pcp['pcpInfo']);
}
// assign all event properties so wizard templates can display event info.
$this->assign('event', $this->_values['event']);
$this->assign('location', $this->_values['location']);
$this->assign('bltID', $this->_bltID);
$isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']);
$this->assign('isShowLocation', $isShowLocation);
//CRM-6907
$config->defaultCurrency = CRM_Utils_Array::value('currency', $this->_values['event'], $config->defaultCurrency);
//lets allow user to override campaign.
$campID = CRM_Utils_Request::retrieve('campID', 'Positive', $this);
if ($campID && CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Campaign', $campID)) {
$this->_values['event']['campaign_id'] = $campID;
}
// Set the same value for is_billing_required as contribution page so code can be shared.
$this->_values['is_billing_required'] = CRM_Utils_Array::value('is_billing_required', $this->_values['event']);
// check if billing block is required for pay later
// note that I have started removing the use of isBillingAddressRequiredForPayLater in favour of letting
// the CRM_Core_Payment_Manual class handle it - but there are ~300 references to it in the code base so only
// removing in very limited cases.
if (CRM_Utils_Array::value('is_pay_later', $this->_values['event'])) {
$this->_isBillingAddressRequiredForPayLater = CRM_Utils_Array::value('is_billing_required', $this->_values['event']);
$this->assign('isBillingAddressRequiredForPayLater', $this->_isBillingAddressRequiredForPayLater);
}
}
示例4: preProcess
//.........这里部分代码省略.........
foreach ($this->_paymentProcessors as $eachPaymentProcessor) {
// check selected payment processor is active
if (!$eachPaymentProcessor) {
CRM_Core_Error::fatal(ts('The site administrator must set a Payment Processor for this event in order to use online registration.'));
}
// ensure that processor has a valid config
$payment = CRM_Core_Payment::singleton($this->_mode, $eachPaymentProcessor, $this);
$error = $payment->checkConfig();
if (!empty($error)) {
CRM_Core_Error::fatal($error);
}
}
}
}
}
//init event fee.
self::initEventFee($this, $this->_eventId);
// get the profile ids
$ufJoinParams = array('entity_table' => 'civicrm_event', 'module' => 'CiviEvent', 'entity_id' => $this->_eventId);
list($this->_values['custom_pre_id'], $this->_values['custom_post_id']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
// set profiles for additional participants
if ($this->_values['event']['is_multiple_registrations']) {
// CRM-4377: CiviEvent for the main participant, CiviEvent_Additional for additional participants
$ufJoinParams['module'] = 'CiviEvent_Additional';
list($this->_values['additional_custom_pre_id'], $this->_values['additional_custom_post_id'], $preActive, $postActive) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
// CRM-4377: we need to maintain backward compatibility, hence if there is profile for main contact
// set same profile for additional contacts.
if ($this->_values['custom_pre_id'] && !$this->_values['additional_custom_pre_id']) {
$this->_values['additional_custom_pre_id'] = $this->_values['custom_pre_id'];
}
if ($this->_values['custom_post_id'] && !$this->_values['additional_custom_post_id']) {
$this->_values['additional_custom_post_id'] = $this->_values['custom_post_id'];
}
// now check for no profile condition, in that case is_active = 0
if (isset($preActive) && !$preActive) {
unset($this->_values['additional_custom_pre_id']);
}
if (isset($postActive) && !$postActive) {
unset($this->_values['additional_custom_post_id']);
}
}
// get the billing location type
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
// CRM-8108 remove ts from Billing as the location type can not be translated in CiviCRM!
//$this->_bltID = array_search( ts('Billing'), $locationTypes );
$this->_bltID = array_search('Billing', $locationTypes);
if (!$this->_bltID) {
CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
}
$this->set('bltID', $this->_bltID);
if ($this->_values['event']['is_monetary'] && $this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_FORM) {
CRM_Core_Payment_Form::setCreditCardFields($this);
}
$params = array('entity_id' => $this->_eventId, 'entity_table' => 'civicrm_event');
$this->_values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE);
$this->set('values', $this->_values);
$this->set('fields', $this->_fields);
$this->_availableRegistrations = CRM_Event_BAO_Participant::eventFull($this->_values['event']['id'], TRUE, CRM_Utils_Array::value('has_waitlist', $this->_values['event']));
$this->set('availableRegistrations', $this->_availableRegistrations);
}
$this->assign_by_ref('paymentProcessor', $this->_paymentProcessor);
// check if this is a paypal auto return and redirect accordingly
if (CRM_Core_Payment::paypalRedirect($this->_paymentProcessor)) {
$url = CRM_Utils_System::url('civicrm/event/register', "_qf_ThankYou_display=1&qfKey={$this->controller->_key}");
CRM_Utils_System::redirect($url);
}
$this->_contributeMode = $this->get('contributeMode');
$this->assign('contributeMode', $this->_contributeMode);
// setting CMS page title
CRM_Utils_System::setTitle($this->_values['event']['title']);
$this->assign('title', $this->_values['event']['title']);
$this->assign('paidEvent', $this->_values['event']['is_monetary']);
// we do not want to display recently viewed items on Registration pages
$this->assign('displayRecent', FALSE);
// Registration page values are cleared from session, so can't use normal Printer Friendly view.
// Use Browser Print instead.
$this->assign('browserPrint', TRUE);
$isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']);
$this->assign('isShowLocation', $isShowLocation);
// Handle PCP
$pcpId = CRM_Utils_Request::retrieve('pcpId', 'Positive', $this);
if ($pcpId) {
$pcp = CRM_PCP_BAO_PCP::handlePcp($pcpId, 'event', $this->_values['event']);
$this->_pcpId = $pcp['pcpId'];
$this->_values['event']['intro_text'] = CRM_Utils_Array::value('intro_text', $pcp['pcpInfo']);
}
// assign all event properties so wizard templates can display event info.
$this->assign('event', $this->_values['event']);
$this->assign('location', $this->_values['location']);
$this->assign('bltID', $this->_bltID);
$isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']);
$this->assign('isShowLocation', $isShowLocation);
//CRM-6907
$config->defaultCurrency = CRM_Utils_Array::value('currency', $this->_values['event'], $config->defaultCurrency);
//lets allow user to override campaign.
$campID = CRM_Utils_Request::retrieve('campID', 'Positive', $this);
if ($campID && CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Campaign', $campID)) {
$this->_values['event']['campaign_id'] = $campID;
}
}
示例5: preProcess
//.........这里部分代码省略.........
if (!CRM_Utils_Array::value('is_active', $pcpBlock)) {
$statusMessage = ts('Personal Campaign Pages are currently not enabled for this contribution page. However you can still support the campaign by making a contribution here.');
CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$pcpInfo['contribution_page_id']}", false, null, false, true));
} else {
if (!CRM_Utils_Array::value('is_active', $pcpInfo)) {
$statusMessage = ts('The Personal Campaign Page you have just visited is current inactive. However you can still make a contribution here.');
CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$pcpInfo['contribution_page_id']}", false, null, false, true));
} else {
if ($startDate && $startDate > $now || $endDate && $endDate < $now) {
$customStartDate = CRM_Utils_Date::customFormat(CRM_Utils_Array::value('start_date', $this->_values));
$customEndDate = CRM_Utils_Date::customFormat(CRM_Utils_Array::value('end_date', $this->_values));
if ($startDate && $endDate) {
$statusMessage = ts('The Personal Campaign Page you have just visited is only active between %1 to %2. However you can still support the campaign by making a contribution here.', array(1 => $customStartDate, 2 => $customEndDate));
CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$pcpInfo['contribution_page_id']}", false, null, false, true));
} else {
if ($startDate) {
$statusMessage = ts('The Personal Campaign Page you have just visited will be active beginning on %1. However you can still support the campaign by making a contribution here.', array(1 => $customStartDate));
CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$pcpInfo['contribution_page_id']}", false, null, false, true));
} else {
if ($endDate) {
$statusMessage = ts('The Personal Campaign Page you have just visited is not longer active (as of %1). However you can still support the campaign by making a contribution here.', array(1 => $customEndDate));
CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$pcpInfo['contribution_page_id']}", false, null, false, true));
}
}
}
}
}
}
}
}
$this->_pcpId = $pcpId;
$this->_pcpBlock = $pcpBlock;
$this->_pcpInfo = $pcpInfo;
}
// Link (button) for users to create their own Personal Campaign page
if ($linkText = CRM_Contribute_BAO_PCP::getPcpBlockStatus($this->_id)) {
$linkTextUrl = CRM_Utils_System::url('civicrm/contribute/campaign', "action=add&reset=1&pageId={$this->_id}", false, null, true);
$this->assign('linkTextUrl', $linkTextUrl);
$this->assign('linkText', $linkText);
}
//set pledge block if block id is set
if (CRM_Utils_Array::value('pledge_block_id', $this->_values)) {
$this->assign('pledgeBlock', true);
}
// we do this outside of the above conditional to avoid
// saving the country/state list in the session (which could be huge)
if ($this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_FORM && CRM_Utils_Array::value('is_monetary', $this->_values)) {
require_once 'CRM/Core/Payment/Form.php';
require_once 'CRM/Core/Payment.php';
// payment fields are depending on payment type
if ($this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
CRM_Core_Payment_Form::setDirectDebitFields($this);
} else {
CRM_Core_Payment_Form::setCreditCardFields($this);
}
}
$this->assign_by_ref('paymentProcessor', $this->_paymentProcessor);
// check if this is a paypal auto return and redirect accordingly
if (CRM_Core_Payment::paypalRedirect($this->_paymentProcessor)) {
$url = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_ThankYou_display=1&qfKey={$this->controller->_key}");
CRM_Utils_System::redirect($url);
}
// make sure we have a valid payment class, else abort
if (CRM_Utils_Array::value('is_monetary', $this->_values) && !$this->_paymentProcessor['class_name'] && !CRM_Utils_Array::value('is_pay_later', $this->_values)) {
CRM_Core_Error::fatal(ts('Payment processor is not set for this page'));
}
// check if one of the (amount , membership) bloks is active or not
require_once 'CRM/Member/BAO/Membership.php';
$this->_membershipBlock = $this->get('membershipBlock');
if (!$this->_values['amount_block_is_active'] && !$this->_membershipBlock['is_active'] && !$this->_priceSetId) {
CRM_Core_Error::fatal(ts('The requested online contribution page is missing a required Contribution Amount section or Membership section or Price Set. Please check with the site administrator for assistance.'));
}
if ($this->_values['amount_block_is_active']) {
$this->set('amount_block_is_active', $this->_values['amount_block_is_active']);
}
if (!empty($this->_membershipBlock) && CRM_Utils_Array::value('is_separate_payment', $this->_membershipBlock) && !($this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_FORM)) {
CRM_Core_Error::fatal(ts('This contribution page is configured to support separate contribution and membership payments. This %1 plugin does not currently support multiple simultaneous payments. Please contact the site administrator and notify them of this error', array(1 => $this->_paymentProcessor['payment_processor_type'])));
}
$this->_contributeMode = $this->get('contributeMode');
$this->assign('contributeMode', $this->_contributeMode);
//assigning is_monetary and is_email_receipt to template
$this->assign('is_monetary', $this->_values['is_monetary']);
$this->assign('is_email_receipt', $this->_values['is_email_receipt']);
$this->assign('bltID', $this->_bltID);
//assign cancelSubscription URL to templates
$this->assign('cancelSubscriptionUrl', CRM_Utils_Array::value('cancelSubscriptionUrl', $this->_values));
// assigning title to template in case someone wants to use it, also setting CMS page title
if ($this->_pcpId) {
$this->assign('title', $pcpInfo['title']);
CRM_Utils_System::setTitle($pcpInfo['title']);
} else {
$this->assign('title', $this->_values['title']);
CRM_Utils_System::setTitle($this->_values['title']);
}
$this->_defaults = array();
$this->_amount = $this->get('amount');
//CRM-6907
$config = CRM_Core_Config::singleton();
$config->defaultCurrency = CRM_Utils_Array::value('currency', $this->_values, $config->defaultCurrency);
}
示例6: preProcess
//.........这里部分代码省略.........
if (!$ppID) {
CRM_Core_Error::statusBounce(ts('A payment processor must be selected for this event registration page, or the event must be configured to give users the option to pay later (contact the site administrator for assistance).'), $infoUrl);
}
require_once 'CRM/Core/BAO/PaymentProcessor.php';
$this->_paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
// make sure we have a valid payment class, else abort
if ($this->_values['event']['is_monetary']) {
if (!$this->_paymentProcessor) {
CRM_Core_Error::fatal(ts('The site administrator must set a Payment Processor for this event in order to use online registration.'));
}
// ensure that processor has a valid config
$payment =& CRM_Core_Payment::singleton($this->_mode, 'Event', $this->_paymentProcessor, $this);
$error = $payment->checkConfig();
if (!empty($error)) {
CRM_Core_Error::fatal($error);
}
}
$this->_paymentProcessor['processorName'] = $payment->_processorName;
$this->set('paymentProcessor', $this->_paymentProcessor);
}
// get price info
$price = self::initPriceSet($this, $eventID);
if ($price == false) {
if (!isset($this->_values['fee'])) {
$this->_values['fee'] = array();
}
require_once 'CRM/Core/OptionGroup.php';
CRM_Core_OptionGroup::getAssoc("civicrm_event.amount.{$eventID}", $this->_values['fee'], true);
//fix for non-upgraded price sets.CRM-4256.
if ($isMonetary && empty($this->_values['fee'])) {
CRM_Core_Error::fatal(ts('No Fee Level(s) or Price Set is configured for this event.<br />Click <a href=\'%1\'>CiviEvent >> Manage Event >> Configure >> Event Fees</a> to configure the Fee Level(s) or Price Set for this event.', array(1 => CRM_Utils_System::url('civicrm/event/manage', 'reset=1&action=update&subPage=Fee&id=' . $this->_eventId))));
}
}
// get the profile ids
require_once 'CRM/Core/BAO/UFJoin.php';
$ufJoinParams = array('entity_table' => 'civicrm_event', 'module' => 'CiviEvent', 'entity_id' => $this->_eventId);
list($this->_values['custom_pre_id'], $this->_values['custom_post_id']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
// set profiles for additional participants
if ($this->_values['event']['is_multiple_registrations']) {
require_once 'CRM/Core/BAO/UFJoin.php';
$ufJoinParams = array('entity_table' => 'civicrm_event', 'module' => 'CiviEvent_Additional', 'entity_id' => $this->_eventId);
list($this->_values['additional_custom_pre_id'], $this->_values['additional_custom_post_id'], $preActive, $postActive) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
// CRM-4377: we need to maintain backward compatibility, hence if there is profile for main contact
// set same profile for additional contacts.
if ($this->_values['custom_pre_id'] && !$this->_values['additional_custom_pre_id']) {
$this->_values['additional_custom_pre_id'] = $this->_values['custom_pre_id'];
}
if ($this->_values['custom_post_id'] && !$this->_values['additional_custom_post_id']) {
$this->_values['additional_custom_post_id'] = $this->_values['custom_post_id'];
}
// now check for no profile condition, in that case is_active = 0
if (isset($preActive) && !$preActive) {
unset($this->_values['additional_custom_pre_id']);
}
if (isset($postActive) && !$postActive) {
unset($this->_values['additional_custom_post_id']);
}
}
$params = array('id' => $this->_eventId);
// get the billing location type
$locationTypes =& CRM_Core_PseudoConstant::locationType();
$this->_bltID = array_search('Billing', $locationTypes);
if (!$this->_bltID) {
CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
}
$this->set('bltID', $this->_bltID);
if ($this->_values['event']['is_monetary'] && $this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_FORM) {
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::setCreditCardFields($this);
}
$params = array('entity_id' => $this->_eventId, 'entity_table' => 'civicrm_event');
require_once 'CRM/Core/BAO/Location.php';
$this->_values['location'] = CRM_Core_BAO_Location::getValues($params, true);
$this->set('values', $this->_values);
$this->set('fields', $this->_fields);
}
$this->assign_by_ref('paymentProcessor', $this->_paymentProcessor);
// check if this is a paypal auto return and redirect accordingly
if (CRM_Core_Payment::paypalRedirect($this->_paymentProcessor)) {
$url = CRM_Utils_System::url('civicrm/event/register', "_qf_ThankYou_display=1&qfKey={$this->controller->_key}");
CRM_Utils_System::redirect($url);
}
$this->_contributeMode = $this->get('contributeMode');
$this->assign('contributeMode', $this->_contributeMode);
// setting CMS page title
CRM_Utils_System::setTitle($this->_values['event']['title']);
$this->assign('title', $this->_values['event']['title']);
$this->assign('paidEvent', $this->_values['event']['is_monetary']);
// we do not want to display recently viewed items on Registration pages
$this->assign('displayRecent', false);
// Registration page values are cleared from session, so can't use normal Printer Friendly view.
// Use Browser Print instead.
$this->assign('browserPrint', true);
// assign all event properties so wizard templates can display event info.
$this->assign('event', $this->_values['event']);
$this->assign('location', $this->_values['location']);
$this->assign('bltID', $this->_bltID);
$isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']);
$this->assign('isShowLocation', $isShowLocation);
}