}
if (isset($params['amount'])) {
- $contributionParams = array_merge(CRM_Contribute_Form_Contribution_Confirm::getContributionParams(
- $params, $financialType->id,
- NULL, $receiptDate,
+ $contributionParams = array_merge($this->getContributionParams(
+ $params, $financialType->id, $receiptDate,
$recurringContributionID), $contributionParams
);
$contributionParams['non_deductible_amount'] = CRM_Contribute_Form_Contribution_Confirm::getNonDeductibleAmount($params, $financialType, FALSE, $form);
return $recurring->id;
}
+ /**
+ * Set the parameters to be passed to contribution create function.
+ *
+ * Previously shared function.
+ *
+ * @param array $params
+ * @param int $financialTypeID
+ * @param string $receiptDate
+ * @param int $recurringContributionID
+ *
+ * @return array
+ * @throws \CRM_Core_Exception
+ */
+ private function getContributionParams(
+ $params, $financialTypeID, $receiptDate, $recurringContributionID) {
+ $contributionParams = [
+ 'financial_type_id' => $financialTypeID,
+ 'receive_date' => !empty($params['receive_date']) ? CRM_Utils_Date::processDate($params['receive_date']) : date('YmdHis'),
+ 'tax_amount' => $params['tax_amount'] ?? NULL,
+ 'amount_level' => $params['amount_level'] ?? NULL,
+ 'invoice_id' => $params['invoiceID'],
+ 'currency' => $params['currencyID'],
+ 'is_pay_later' => $params['is_pay_later'] ?? 0,
+ //configure cancel reason, cancel date and thankyou date
+ //from 'contribution' type profile if included
+ 'cancel_reason' => $params['cancel_reason'] ?? 0,
+ 'cancel_date' => isset($params['cancel_date']) ? CRM_Utils_Date::format($params['cancel_date']) : NULL,
+ 'thankyou_date' => isset($params['thankyou_date']) ? CRM_Utils_Date::format($params['thankyou_date']) : NULL,
+ //setting to make available to hook - although seems wrong to set on form for BAO hook availability
+ 'skipLineItem' => $params['skipLineItem'] ?? 0,
+ ];
+
+ if (!empty($params["is_email_receipt"])) {
+ $contributionParams += [
+ 'receipt_date' => $receiptDate,
+ ];
+ }
+
+ if ($recurringContributionID) {
+ $contributionParams['contribution_recur_id'] = $recurringContributionID;
+ }
+
+ $contributionParams['contribution_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
+ if (isset($contributionParams['invoice_id'])) {
+ $contributionParams['id'] = CRM_Core_DAO::getFieldValue(
+ 'CRM_Contribute_DAO_Contribution',
+ $contributionParams['invoice_id'],
+ 'id',
+ 'invoice_id'
+ );
+ }
+
+ return $contributionParams;
+ }
+
/**
* Generate the data to construct a snippet based pane.
*
*
* @param array $params
* @param int $financialTypeID
- * @param array $paymentProcessorOutcome
* @param string $receiptDate
* @param int $recurringContributionID
*
* @return array
* @throws \CRM_Core_Exception
*/
- public static function getContributionParams(
+ private function getContributionParams(
$params, $financialTypeID,
- $paymentProcessorOutcome, $receiptDate, $recurringContributionID) {
+ $receiptDate, $recurringContributionID) {
$contributionParams = [
'financial_type_id' => $financialTypeID,
'receive_date' => !empty($params['receive_date']) ? CRM_Utils_Date::processDate($params['receive_date']) : date('YmdHis'),
}
if (isset($params['amount'])) {
- $contributionParams = array_merge(self::getContributionParams(
- $params, $financialType->id,
- NULL, $receiptDate,
+ $contributionParams = array_merge($this->getContributionParams(
+ $params, $financialType->id, $receiptDate,
$recurringContributionID), $contributionParams
);