*/
use Civi\Api4\Contribution;
+use Civi\Api4\FinancialType;
use Civi\Payment\Exception\PaymentProcessorException;
/**
if (!isset($params['is_email_receipt']) && $isEmailReceipt) {
$params['is_email_receipt'] = $isEmailReceipt;
}
+ // We may no longer need to set params['is_recur'] - it used to be used in processRecurringContribution
$params['is_recur'] = $isRecur;
$params['payment_instrument_id'] = $contributionParams['payment_instrument_id'] ?? NULL;
- $recurringContributionID = CRM_Contribute_Form_Contribution_Confirm::processRecurringContribution($form, $params, $contactID, $financialType);
+ $recurringContributionID = !$isRecur ? NULL : CRM_Contribute_Form_Contribution_Confirm::processRecurringContribution($form, $params, [
+ 'contact_id' => $contactID,
+ 'financial_type_id' => $financialType->id,
+ ]);
$now = date('YmdHis');
$receiptDate = $params['receipt_date'] ?? NULL;
$toType = $submittedValues['financial_type_id'] ?? NULL;
$fromType = $this->_defaults['financial_type_id'] ?? NULL;
if (($this->_action & CRM_Core_Action::UPDATE) && ($toType != $fromType) && ($submittedValues['non_deductible_amount'] ?? NULL)) {
- $deductible = \Civi\Api4\FinancialType::get(TRUE)
+ $deductible = FinancialType::get(TRUE)
->addSelect('is_deductible')
->addWhere('id', 'IN', [$toType, $fromType])
->execute()->indexBy('id')->column('is_deductible');
if (!isset($params['is_email_receipt']) && $isEmailReceipt) {
$params['is_email_receipt'] = $isEmailReceipt;
}
+ // We may no longer need to set params['is_recur'] - it used to be used in processRecurringContribution
$params['is_recur'] = $isRecur;
$params['payment_instrument_id'] = $contributionParams['payment_instrument_id'] ?? NULL;
- $recurringContributionID = self::processRecurringContribution($form, $params, $contactID, $financialType);
+ $recurringContributionID = !$isRecur ? NULL : self::processRecurringContribution($form, $params, [
+ 'contact_id' => $contactID,
+ 'financial_type_id' => $financialType->id,
+ ]);
$now = date('YmdHis');
$receiptDate = $params['receipt_date'] ?? NULL;
*
* @param CRM_Core_Form $form
* @param array $params
- * @param int $contactID
- * @param string $contributionType
+ * @param array $recurParams
*
* @return int|null
*/
- public static function processRecurringContribution($form, $params, $contactID, $contributionType) {
-
- if (empty($params['is_recur'])) {
- return NULL;
- }
+ public static function processRecurringContribution($form, $params, $recurParams) {
- $recurParams = ['contact_id' => $contactID];
$recurParams['amount'] = $params['amount'] ?? NULL;
$recurParams['auto_renew'] = $params['auto_renew'] ?? NULL;
$recurParams['frequency_unit'] = $params['frequency_unit'] ?? NULL;
$recurParams['frequency_interval'] = $params['frequency_interval'] ?? NULL;
$recurParams['installments'] = $params['installments'] ?? NULL;
- $recurParams['financial_type_id'] = $params['financial_type_id'] ?? NULL;
$recurParams['currency'] = $params['currency'] ?? NULL;
$recurParams['payment_instrument_id'] = $params['payment_instrument_id'];
$recurParams['is_email_receipt'] = (bool) ($params['is_email_receipt'] ?? FALSE);
// We set trxn_id=invoiceID specifically for paypal IPN. It is reset this when paypal sends us the real trxn id, CRM-2991
$recurParams['processor_id'] = $recurParams['trxn_id'] = ($params['trxn_id'] ?? $params['invoiceID']);
- $recurParams['financial_type_id'] = $contributionType->id;
$campaignId = $params['campaign_id'] ?? $form->_values['campaign_id'] ?? NULL;
$recurParams['campaign_id'] = $campaignId;