本文整理汇总了PHP中CRM_Contribute_BAO_ContributionRecur::getTemplateContribution方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_ContributionRecur::getTemplateContribution方法的具体用法?PHP CRM_Contribute_BAO_ContributionRecur::getTemplateContribution怎么用?PHP CRM_Contribute_BAO_ContributionRecur::getTemplateContribution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_ContributionRecur
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_ContributionRecur::getTemplateContribution方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
* @param int $paymentProcessorID
*
* @return array
* @throws CiviCRM_API3_Exception
*/
protected static function repeatTransaction(&$contribution, &$input, $contributionParams, $paymentProcessorID)
{
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'];
}
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'];
}
}
$templateContribution = CRM_Contribute_BAO_ContributionRecur::getTemplateContribution($contributionParams['contribution_recur_id'], array_intersect_key($contributionParams, array('total_amount' => TRUE, 'financial_type_id' => TRUE)));
$input['line_item'] = $contributionParams['line_item'] = $templateContribution['line_item'];
$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'];
//CRM-18805 -- Contribution page not recorded on recurring transactions, Recurring contribution payments
//do not create CC or BCC emails or profile notifications.
//The if is just to be safe. Not sure if we can ever arrive with this unset
if (isset($contribution->contribution_page_id)) {
$contributionParams['contribution_page_id'] = $contribution->contribution_page_id;
}
$createContribution = civicrm_api3('Contribution', 'create', $contributionParams);
$contribution->id = $createContribution['id'];
CRM_Contribute_BAO_ContributionRecur::copyCustomValues($contributionParams['contribution_recur_id'], $contribution->id);
return TRUE;
}
}