本文整理汇总了PHP中CRM_Core_Error::displaySessionError方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Error::displaySessionError方法的具体用法?PHP CRM_Core_Error::displaySessionError怎么用?PHP CRM_Core_Error::displaySessionError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Error
的用法示例。
在下文中一共展示了CRM_Core_Error::displaySessionError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
//.........这里部分代码省略.........
$params['currencyID'] = $config->defaultCurrency;
//added for discount
require_once 'CRM/Core/BAO/Discount.php';
$discountId = CRM_Core_BAO_Discount::findSet($this->_eventId, 'civicrm_event');
if (!empty($this->_values['discount'][$discountId])) {
$params['discount_id'] = $discountId;
$params['amount_level'] = $this->_values['discount'][$discountId][$params['amount']]['label'];
$params['amount'] = $this->_values['discount'][$discountId][$params['amount']]['value'];
} else {
if (empty($params['priceSetId'])) {
$params['amount_level'] = $this->_values['fee'][$params['amount']]['label'];
$params['amount'] = $this->_values['fee'][$params['amount']]['value'];
} else {
$lineItem = array();
require_once "CRM/Price/BAO/Set.php";
CRM_Price_BAO_Set::processAmount($this->_values['fee']['fields'], $params, $lineItem);
$priceSet = array();
$priceSet[] = $lineItem;
$this->set('lineItem', $priceSet);
}
}
$this->set('amount', $params['amount']);
$this->set('amount_level', $params['amount_level']);
// generate and set an invoiceID for this transaction
$invoiceID = md5(uniqid(rand(), true));
$this->set('invoiceID', $invoiceID);
if (is_array($this->_paymentProcessor)) {
$payment =& CRM_Core_Payment::singleton($this->_mode, 'Event', $this->_paymentProcessor, $this);
}
// default mode is direct
$this->set('contributeMode', 'direct');
if (isset($params["state_province_id-{$this->_bltID}"]) && $params["state_province_id-{$this->_bltID}"]) {
$params["state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($params["state_province_id-{$this->_bltID}"]);
}
if (isset($params["country_id-{$this->_bltID}"]) && $params["country_id-{$this->_bltID}"]) {
$params["country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($params["country_id-{$this->_bltID}"]);
}
if (isset($params['credit_card_exp_date'])) {
$params['year'] = $params['credit_card_exp_date']['Y'];
$params['month'] = $params['credit_card_exp_date']['M'];
}
if ($this->_values['event']['is_monetary']) {
$params['ip_address'] = CRM_Utils_System::ipAddress();
$params['currencyID'] = $config->defaultCurrency;
$params['payment_action'] = 'Sale';
$params['invoiceID'] = $invoiceID;
}
$this->_params = array();
$this->_params[] = $params;
$this->set('params', $this->_params);
if ($this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON) {
//get the button name
$buttonName = $this->controller->getButtonName();
if (in_array($buttonName, array($this->_expressButtonName, $this->_expressButtonName . '_x', $this->_expressButtonName . '_y')) && !isset($params['is_pay_later']) && !$this->_allowWaitlist && !$this->_requireApproval) {
$this->set('contributeMode', 'express');
// Send Event Name & Id in Params
$params['eventName'] = $this->_values['event']['title'];
$params['eventId'] = $this->_values['event']['id'];
$params['cancelURL'] = CRM_Utils_System::url('civicrm/event/register', '_qf_Register_display=1', true, null, false);
if (CRM_Utils_Array::value('additional_participants', $params, false)) {
$urlArgs = "_qf_Participant_1_display=1&rfp=1&qfKey={$this->controller->_key}";
} else {
$urlArgs = '_qf_Confirm_display=1&rfp=1';
}
$params['returnURL'] = CRM_Utils_System::url('civicrm/event/register', $urlArgs, true, null, false);
$params['invoiceID'] = $invoiceID;
//default action is Sale
$params['payment_action'] = 'Sale';
$token = $payment->setExpressCheckout($params);
if (is_a($token, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($token);
CRM_Utils_System::redirect($params['cancelURL']);
}
$this->set('token', $token);
$paymentURL = $this->_paymentProcessor['url_site'] . "/cgi-bin/webscr?cmd=_express-checkout&token={$token}";
CRM_Utils_System::redirect($paymentURL);
}
} else {
if ($this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_NOTIFY) {
$this->set('contributeMode', 'notify');
}
}
} else {
$session =& CRM_Core_Session::singleton();
$contactID = $session->get('userID');
$params['description'] = ts('Online Event Registration') . ' ' . $this->_values['event']['title'];
$this->_params = array();
$this->_params[] = $params;
$this->set('params', $this->_params);
if (!CRM_Utils_Array::value('additional_participants', $params)) {
self::processRegistration($this->_params, $contactID);
}
}
// If registering > 1 participant, give status message
if (CRM_Utils_Array::value('additional_participants', $params, false)) {
require_once "CRM/Core/Session.php";
$statusMsg = ts('Registration information for participant 1 has been saved.');
CRM_Core_Session::setStatus("{$statusMsg}");
}
}
示例2: handlePreApproval
/**
* Handle pre approval for processors.
*
* This fits with the flow where a pre-approval is done and then confirmed in the next stage when confirm is hit.
*
* This function is shared between contribution & event forms & this is their common class.
*
* However, this should be seen as an in-progress refactor, the end goal being to also align the
* backoffice forms that action payments.
*
* @param array $params
*/
protected function handlePreApproval(&$params)
{
try {
$payment = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
$params['component'] = 'contribute';
$result = $payment->doPreApproval($params);
if (empty($result)) {
// This could happen, for example, when paypal looks at the button value & decides it is not paypal express.
return;
}
} catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
CRM_Core_Error::displaySessionError($e->getMessage());
CRM_Utils_System::redirect($params['cancelURL']);
}
$this->set('pre_approval_parameters', $result['pre_approval_parameters']);
if (!empty($result['redirect_url'])) {
CRM_Utils_System::redirect($result['redirect_url']);
}
}
示例3: postProcess
//.........这里部分代码省略.........
if (($this->_lineItem || !isset($params['proceSetId'])) && !$this->_paymentId && $this->_id) {
CRM_Price_BAO_LineItem::deleteLineItems($this->_id, 'civicrm_participant');
}
if ($this->_mode) {
// add all the additional payment params we need
$this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
$this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
$this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
$this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$this->_params['amount'] = $params['fee_amount'];
$this->_params['amount_level'] = $params['amount_level'];
$this->_params['currencyID'] = $config->defaultCurrency;
$this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
// at this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
if (!empty($this->_params['send_receipt'])) {
$paymentParams['email'] = $this->_contributorEmail;
}
// The only reason for merging in the 'contact_id' rather than ensuring it is set
// is that this patch is being done around the time of the stable release
// so more conservative approach is called for.
// In fact the use of $params and $this->_params & $this->_contactId vs $contactID
// needs rationalising.
$mapParams = array_merge(array('contact_id' => $contactID), $this->_params);
CRM_Core_Payment_Form::mapParams($this->_bltID, $mapParams, $paymentParams, TRUE);
$payment = $this->_paymentProcessor['object'];
// CRM-15622: fix for incorrect contribution.fee_amount
$paymentParams['fee_amount'] = NULL;
$result = $payment->doPayment($paymentParams);
if (is_a($result, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/participant', "reset=1&action=add&cid={$this->_contactId}&context=participant&mode={$this->_mode}"));
}
if ($result) {
$this->_params = array_merge($this->_params, $result);
}
$this->_params['receive_date'] = $now;
if (!empty($this->_params['send_receipt'])) {
$this->_params['receipt_date'] = $now;
} else {
$this->_params['receipt_date'] = NULL;
}
$this->set('params', $this->_params);
$this->assign('trxn_id', $result['trxn_id']);
$this->assign('receive_date', CRM_Utils_Date::processDate($this->_params['receive_date']));
//add contribution record
$this->_params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['event_id'], 'financial_type_id');
$this->_params['mode'] = $this->_mode;
//add contribution record
$contributions[] = $contribution = CRM_Event_Form_Registration_Confirm::processContribution($this, $this->_params, $result, $contactID, FALSE);
// add participant record
$participants = array();
if (!empty($this->_params['role_id']) && is_array($this->_params['role_id'])) {
$this->_params['role_id'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_params['role_id']);
}
//CRM-15372 patch to fix fee amount replacing amount
$this->_params['fee_amount'] = $this->_params['amount'];
$participants[] = CRM_Event_Form_Registration::addParticipant($this, $contactID);
//add custom data for participant
CRM_Core_BAO_CustomValueTable::postProcess($this->_params, 'civicrm_participant', $participants[0]->id, 'Participant');
//add participant payment
$paymentParticipant = array('participant_id' => $participants[0]->id, 'contribution_id' => $contribution->id);
$ids = array();
示例4: postProcess
//.........这里部分代码省略.........
}
$contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $this->_contactID, null, null, $ctype);
}
// build custom data getFields array
$customFieldsRole = CRM_Core_BAO_CustomField::getFields('Participant', false, false, CRM_Utils_Array::value('role_id', $params), $this->_roleCustomDataTypeID);
$customFieldsEvent = CRM_Core_BAO_CustomField::getFields('Participant', false, false, CRM_Utils_Array::value('event_id', $params), $this->_eventNameCustomDataTypeID);
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsRole, CRM_Core_BAO_CustomField::getFields('Participant', false, false, null, null, true));
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsEvent, $customFields);
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_participantId, 'Participant');
if ($this->_mode) {
// add all the additioanl payment params we need
$this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
$this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
$this->_params['year'] = $this->_params['credit_card_exp_date']['Y'];
$this->_params['month'] = $this->_params['credit_card_exp_date']['M'];
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$this->_params['amount'] = $params['fee_amount'];
$this->_params['amount_level'] = $params['amount_level'];
$this->_params['currencyID'] = $config->defaultCurrency;
$this->_params['payment_action'] = 'Sale';
$this->_params['invoiceID'] = md5(uniqid(rand(), true));
// at this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
if (CRM_Utils_Array::value('send_receipt', $this->_params)) {
$paymentParams['email'] = $this->_contributorEmail;
}
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, true);
$payment =& CRM_Core_Payment::singleton($this->_mode, 'Event', $this->_paymentProcessor, $this);
$result =& $payment->doDirectPayment($paymentParams);
if (is_a($result, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/participant', "reset=1&action=add&cid={$this->_contactID}&context=participant&mode={$this->_mode}"));
}
if ($result) {
$this->_params = array_merge($this->_params, $result);
}
$this->_params['receive_date'] = $now;
if (CRM_Utils_Array::value('send_receipt', $this->_params)) {
$this->_params['receipt_date'] = $now;
} else {
$this->_params['receipt_date'] = null;
}
$this->set('params', $this->_params);
$this->assign('trxn_id', $result['trxn_id']);
$this->assign('receive_date', CRM_Utils_Date::processDate($this->_params['receive_date']));
// set source if not set
$this->_params['description'] = ts('Submit Credit Card for Event Registration by: %1', array(1 => $userName));
require_once 'CRM/Event/Form/Registration/Confirm.php';
require_once 'CRM/Event/Form/Registration.php';
//add contribution record
$this->_params['contribution_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['event_id'], 'contribution_type_id');
$this->_params['mode'] = $this->_mode;
//add contribution reocord
$contribution = CRM_Event_Form_Registration_Confirm::processContribution($this, $this->_params, $result, $contactID, false);
// add participant record
$participants = array();
$participants[] = CRM_Event_Form_Registration::addParticipant($this->_params, $contactID);
//add custom data for participant
require_once 'CRM/Core/BAO/CustomValueTable.php';
CRM_Core_BAO_CustomValueTable::postProcess($this->_params, CRM_Core_DAO::$_nullArray, 'civicrm_participant', $participants[0]->id, 'Participant');
//add participant payment
require_once 'CRM/Event/BAO/ParticipantPayment.php';
$paymentParticipant = array('participant_id' => $participants[0]->id, 'contribution_id' => $contribution->id);
示例5: processConfirm
//.........这里部分代码省略.........
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
require_once 'CRM/Contribute/BAO/ContributionPage.php';
$form->_values['contribution_id'] = $contribution->id;
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test);
return;
}
}
}
} elseif ($form->_contributeMode == 'express') {
if ($form->_values['is_monetary'] && $form->_amount > 0.0) {
//LCD determine if express + recurring and direct accordingly
if ($paymentParams['is_recur'] == 1) {
$result =& $payment->createRecurringPayments($paymentParams);
} else {
$result =& $payment->doExpressCheckout($paymentParams);
}
}
} elseif ($form->_values['is_monetary'] && $form->_amount > 0.0) {
if ($paymentParams['is_recur'] && $form->_contributeMode == 'direct') {
// For recurring contribution, create Contribution Record first.
// Contribution ID, Recurring ID and Contact ID needed
// When we get a callback from the payment processor
$paymentParams['contactID'] = $contactID;
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $paymentParams, null, $contactID, $contributionType, true, true, true);
$paymentParams['contributionID'] = $contribution->id;
$paymentParams['contributionTypeID'] = $contribution->contribution_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
if ($form->_values['is_recur'] && $contribution->contribution_recur_id) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
}
$result =& $payment->doDirectPayment($paymentParams);
}
if ($component == 'membership') {
$membershipResult = array();
}
if (is_a($result, 'CRM_Core_Error')) {
//make sure to cleanup db for recurring case.
if (CRM_Utils_Array::value('contributionID', $paymentParams)) {
CRM_Contribute_BAO_Contribution::deleteContribution($paymentParams['contributionID']);
}
if (CRM_Utils_Array::value('contributionRecurID', $paymentParams)) {
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
if ($component !== 'membership') {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Main_display=true&qfKey={$form->_params['qfKey']}"));
}
$membershipResult[1] = $result;
} else {
if ($result) {
$form->_params = array_merge($form->_params, $result);
}
$form->_params['receive_date'] = $now;
$form->set('params', $form->_params);
$form->assign('trxn_id', $result['trxn_id']);
$form->assign('receive_date', CRM_Utils_Date::mysqlToIso($form->_params['receive_date']));
// result has all the stuff we need
// lets archive it to a financial transaction
if ($contributionType->is_deductible) {
$form->assign('is_deductible', true);
$form->set('is_deductible', true);
}
if (isset($paymentParams['contribution_source'])) {
$form->_params['source'] = $paymentParams['contribution_source'];
}
// check if pending was set to true by payment processor
$pending = false;
if (CRM_Utils_Array::value('contribution_status_pending', $form->_params)) {
$pending = true;
}
if (!($paymentParams['is_recur'] && $form->_contributeMode == 'direct')) {
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $form->_params, $result, $contactID, $contributionType, true, $pending, true);
}
$form->postProcessPremium($premiumParams, $contribution);
$membershipResult[1] = $contribution;
}
if ($component == 'membership') {
return $membershipResult;
}
//Do not send an email if Recurring contribution is done via Direct Mode
//Email will we send once the IPN will receive.
if ($paymentParams['is_recur'] && $form->_contributeMode == 'direct') {
return true;
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
// finally send an email receipt
require_once 'CRM/Contribute/BAO/ContributionPage.php';
$form->_values['contribution_id'] = $contribution->id;
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test);
}
示例6: submit
//.........这里部分代码省略.........
$financialType->id = $params['financial_type_id'];
$financialType->find(TRUE);
$this->_params = $formValues;
$contribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution($this, $paymentParams, NULL, array('contact_id' => $this->_contributorContactID, 'line_item' => $lineItem, 'is_test' => $isTest, 'campaign_id' => CRM_Utils_Array::value('campaign_id', $paymentParams), 'contribution_page_id' => CRM_Utils_Array::value('contribution_page_id', $formValues), 'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)), 'thankyou_date' => CRM_Utils_Array::value('thankyou_date', $paymentParams), 'payment_instrument_id' => $this->_paymentProcessor['payment_instrument_id']), $financialType, TRUE, FALSE, $this->_bltID);
//create new soft-credit record, CRM-13981
if ($softParams) {
$softParams['contribution_id'] = $contribution->id;
$softParams['currency'] = $contribution->currency;
$softParams['amount'] = $contribution->total_amount;
CRM_Contribute_BAO_ContributionSoft::add($softParams);
}
$paymentParams['contactID'] = $this->_contactID;
$paymentParams['contributionID'] = $contribution->id;
$paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
$ids['contribution'] = $contribution->id;
$params['contribution_recur_id'] = $paymentParams['contributionRecurID'];
}
if ($params['total_amount'] > 0.0) {
$payment = $this->_paymentProcessor['object'];
try {
$result = $payment->doPayment($paymentParams);
$formValues = array_merge($formValues, $result);
// Assign amount to template if payment was successful.
$this->assign('amount', $params['total_amount']);
} catch (PaymentProcessorException $e) {
if (!empty($paymentParams['contributionID'])) {
CRM_Contribute_BAO_Contribution::failPayment($paymentParams['contributionID'], $this->_contactID, $e->getMessage());
}
if (!empty($paymentParams['contributionRecurID'])) {
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=add&cid={$this->_contactID}&context=&mode={$this->_mode}"));
}
}
if ($formValues['payment_status_id'] != array_search('Completed', $allContributionStatus)) {
$params['status_id'] = array_search('Pending', $allMemberStatus);
$params['skipStatusCal'] = TRUE;
// unset send-receipt option, since receipt will be sent when ipn is received.
unset($formValues['send_receipt'], $formValues['send_receipt']);
//as membership is pending set dates to null.
$memberDates = array('join_date' => 'joinDate', 'start_date' => 'startDate', 'end_date' => 'endDate');
foreach ($memberDates as $dv) {
${$dv} = NULL;
foreach ($this->_memTypeSelected as $memType) {
$membershipTypeValues[$memType][$dv] = NULL;
}
}
}
$params['receive_date'] = $now;
$params['invoice_id'] = $formValues['invoiceID'];
$params['contribution_source'] = ts('%1 Membership Signup: Credit card or direct debit (by %2)', array(1 => $membershipType, 2 => $userName));
$params['source'] = $formValues['source'] ? $formValues['source'] : $params['contribution_source'];
$params['trxn_id'] = CRM_Utils_Array::value('trxn_id', $result);
$params['payment_instrument_id'] = 1;
$params['is_test'] = $this->_mode == 'live' ? 0 : 1;
if (!empty($formValues['send_receipt'])) {
$params['receipt_date'] = $now;
} else {
$params['receipt_date'] = NULL;
}
$this->set('params', $formValues);
$this->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $result));
$this->assign('receive_date', CRM_Utils_Date::mysqlToIso($params['receive_date']));
示例7: processCreditCard
//.........这里部分代码省略.........
$this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
if ($this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_CREDIT_CARD) {
$this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
$this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
}
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$this->_params['amount'] = $this->_params['total_amount'];
// @todo - stop setting amount level in this function & call the CRM_Price_BAO_PriceSet::getAmountLevel
// function to get correct amount level consistently. Remove setting of the amount level in
// CRM_Price_BAO_PriceSet::processAmount. Extend the unit tests in CRM_Price_BAO_PriceSetTest
// to cover all variants.
$this->_params['amount_level'] = 0;
$this->_params['currencyID'] = CRM_Utils_Array::value('currency', $this->_params, $config->defaultCurrency);
if (!empty($this->_params['trxn_date'])) {
$this->_params['receive_date'] = CRM_Utils_Date::processDate($this->_params['trxn_date'], $this->_params['trxn_date_time']);
}
if (empty($this->_params['invoice_id'])) {
$this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
} else {
$this->_params['invoiceID'] = $this->_params['invoice_id'];
}
$this->assignBillingName($params);
$this->assign('address', CRM_Utils_Address::getFormattedBillingAddressFieldsFromParameters($params, $this->_bltID));
$date = CRM_Utils_Date::format($params['credit_card_exp_date']);
$date = CRM_Utils_Date::mysqlToIso($date);
$this->assign('credit_card_type', CRM_Utils_Array::value('credit_card_type', $params));
$this->assign('credit_card_exp_date', $date);
$this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($params['credit_card_number']));
//Add common data to formatted params
CRM_Contribute_Form_AdditionalInfo::postProcessCommon($params, $this->_params, $this);
// at this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
$paymentParams['contactID'] = $this->_contactId;
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, TRUE);
// add some financial type details to the params list
// if folks need to use it
$paymentParams['contributionType_name'] = $this->_params['contributionType_name'] = $contributionType->name;
$paymentParams['contributionPageID'] = NULL;
if (!empty($this->_params['is_email_receipt'])) {
$paymentParams['email'] = $this->_contributorEmail;
$paymentParams['is_email_receipt'] = 1;
} else {
$paymentParams['is_email_receipt'] = 0;
$this->_params['is_email_receipt'] = 0;
}
if (!empty($this->_params['receive_date'])) {
$paymentParams['receive_date'] = $this->_params['receive_date'];
}
if (!empty($this->_params['receive_date'])) {
$paymentParams['receive_date'] = $this->_params['receive_date'];
}
$result = NULL;
if ($paymentParams['amount'] > 0.0) {
try {
// force a reget of the payment processor in case the form changed it, CRM-7179
$payment = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
$result = $payment->doPayment($paymentParams);
} catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
//set the contribution mode.
$urlParams = "action=add&cid={$this->_contactId}&id={$this->_id}&component={$this->_component}";
if ($this->_mode) {
$urlParams .= "&mode={$this->_mode}";
}
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/payment/add', $urlParams));
}
}
if ($result) {
$this->_params = array_merge($this->_params, $result);
}
if (empty($this->_params['receive_date'])) {
$this->_params['receive_date'] = $now;
}
$this->set('params', $this->_params);
// set source if not set
if (empty($this->_params['source'])) {
$userID = $session->get('userID');
$userSortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $userID, 'sort_name');
$this->_params['source'] = ts('Submit Credit Card Payment by: %1', array(1 => $userSortName));
}
// process the additional payment
$participantId = NULL;
if ($this->_component == 'event') {
$participantId = $this->_id;
}
$trxnRecord = CRM_Contribute_BAO_Contribution::recordAdditionalPayment($this->_contributionId, $submittedValues, $this->_paymentType, $participantId);
if ($trxnRecord->id && !empty($this->_params['is_email_receipt'])) {
$sendReceipt = $this->emailReceipt($this->_params);
}
if ($trxnRecord->id) {
$statusMsg = ts('The payment record has been processed.');
if (!empty($this->_params['is_email_receipt']) && $sendReceipt) {
$statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
}
CRM_Core_Session::setStatus($statusMsg, ts('Complete'), 'success');
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactId}&selectedChild=participant"));
}
}
示例8: processCreditCard
//.........这里部分代码省略.........
if (!empty($this->_params['receive_date'])) {
$paymentParams['receive_date'] = $this->_params['receive_date'];
}
// For recurring contribution, create Contribution Record first.
// Contribution ID, Recurring ID and Contact ID needed
// When we get a callback from the payment processor, CRM-7115
if (!empty($paymentParams['is_recur'])) {
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($this, $this->_params, NULL, $this->_contactID, $contributionType, TRUE, FALSE, $isTest, $this->_lineItem);
$paymentParams['contributionID'] = $contribution->id;
$paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
$result = NULL;
if ($paymentParams['amount'] > 0.0) {
// force a re-get of the payment processor in case the form changed it, CRM-7179
$payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this, TRUE);
$result = $payment->doDirectPayment($paymentParams);
}
if (is_a($result, 'CRM_Core_Error')) {
//make sure to cleanup db for recurring case.
if (!empty($paymentParams['contributionID'])) {
CRM_Core_Error::debug_log_message(CRM_Core_Error::getMessages($result) . "contact id={$this->_contactID} (deleting contribution {$paymentParams['contributionID']}");
CRM_Contribute_BAO_Contribution::deleteContribution($paymentParams['contributionID']);
}
if (!empty($paymentParams['contributionRecurID'])) {
CRM_Core_Error::debug_log_message(CRM_Core_Error::getMessages($result) . "contact id={$this->_contactID} (deleting recurring contribution {$paymentParams['contributionRecurID']}");
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
//set the contribution mode.
$urlParams = "action=add&cid={$this->_contactID}";
if ($this->_mode) {
$urlParams .= "&mode={$this->_mode}";
}
if (!empty($this->_ppID)) {
$urlParams .= "&context=pledge&ppid={$this->_ppID}";
}
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/contribution', $urlParams));
}
if ($result) {
$this->_params = array_merge($this->_params, $result);
}
$this->_params['receive_date'] = $now;
if (!empty($this->_params['is_email_receipt'])) {
$this->_params['receipt_date'] = $now;
} else {
$this->_params['receipt_date'] = CRM_Utils_Date::processDate($this->_params['receipt_date'], $params['receipt_date_time'], TRUE);
}
$this->set('params', $this->_params);
$this->assign('trxn_id', $result['trxn_id']);
$this->assign('receive_date', $this->_params['receive_date']);
// result has all the stuff we need
// lets archive it to a financial transaction
if ($contributionType->is_deductible) {
$this->assign('is_deductible', TRUE);
$this->set('is_deductible', TRUE);
}
// set source if not set
if (empty($this->_params['source'])) {
$userID = $session->get('userID');
$userSortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $userID, 'sort_name');
$this->_params['source'] = ts('Submit Credit Card Payment by: %1', array(1 => $userSortName));
}
// build custom data getFields array
$customFieldsContributionType = CRM_Core_BAO_CustomField::getFields('Contribution', FALSE, FALSE, CRM_Utils_Array::value('financial_type_id', $params));
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsContributionType, CRM_Core_BAO_CustomField::getFields('Contribution', FALSE, FALSE, NULL, NULL, TRUE));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_id, 'Contribution');
if (empty($paymentParams['is_recur'])) {
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($this, $this->_params, $result, $this->_contactID, $contributionType, FALSE, FALSE, $isTest, $this->_lineItem);
}
//send receipt mail.
if ($contribution->id && !empty($this->_params['is_email_receipt'])) {
$this->_params['trxn_id'] = CRM_Utils_Array::value('trxn_id', $result);
$this->_params['contact_id'] = $this->_contactID;
$this->_params['contribution_id'] = $contribution->id;
$sendReceipt = CRM_Contribute_Form_AdditionalInfo::emailReceipt($this, $this->_params, TRUE);
}
//process the note
if ($contribution->id && isset($params['note'])) {
CRM_Contribute_Form_AdditionalInfo::processNote($params, $contactID, $contribution->id, NULL);
}
//process premium
if ($contribution->id && isset($params['product_name'][0])) {
CRM_Contribute_Form_AdditionalInfo::processPremium($params, $contribution->id, NULL, $this->_options);
}
//update pledge payment status.
if ($this->_ppID && $contribution->id) {
//store contribution id in payment record.
CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', $this->_ppID, 'contribution_id', $contribution->id);
CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($this->_pledgeID, array($this->_ppID), $contribution->contribution_status_id, NULL, $contribution->total_amount);
}
if ($contribution->id) {
$statusMsg = ts('The contribution record has been processed.');
if (!empty($this->_params['is_email_receipt']) && $sendReceipt) {
$statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
}
CRM_Core_Session::setStatus($statusMsg, ts('Complete'), 'success');
}
}
示例9: postProcess
/**
* Function to process the renewal form
*
* @access public
* @return None
*/
public function postProcess()
{
require_once 'CRM/Member/BAO/Membership.php';
require_once 'CRM/Member/BAO/MembershipType.php';
require_once 'CRM/Member/BAO/MembershipStatus.php';
// get the submitted form values.
$this->_params = $formValues = $this->controller->exportValues($this->_name);
$params = array();
$ids = array();
$config =& CRM_Core_Config::singleton();
$params['contact_id'] = $this->_contactID;
if ($this->_mode) {
$formValues['total_amount'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'minimum_fee');
$formValues['contribution_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'contribution_type_id');
require_once 'CRM/Core/BAO/PaymentProcessor.php';
$this->_paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($formValues['payment_processor_id'], $this->_mode);
require_once "CRM/Contact/BAO/Contact.php";
$now = CRM_Utils_Date::getToday($now, 'YmdHis');
$fields = array();
// set email for primary location.
$fields["email-Primary"] = 1;
$formValues["email-5"] = $formValues["email-Primary"] = $this->_contributorEmail;
$formValues['register_date'] = $now;
// now set the values for the billing location.
foreach ($this->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
// also add location name to the array
$formValues["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_middle_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_last_name', $formValues);
$formValues["address_name-{$this->_bltID}"] = trim($formValues["address_name-{$this->_bltID}"]);
$fields["address_name-{$this->_bltID}"] = 1;
$fields["email-{$this->_bltID}"] = 1;
$ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactID, 'contact_type');
$nameFields = array('first_name', 'middle_name', 'last_name');
foreach ($nameFields as $name) {
$fields[$name] = 1;
if (array_key_exists("billing_{$name}", $formValues)) {
$formValues[$name] = $formValues["billing_{$name}"];
$formValues['preserveDBName'] = true;
}
}
$contactID = CRM_Contact_BAO_Contact::createProfileContact($formValues, $fields, $this->_contactID, null, null, $ctype);
// add all the additioanl payment params we need
$this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
$this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
$this->_params['year'] = $this->_params['credit_card_exp_date']['Y'];
$this->_params['month'] = $this->_params['credit_card_exp_date']['M'];
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$this->_params['amount'] = $formValues['total_amount'];
$this->_params['currencyID'] = $config->defaultCurrency;
$this->_params['payment_action'] = 'Sale';
$this->_params['invoiceID'] = md5(uniqid(rand(), true));
// at this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
if (CRM_Utils_Array::value('send_receipt', $this->_params)) {
$paymentParams['email'] = $this->_contributorEmail;
}
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, true);
$payment =& CRM_Core_Payment::singleton($this->_mode, 'Contribute', $this->_paymentProcessor, $this);
$result =& $payment->doDirectPayment($paymentParams);
if (is_a($result, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$this->_id}&context=membership&mode={$this->_mode}"));
}
if ($result) {
$this->_params = array_merge($this->_params, $result);
}
$formValues['contribution_status_id'] = 1;
$formValues['receive_date'] = $now;
$formValues['invoice_id'] = $this->_params['invoiceID'];
$formValues['trxn_id'] = $result['trxn_id'];
$formValues['payment_instrument_id'] = 1;
$formValues['is_test'] = $this->_mode == 'live' ? 0 : 1;
if (CRM_Utils_Array::value('send_receipt', $this->_params)) {
$formValues['receipt_date'] = $now;
} else {
$formValues['receipt_date'] = null;
}
$this->set('params', $this->_params);
$this->assign('trxn_id', $result['trxn_id']);
$this->assign('receive_date', CRM_Utils_Date::mysqlToIso($formValues['receive_date']));
}
$renewalDate = null;
if ($formValues['renewal_date']) {
$this->set('renewDate', CRM_Utils_Date::processDate($formValues['renewal_date']));
}
$this->_membershipId = $this->_id;
// check for test membership.
$isTestMembership = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_membershipId, 'is_test');
$renewMembership = CRM_Member_BAO_Membership::renewMembership($this->_contactID, $this->_memType, $isTestMembership, $this, null);
$endDate = CRM_Utils_Date::processDate($renewMembership->end_date);
//.........这里部分代码省略.........
示例10: make_payment
/**
* @param array $params
*
* @return array|void
* @throws Exception
*/
public function make_payment(&$params)
{
$config = CRM_Core_Config::singleton();
if (isset($params["billing_state_province_id-{$this->_bltID}"]) && $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-{$this->_bltID}"]) && $params["billing_country_id-{$this->_bltID}"]) {
$params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($params["billing_country_id-{$this->_bltID}"]);
}
$params['ip_address'] = CRM_Utils_System::ipAddress();
$params['currencyID'] = $config->defaultCurrency;
$payment = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
CRM_Core_Payment_Form::mapParams($this->_bltID, $params, $params, TRUE);
$params['month'] = $params['credit_card_exp_date']['M'];
$params['year'] = $params['credit_card_exp_date']['Y'];
try {
$result = $payment->doPayment($params);
} catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/cart_checkout', "_qf_Payment_display=1&qfKey={$this->controller->_key}", TRUE, NULL, FALSE));
}
$trxnDetails = array('trxn_id' => $result['trxn_id'], 'trxn_date' => $result['now'], 'currency' => CRM_Utils_Array::value('currencyID', $result));
return $trxnDetails;
}
示例11: postProcess
//.........这里部分代码省略.........
//get the participant statuses.
$waitingStatuses = CRM_Event_PseudoConstant::participantStatus(null, "class = 'Waiting'");
if ($this->_allowWaitlist) {
$value['participant_status_id'] = array_search('On waitlist', $waitingStatuses);
} else {
$value['participant_status_id'] = array_search('Awaiting approval', $waitingStatuses);
}
//there might be case user seleted pay later and
//now becomes part of run time waiting list.
$value['is_pay_later'] = false;
} else {
if (CRM_Utils_Array::value('is_pay_later', $value) || $value['amount'] == 0 || $this->_contributeMode == 'checkout' || $this->_contributeMode == 'notify') {
if ($value['amount'] != 0) {
$pending = true;
//get the participant statuses.
require_once 'CRM/Event/PseudoConstant.php';
$pendingStatuses = CRM_Event_PseudoConstant::participantStatus(null, "class = 'Pending'");
$status = CRM_Utils_Array::value('is_pay_later', $value) ? 'Pending from pay later' : 'Pending from incomplete transaction';
$value['participant_status_id'] = array_search($status, $pendingStatuses);
}
} else {
if ($this->_contributeMode == 'express' && CRM_Utils_Array::value('is_primary', $value)) {
$result =& $payment->doExpressCheckout($value);
} else {
if (CRM_Utils_Array::value('is_primary', $value)) {
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::mapParams($this->_bltID, $value, $value, true);
$result =& $payment->doDirectPayment($value);
}
}
}
}
if (is_a($result, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/register', "id={$this->_eventId}"));
}
if ($result) {
$value = array_merge($value, $result);
}
$value['receive_date'] = $now;
if ($this->_allowConfirmation) {
$value['participant_register_date'] = $this->_values['participant']['register_date'];
}
$createContrib = $value['amount'] != 0 ? true : false;
// force to create zero amount contribution, CRM-5095
if (!$createContrib && $value['amount'] == 0 && $this->_priceSetId && $this->_lineItem) {
$createContrib = true;
}
if ($createContrib && CRM_Utils_Array::value('is_primary', $value) && !$this->_allowWaitlist && !$this->_requireApproval) {
// if paid event add a contribution record
//if primary participant contributing additional amount
//append (multiple participants) to its fee level. CRM-4196.
$isAdditionalAmount = false;
if (count($params) > 1) {
$isAdditionalAmount = true;
}
//passing contribution id is already registered.
$contribution =& self::processContribution($this, $value, $result, $contactID, $pending, $isAdditionalAmount);
$value['contributionID'] = $contribution->id;
$value['contributionTypeID'] = $contribution->contribution_type_id;
$value['receive_date'] = $contribution->receive_date;
$value['trxn_id'] = $contribution->trxn_id;
$value['contributionID'] = $contribution->id;
$value['contributionTypeID'] = $contribution->contribution_type_id;
}
$value['contactID'] = $contactID;
示例12: postProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
public function postProcess()
{
$status = $message = NULL;
$cancelSubscription = TRUE;
$params = $this->controller->exportValues($this->_name);
if ($this->_selfService) {
// for self service force sending-request & notify
if ($this->_paymentProcessorObj->isSupported('cancelSubscription')) {
$params['send_cancel_request'] = 1;
}
if ($this->_donorEmail) {
$params['is_notify'] = 1;
}
}
if (CRM_Utils_Array::value('send_cancel_request', $params) == 1) {
$cancelParams = array('subscriptionId' => $this->_subscriptionDetails->subscription_id);
$cancelSubscription = $this->_paymentProcessorObj->cancelSubscription($message, $cancelParams);
}
if (is_a($cancelSubscription, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($cancelSubscription);
} elseif ($cancelSubscription) {
$activityParams = array('subject' => $this->_mid ? ts('Auto-renewal membership cancelled') : ts('Recurring contribution cancelled'), 'details' => $message);
$cancelStatus = CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution($this->_subscriptionDetails->recur_id, CRM_Core_DAO::$_nullObject, $activityParams);
if ($cancelStatus) {
$tplParams = array();
if ($this->_mid) {
$inputParams = array('id' => $this->_mid);
CRM_Member_BAO_Membership::getValues($inputParams, $tplParams);
$tplParams = $tplParams[$this->_mid];
$tplParams['membership_status'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $tplParams['status_id']);
$tplParams['membershipType'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $tplParams['membership_type_id']);
$status = ts('The automatic renewal of your %1 membership has been cancelled as requested. This does not affect the status of your membership - you will receive a separate notification when your membership is up for renewal.', array(1 => $tplParams['membershipType']));
$msgTitle = 'Membership Renewal Cancelled';
$msgType = 'info';
} else {
$tplParams['recur_frequency_interval'] = $this->_subscriptionDetails->frequency_interval;
$tplParams['recur_frequency_unit'] = $this->_subscriptionDetails->frequency_unit;
$tplParams['amount'] = $this->_subscriptionDetails->amount;
$tplParams['contact'] = array('display_name' => $this->_donorDisplayName);
$status = ts('The recurring contribution of %1, every %2 %3 has been cancelled.', array(1 => $this->_subscriptionDetails->amount, 2 => $this->_subscriptionDetails->frequency_interval, 3 => $this->_subscriptionDetails->frequency_unit));
$msgTitle = 'Contribution Cancelled';
$msgType = 'success';
}
if (CRM_Utils_Array::value('is_notify', $params) == 1) {
if ($this->_subscriptionDetails->contribution_page_id) {
CRM_Core_DAO::commonRetrieveAll('CRM_Contribute_DAO_ContributionPage', 'id', $this->_subscriptionDetails->contribution_page_id, $value, array('title', 'receipt_from_name', 'receipt_from_email'));
$receiptFrom = '"' . CRM_Utils_Array::value('receipt_from_name', $value[$this->_subscriptionDetails->contribution_page_id]) . '" <' . $value[$this->_subscriptionDetails->contribution_page_id]['receipt_from_email'] . '>';
} else {
$domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
$receiptFrom = "{$domainValues['0']} <{$domainValues['1']}>";
}
// send notification
$sendTemplateParams = array('groupName' => $this->_mode == 'auto_renew' ? 'msg_tpl_workflow_membership' : 'msg_tpl_workflow_contribution', 'valueName' => $this->_mode == 'auto_renew' ? 'membership_autorenew_cancelled' : 'contribution_recurring_cancelled', 'contactId' => $this->_subscriptionDetails->contact_id, 'tplParams' => $tplParams, 'PDFFilename' => 'receipt.pdf', 'from' => $receiptFrom, 'toName' => $this->_donorDisplayName, 'toEmail' => $this->_donorEmail);
list($sent) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
}
} else {
$msgType = 'error';
$msgTitle = ts('Error');
if ($params['send_cancel_request'] == 1) {
$status = ts('Recurring contribution was cancelled successfully by the processor, but could not be marked as cancelled in the database.');
} else {
$status = ts('Recurring contribution could not be cancelled in the database.');
}
}
} else {
$status = ts('The recurring contribution could not be cancelled.');
$msgTitle = 'Error Cancelling Contribution';
$msgType = 'error';
}
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
if ($userID && $status) {
$session->setStatus($status, $msgTitle, $msgType);
} elseif (!$userID) {
if ($status) {
CRM_Utils_System::setUFMessage($status);
}
// keep result as 1, since we not displaying anything on the redirected page anyway
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/subscriptionstatus', "reset=1&task=cancel&result=1"));
}
}
示例13: handlePreApproval
/**
* Handle pre approval for processors.
*
* This fits with the flow where a pre-approval is done and then confirmed in the next stage when confirm is hit.
*
* This applies to processors that
* @param array $params
*/
protected function handlePreApproval(&$params)
{
try {
$payment = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
$result = $payment->doPreApproval($params);
} catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
CRM_Core_Error::displaySessionError($e->getMessage());
CRM_Utils_System::redirect($params['cancelURL']);
}
$this->set('pre_approval_parameters', $result['pre_approval_parameters']);
if (!empty($result['redirect_url'])) {
CRM_Utils_System::redirect($result['redirect_url']);
}
}
示例14: processConfirm
//.........这里部分代码省略.........
} elseif ($form->_contributeMode == 'express') {
if ($form->_values['is_monetary'] && $form->_amount > 0.0) {
// determine if express + recurring and direct accordingly
if ($paymentParams['is_recur'] == 1) {
if (is_object($payment)) {
$result = $payment->createRecurringPayments($paymentParams);
} else {
CRM_Core_Error::fatal($paymentObjError);
}
} else {
if (is_object($payment)) {
$result = $payment->doExpressCheckout($paymentParams);
} else {
CRM_Core_Error::fatal($paymentObjError);
}
}
}
} elseif ($form->_values['is_monetary'] && $form->_amount > 0.0) {
if (!empty($paymentParams['is_recur']) && $form->_contributeMode == 'direct') {
// For recurring contribution, create Contribution Record first.
// Contribution ID, Recurring ID and Contact ID needed
// When we get a callback from the payment processor
$paymentParams['contactID'] = $contactID;
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $paymentParams, NULL, $contactID, $contributionType, TRUE, TRUE, TRUE);
$paymentParams['contributionID'] = $contribution->id;
$paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
if ($form->_values['is_recur'] && $contribution->contribution_recur_id) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
}
if (is_object($payment)) {
$result = $payment->doDirectPayment($paymentParams);
} else {
CRM_Core_Error::fatal($paymentObjError);
}
}
if ($component == 'membership') {
$membershipResult = array();
}
if (is_a($result, 'CRM_Core_Error')) {
//make sure to cleanup db for recurring case.
if (!empty($paymentParams['contributionID'])) {
CRM_Contribute_BAO_Contribution::deleteContribution($paymentParams['contributionID']);
}
if (!empty($paymentParams['contributionRecurID'])) {
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
if ($component !== 'membership') {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Main_display=true&qfKey={$form->_params['qfKey']}"));
}
$membershipResult[1] = $result;
} elseif ($result || $form->_amount == 0.0 && !$form->_params['is_pay_later']) {
if ($result) {
$form->_params = array_merge($form->_params, $result);
}
$form->_params['receive_date'] = $now;
$form->set('params', $form->_params);
$form->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $result));
$form->assign('receive_date', CRM_Utils_Date::mysqlToIso($form->_params['receive_date']));
// result has all the stuff we need
// lets archive it to a financial transaction
if ($contributionType->is_deductible) {
$form->assign('is_deductible', TRUE);
$form->set('is_deductible', TRUE);
}
if (isset($paymentParams['contribution_source'])) {
$form->_params['source'] = $paymentParams['contribution_source'];
}
// check if pending was set to true by payment processor
$pending = FALSE;
if (!empty($form->_params['contribution_status_pending'])) {
$pending = TRUE;
}
if (!(!empty($paymentParams['is_recur']) && $form->_contributeMode == 'direct')) {
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $form->_params, $result, $contactID, $contributionType, TRUE, $pending, TRUE);
}
$form->postProcessPremium($premiumParams, $contribution);
$membershipResult[1] = $contribution;
}
if ($component == 'membership') {
return $membershipResult;
}
//Do not send an email if Recurring contribution is done via Direct Mode
//We will send email once the IPN is received.
if (!empty($paymentParams['is_recur']) && $form->_contributeMode == 'direct') {
return TRUE;
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
// finally send an email receipt
if ($contribution) {
$form->_values['contribution_id'] = $contribution->id;
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test, FALSE, $fieldTypes);
}
}
示例15: postProcess
//.........这里部分代码省略.........
}
$config = CRM_Core_Config::singleton();
$params['currencyID'] = $config->defaultCurrency;
if ($this->_values['event']['is_monetary']) {
// we first reset the confirm page so it accepts new values
$this->controller->resetPage('Confirm');
//added for discount
$discountId = CRM_Core_BAO_Discount::findSet($this->_eventId, 'civicrm_event');
if (!empty($this->_values['discount'][$discountId])) {
$params['discount_id'] = $discountId;
$params['amount_level'] = $this->_values['discount'][$discountId][$params['amount']]['label'];
$params['amount'] = $this->_values['discount'][$discountId][$params['amount']]['value'];
} elseif (empty($params['priceSetId'])) {
if (!empty($params['amount'])) {
$params['amount_level'] = $this->_values['fee'][$params['amount']]['label'];
$params['amount'] = $this->_values['fee'][$params['amount']]['value'];
} else {
$params['amount_level'] = $params['amount'] = '';
}
} else {
$lineItem = array();
CRM_Price_BAO_PriceSet::processAmount($this->_values['fee'], $params, $lineItem);
$this->set('lineItem', array($lineItem));
$this->set('lineItemParticipantsCount', array($primaryParticipantCount));
}
$this->set('amount', $params['amount']);
$this->set('amount_level', $params['amount_level']);
// generate and set an invoiceID for this transaction
$invoiceID = md5(uniqid(rand(), TRUE));
$this->set('invoiceID', $invoiceID);
if (is_array($this->_paymentProcessor)) {
$payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
}
// default mode is direct
$this->set('contributeMode', 'direct');
if (isset($params["state_province_id-{$this->_bltID}"]) && $params["state_province_id-{$this->_bltID}"]) {
$params["state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($params["state_province_id-{$this->_bltID}"]);
}
if (isset($params["country_id-{$this->_bltID}"]) && $params["country_id-{$this->_bltID}"]) {
$params["country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($params["country_id-{$this->_bltID}"]);
}
if (isset($params['credit_card_exp_date'])) {
$params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($params);
$params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($params);
}
if ($this->_values['event']['is_monetary']) {
$params['ip_address'] = CRM_Utils_System::ipAddress();
$params['currencyID'] = $config->defaultCurrency;
$params['payment_action'] = 'Sale';
$params['invoiceID'] = $invoiceID;
}
$this->_params = array();
$this->_params[] = $params;
$this->set('params', $this->_params);
if ($this->_paymentProcessor && $this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON) {
//get the button name
$buttonName = $this->controller->getButtonName();
if (in_array($buttonName, array($this->_expressButtonName, $this->_expressButtonName . '_x', $this->_expressButtonName . '_y')) && !CRM_Utils_Array::value('is_pay_later', $params) && !$this->_allowWaitlist && !$this->_requireApproval) {
$this->set('contributeMode', 'express');
// Send Event Name & Id in Params
$params['eventName'] = $this->_values['event']['title'];
$params['eventId'] = $this->_values['event']['id'];
$params['cancelURL'] = CRM_Utils_System::url('civicrm/event/register', "_qf_Register_display=1&qfKey={$this->controller->_key}", TRUE, NULL, FALSE);
if (CRM_Utils_Array::value('additional_participants', $params, FALSE)) {
$urlArgs = "_qf_Participant_1_display=1&rfp=1&qfKey={$this->controller->_key}";
} else {
$urlArgs = "_qf_Confirm_display=1&rfp=1&qfKey={$this->controller->_key}";
}
$params['returnURL'] = CRM_Utils_System::url('civicrm/event/register', $urlArgs, TRUE, NULL, FALSE);
$params['invoiceID'] = $invoiceID;
//default action is Sale
$params['payment_action'] = 'Sale';
$token = $payment->setExpressCheckout($params);
if (is_a($token, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($token);
CRM_Utils_System::redirect($params['cancelURL']);
}
$this->set('token', $token);
$paymentURL = $this->_paymentProcessor['url_site'] . "/cgi-bin/webscr?cmd=_express-checkout&token={$token}";
CRM_Utils_System::redirect($paymentURL);
}
} elseif ($this->_paymentProcessor && $this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_NOTIFY) {
$this->set('contributeMode', 'notify');
}
} else {
$session = CRM_Core_Session::singleton();
$params['description'] = ts('Online Event Registration') . ' ' . $this->_values['event']['title'];
$this->_params = array();
$this->_params[] = $params;
$this->set('params', $this->_params);
if (!CRM_Utils_Array::value('additional_participants', $params)) {
self::processRegistration($this->_params);
}
}
// If registering > 1 participant, give status message
if (CRM_Utils_Array::value('additional_participants', $params, FALSE)) {
$statusMsg = ts('Registration information for participant 1 has been saved.');
CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success');
}
}