本文整理汇总了PHP中CRM_Contribute_BAO_ContributionSoft::formatSoftCreditParams方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_ContributionSoft::formatSoftCreditParams方法的具体用法?PHP CRM_Contribute_BAO_ContributionSoft::formatSoftCreditParams怎么用?PHP CRM_Contribute_BAO_ContributionSoft::formatSoftCreditParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_ContributionSoft
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_ContributionSoft::formatSoftCreditParams方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processFormContribution
/**
* Process the contribution.
*
* @param CRM_Core_Form $form
* @param array $params
* @param array $result
* @param array $contributionParams
* Parameters to be passed to contribution create action.
* This differs from params in that we are currently adding params to it and 1) ensuring they are being
* passed consistently & 2) documenting them here.
* - contact_id
* - line_item
* - is_test
* - campaign_id
* - contribution_page_id
* - source
* - payment_type_id
* - thankyou_date (not all forms will set this)
*
* @param CRM_Financial_DAO_FinancialType $financialType
* @param bool $online
* Is the form a front end form? If so set a bunch of unpredictable things that should be passed in from the form.
*
* @param int $billingLocationID
* ID of billing location type.
* @param bool $isRecur
* Is this recurring?
*
* @return \CRM_Contribute_DAO_Contribution
* @throws \Exception
*/
public static function processFormContribution(&$form, $params, $result, $contributionParams, $financialType, $online, $billingLocationID, $isRecur)
{
$transaction = new CRM_Core_Transaction();
$contactID = $contributionParams['contact_id'];
$isEmailReceipt = !empty($form->_values['is_email_receipt']);
$isSeparateMembershipPayment = empty($params['separate_membership_payment']) ? FALSE : TRUE;
$pledgeID = !empty($params['pledge_id']) ? $params['pledge_id'] : CRM_Utils_Array::value('pledge_id', $form->_values);
if (!$isSeparateMembershipPayment && !empty($form->_values['pledge_block_id']) && (!empty($params['is_pledge']) || $pledgeID)) {
$isPledge = TRUE;
} else {
$isPledge = FALSE;
}
// add these values for the recurringContrib function ,CRM-10188
$params['financial_type_id'] = $financialType->id;
$contributionParams['address_id'] = CRM_Contribute_BAO_Contribution::createAddress($params, $billingLocationID);
//@todo - this is being set from the form to resolve CRM-10188 - an
// eNotice caused by it not being set @ the front end
// however, we then get it being over-written with null for backend contributions
// a better fix would be to set the values in the respective forms rather than require
// a function being shared by two forms to deal with their respective values
// moving it to the BAO & not taking the $form as a param would make sense here.
if (!isset($params['is_email_receipt']) && $isEmailReceipt) {
$params['is_email_receipt'] = $isEmailReceipt;
}
$params['is_recur'] = $isRecur;
$recurringContributionID = self::processRecurringContribution($form, $params, $contactID, $financialType);
$nonDeductibleAmount = self::getNonDeductibleAmount($params, $financialType, $online);
$now = date('YmdHis');
$receiptDate = CRM_Utils_Array::value('receipt_date', $params);
if ($isEmailReceipt) {
$receiptDate = $now;
}
if (isset($params['amount'])) {
$contributionParams = array_merge(self::getContributionParams($params, $financialType->id, $nonDeductibleAmount, TRUE, $result, $receiptDate, $recurringContributionID), $contributionParams);
$contribution = CRM_Contribute_BAO_Contribution::add($contributionParams);
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
if ($invoicing) {
$dataArray = array();
// @todo - interrogate the line items passed in on the params array.
// No reason to assume line items will be set on the form.
foreach ($form->_lineItem as $lineItemKey => $lineItemValue) {
foreach ($lineItemValue as $key => $value) {
if (isset($value['tax_amount']) && isset($value['tax_rate'])) {
if (isset($dataArray[$value['tax_rate']])) {
$dataArray[$value['tax_rate']] = $dataArray[$value['tax_rate']] + CRM_Utils_Array::value('tax_amount', $value);
} else {
$dataArray[$value['tax_rate']] = CRM_Utils_Array::value('tax_amount', $value);
}
}
}
}
$smarty = CRM_Core_Smarty::singleton();
$smarty->assign('dataArray', $dataArray);
$smarty->assign('totalTaxAmount', $params['tax_amount']);
}
if (is_a($contribution, 'CRM_Core_Error')) {
$message = CRM_Core_Error::getMessages($contribution);
CRM_Core_Error::fatal($message);
}
// lets store it in the form variable so postProcess hook can get to this and use it
$form->_contributionID = $contribution->id;
}
// process soft credit / pcp params first
CRM_Contribute_BAO_ContributionSoft::formatSoftCreditParams($params, $form);
//CRM-13981, processing honor contact into soft-credit contribution
CRM_Contribute_BAO_ContributionSoft::processSoftContribution($params, $contribution);
//handle pledge stuff.
if ($isPledge) {
//.........这里部分代码省略.........
示例2: submit
//.........这里部分代码省略.........
$submittedValues['total_amount'] = CRM_Utils_Array::value('total_amount', $this->_values);
}
$this->assign('lineItem', !empty($lineItem) && !$isQuickConfig ? $lineItem : FALSE);
$isEmpty = array_keys(array_flip($submittedValues['soft_credit_contact_id']));
if ($this->_id && count($isEmpty) == 1 && key($isEmpty) == NULL) {
//Delete existing soft credit records if soft credit list is empty on update
CRM_Contribute_BAO_ContributionSoft::del(array('contribution_id' => $this->_id, 'pcp_id' => 0));
}
// set the contact, when contact is selected
if (!empty($submittedValues['contact_id'])) {
$this->_contactID = $submittedValues['contact_id'];
}
$formValues = $submittedValues;
// Credit Card Contribution.
if ($this->_mode) {
$paramsSetByPaymentProcessingSubsystem = array('trxn_id', 'payment_instrument_id', 'contribution_status_id', 'cancel_date', 'cancel_reason');
foreach ($paramsSetByPaymentProcessingSubsystem as $key) {
if (isset($formValues[$key])) {
unset($formValues[$key]);
}
}
$contribution = $this->processCreditCard($formValues, $lineItem, $this->_contactID);
foreach ($paramsSetByPaymentProcessingSubsystem as $key) {
$formValues[$key] = $contribution->{$key};
}
} else {
// Offline Contribution.
$submittedValues = $this->unsetCreditCardFields($submittedValues);
// get the required field value only.
$params = $ids = array();
$params['contact_id'] = $this->_contactID;
$params['currency'] = $this->getCurrency($submittedValues);
//format soft-credit/pcp param first
CRM_Contribute_BAO_ContributionSoft::formatSoftCreditParams($submittedValues, $this);
$params = array_merge($params, $submittedValues);
$fields = array('financial_type_id', 'contribution_status_id', 'payment_instrument_id', 'cancel_reason', 'source', 'check_number');
foreach ($fields as $f) {
$params[$f] = CRM_Utils_Array::value($f, $formValues);
}
// CRM-5740 if priceset is used, no need to cleanup money.
if ($priceSetId) {
$params['skipCleanMoney'] = 1;
}
$dates = array('receive_date', 'receipt_date', 'cancel_date');
foreach ($dates as $d) {
$params[$d] = CRM_Utils_Date::processDate($formValues[$d], $formValues[$d . '_time'], TRUE);
}
if (!empty($formValues['is_email_receipt'])) {
$params['receipt_date'] = date("Y-m-d");
}
if ($params['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Cancelled', 'name') || $params['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Refunded', 'name')) {
if (CRM_Utils_System::isNull(CRM_Utils_Array::value('cancel_date', $params))) {
$params['cancel_date'] = date('YmdHis');
}
} else {
$params['cancel_date'] = $params['cancel_reason'] = 'null';
}
// Set is_pay_later flag for back-office offline Pending status contributions CRM-8996
// else if contribution_status is changed to Completed is_pay_later flag is changed to 0, CRM-15041
if ($params['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Pending', 'name')) {
$params['is_pay_later'] = 1;
} elseif ($params['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name')) {
$params['is_pay_later'] = 0;
}
$ids['contribution'] = $params['id'] = $this->_id;
// Add Additional common information to formatted params.
示例3: processContribution
/**
* Process the contribution.
*
* @param CRM_Core_Form $form
* @param array $params
* @param array $result
* @param int $contactID
* @param bool $pending
* @param bool $isAdditionalAmount
*
* @return \CRM_Contribute_BAO_Contribution
*/
public static function processContribution(&$form, $params, $result, $contactID, $pending = FALSE, $isAdditionalAmount = FALSE)
{
$transaction = new CRM_Core_Transaction();
$now = date('YmdHis');
$receiptDate = NULL;
if (!empty($form->_values['event']['is_email_confirm'])) {
$receiptDate = $now;
}
//CRM-4196
if ($isAdditionalAmount) {
$params['amount_level'] = $params['amount_level'] . ts(' (multiple participants)') . CRM_Core_DAO::VALUE_SEPARATOR;
}
$contribParams = array('contact_id' => $contactID, 'financial_type_id' => !empty($form->_values['event']['financial_type_id']) ? $form->_values['event']['financial_type_id'] : $params['financial_type_id'], 'receive_date' => $now, 'total_amount' => $params['amount'], 'tax_amount' => $params['tax_amount'], 'amount_level' => $params['amount_level'], 'invoice_id' => $params['invoiceID'], 'currency' => $params['currencyID'], 'source' => !empty($params['participant_source']) ? $params['participant_source'] : $params['description'], 'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0), 'campaign_id' => CRM_Utils_Array::value('campaign_id', $params));
if (empty($params['is_pay_later'])) {
$contribParams['payment_instrument_id'] = 1;
}
if (!$pending && $result) {
$contribParams += array('fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['amount']), 'trxn_id' => $result['trxn_id'], 'receipt_date' => $receiptDate);
}
$allStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$contribParams['contribution_status_id'] = array_search('Completed', $allStatuses);
if ($pending) {
$contribParams['contribution_status_id'] = array_search('Pending', $allStatuses);
}
$contribParams['is_test'] = 0;
if ($form->_action & CRM_Core_Action::PREVIEW || CRM_Utils_Array::value('mode', $params) == 'test') {
$contribParams['is_test'] = 1;
}
$contribID = NULL;
if (!empty($contribParams['invoice_id'])) {
$contribID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contribParams['invoice_id'], 'id', 'invoice_id');
}
$ids = array();
if ($contribID) {
$ids['contribution'] = $contribID;
$contribParams['id'] = $contribID;
}
if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) {
$eventStartDate = CRM_Utils_Array::value('start_date', CRM_Utils_Array::value('event', $form->_values));
if ($eventStartDate) {
$contribParams['revenue_recognition_date'] = date('Ymd', strtotime($eventStartDate));
}
}
//create an contribution address
// The concept of contributeMode is deprecated. Elsewhere we use the function processBillingAddress() - although
// currently that is only inherited by back-office forms.
if ($form->_contributeMode != 'notify' && empty($params['is_pay_later'])) {
$contribParams['address_id'] = CRM_Contribute_BAO_Contribution::createAddress($params, $form->_bltID);
}
$contribParams['payment_processor'] = CRM_Utils_Array::value('payment_processor', $params);
$contribParams['skipLineItem'] = 1;
// create contribution record
$contribution = CRM_Contribute_BAO_Contribution::add($contribParams, $ids);
// CRM-11124
CRM_Event_BAO_Participant::createDiscountTrxn($form->_eventId, $contribParams, NULL, CRM_Price_BAO_PriceSet::parseFirstPriceSetValueIDFromParams($params));
// process soft credit / pcp pages
if (!empty($params['pcp_made_through_id'])) {
CRM_Contribute_BAO_ContributionSoft::formatSoftCreditParams($params, $form);
CRM_Contribute_BAO_ContributionSoft::processSoftContribution($params, $contribution);
}
$transaction->commit();
return $contribution;
}