本文整理汇总了PHP中CRM_Contribute_BAO_ContributionRecur::addRecurLineItems方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_ContributionRecur::addRecurLineItems方法的具体用法?PHP CRM_Contribute_BAO_ContributionRecur::addRecurLineItems怎么用?PHP CRM_Contribute_BAO_ContributionRecur::addRecurLineItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_ContributionRecur
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_ContributionRecur::addRecurLineItems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: repeatTransaction
/**
* Repeat a transaction as part of a recurring series.
*
* Only call this via the api as it is being refactored. The intention is that the repeatTransaction function
* (possibly living on the ContributionRecur BAO) would be called first to create a pending contribution with a
* subsequent call to the contribution.completetransaction api.
*
* The completeTransaction functionality has historically been overloaded to both complete and repeat payments.
*
* @param CRM_Contribute_BAO_Contribution $contribution
* @param array $input
* @param array $contributionParams
*
* @return array
*/
protected static function repeatTransaction(&$contribution, &$input, $contributionParams)
{
if (!empty($contribution->id)) {
return FALSE;
}
if (empty($contribution->id)) {
// Unclear why this would only be set for repeats.
if (!empty($input['amount'])) {
$contribution->total_amount = $contributionParams['total_amount'] = $input['amount'];
}
$templateContribution = CRM_Contribute_BAO_ContributionRecur::getTemplateContribution($contributionParams['contribution_recur_id']);
if (!empty($contributionParams['contribution_recur_id'])) {
$recurringContribution = civicrm_api3('ContributionRecur', 'getsingle', array('id' => $contributionParams['contribution_recur_id']));
if (!empty($recurringContribution['campaign_id'])) {
// CRM-17718 the campaign id on the contribution recur record should get precedence.
$contributionParams['campaign_id'] = $recurringContribution['campaign_id'];
}
if (!empty($recurringContribution['financial_type_id'])) {
// CRM-17718 the campaign id on the contribution recur record should get precedence.
$contributionParams['financial_type_id'] = $recurringContribution['financial_type_id'];
}
}
$contributionParams['skipLineItem'] = TRUE;
$contributionParams['status_id'] = 'Pending';
if (isset($contributionParams['financial_type_id'])) {
// Give precedence to passed in type.
$contribution->financial_type_id = $contributionParams['financial_type_id'];
} else {
$contributionParams['financial_type_id'] = $templateContribution['financial_type_id'];
}
$contributionParams['contact_id'] = $templateContribution['contact_id'];
$contributionParams['source'] = empty($templateContribution['source']) ? ts('Recurring contribution') : $templateContribution['source'];
$createContribution = civicrm_api3('Contribution', 'create', $contributionParams);
$contribution->id = $createContribution['id'];
$input['line_item'] = CRM_Contribute_BAO_ContributionRecur::addRecurLineItems($contribution->contribution_recur_id, $contribution);
CRM_Contribute_BAO_ContributionRecur::copyCustomValues($contributionParams['contribution_recur_id'], $contribution->id);
return TRUE;
}
}
示例2: repeatTransaction
/**
* Repeat a transaction as part of a recurring series.
*
* Only call this via the api as it is being refactored. The intention is that the repeatTransaction function
* (possibly living on the ContributionRecur BAO) would be called first to create a pending contribution with a
* subsequent call to the contribution.completetransaction api.
*
* The completeTransaction functionality has historically been overloaded to both complete and repeat payments.
*
* @param CRM_Contribute_BAO_Contribution $contribution
* @param array $input
* @param array $contributionParams
*
* @return array
*/
protected static function repeatTransaction(&$contribution, &$input, $contributionParams)
{
if (!empty($contribution->id)) {
return FALSE;
}
if (empty($contribution->id)) {
// Unclear why this would only be set for repeats.
if (!empty($input['amount'])) {
$contribution->total_amount = $contributionParams['total_amount'] = $input['amount'];
}
$templateContribution = civicrm_api3('Contribution', 'getsingle', array('contribution_recur_id' => $contributionParams['contribution_recur_id'], 'options' => array('limit' => 1)));
$contributionParams['skipLineItem'] = TRUE;
$contributionParams['status_id'] = 'Pending';
$contributionParams['financial_type_id'] = $templateContribution['financial_type_id'];
$contributionParams['contact_id'] = $templateContribution['contact_id'];
$contributionParams['source'] = empty($templateContribution['source']) ? ts('Recurring contribution') : $templateContribution['source'];
$createContribution = civicrm_api3('Contribution', 'create', $contributionParams);
$contribution->id = $createContribution['id'];
$input['line_item'] = CRM_Contribute_BAO_ContributionRecur::addRecurLineItems($contribution->contribution_recur_id, $contribution);
CRM_Contribute_BAO_ContributionRecur::copyCustomValues($contributionParams['contribution_recur_id'], $contribution->id);
return TRUE;
}
}
示例3: cancelled
/**
* Process cancelled payment outcome.
*
* @param array $objects
* @param CRM_Core_Transaction $transaction
* @param array $input
*
* @return bool
*/
public function cancelled(&$objects, &$transaction, $input = array())
{
$contribution =& $objects['contribution'];
$memberships =& $objects['membership'];
if (is_numeric($memberships)) {
$memberships = array($objects['membership']);
}
$participant =& $objects['participant'];
$addLineItems = FALSE;
if (empty($contribution->id)) {
$addLineItems = TRUE;
}
$contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', array('labelColumn' => 'name', 'flip' => 1));
$contribution->contribution_status_id = $contributionStatuses['Cancelled'];
$contribution->cancel_date = self::$_now;
$contribution->cancel_reason = CRM_Utils_Array::value('reasonCode', $input);
$contribution->receive_date = CRM_Utils_Date::isoToMysql($contribution->receive_date);
$contribution->receipt_date = CRM_Utils_Date::isoToMysql($contribution->receipt_date);
$contribution->thankyou_date = CRM_Utils_Date::isoToMysql($contribution->thankyou_date);
$contribution->save();
//add lineitems for recurring payments
if (!empty($objects['contributionRecur']) && $objects['contributionRecur']->id && $addLineItems) {
CRM_Contribute_BAO_ContributionRecur::addRecurLineItems($objects['contributionRecur']->id, $contribution);
}
//add new soft credit against current $contribution and
//copy initial contribution custom fields for recurring contributions
if (!empty($objects['contributionRecur']) && $objects['contributionRecur']->id) {
CRM_Contribute_BAO_ContributionRecur::addrecurSoftCredit($objects['contributionRecur']->id, $contribution->id);
CRM_Contribute_BAO_ContributionRecur::copyCustomValues($objects['contributionRecur']->id, $contribution->id);
}
if (empty($input['IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved'])) {
if (!empty($memberships)) {
$membershipStatuses = CRM_Core_PseudoConstant::get('CRM_Member_DAO_Membership', 'status_id', array('labelColumn' => 'name', 'flip' => 1));
foreach ($memberships as $membership) {
if ($membership) {
$membership->status_id = $membershipStatuses['Cancelled'];
$membership->save();
//update related Memberships.
$params = array('status_id' => $membershipStatuses['Cancelled']);
CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $params);
}
}
}
if ($participant) {
$participantStatuses = CRM_Core_PseudoConstant::get('CRM_Event_DAO_Participant', 'status_id', array('labelColumn' => 'name', 'flip' => 1));
$participant->status_id = $participantStatuses['Cancelled'];
$participant->save();
}
}
$transaction->commit();
CRM_Core_Error::debug_log_message("Setting contribution status to cancelled");
//echo "Success: Setting contribution status to cancelled<p>";
return TRUE;
}