$this->_params = $formValues;
$contribution = $this->processContribution(
- $paymentParams,
[
'contact_id' => $this->_contributorContactID,
'line_item' => [$this->order->getPriceSetID() => $this->order->getLineItems()],
* It's like the contribution create being done here is actively bad and
* being fixed later.
*
- * @param array $params
* @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
* @throws \CiviCRM_API3_Exception
*/
protected function processContribution(
- $params,
$contributionParams
) {
- $contributionParams['contribution_recur_id'] = $this->legacyProcessRecurringContribution($params);
+ $contributionParams['contribution_recur_id'] = $this->legacyProcessRecurringContribution();
return CRM_Contribute_BAO_Contribution::add($contributionParams);
}
*
* This function was copied from another form & needs cleanup.
*
- * @param array $params
- *
* @return int|null
* @throws \CiviCRM_API3_Exception
*/
- protected function legacyProcessRecurringContribution(array $params): ?int {
+ protected function legacyProcessRecurringContribution(): ?int {
if (!$this->isCreateRecurringContribution()) {
return NULL;
}
$recurParams['payment_instrument_id'] = $this->getPaymentInstrumentID();
$recurParams['is_test'] = $this->isTest();
- $recurParams['start_date'] = $recurParams['create_date'] = $recurParams['modified_date'] = CRM_Utils_Time::date('YmdHis');
- if (!empty($params['receive_date'])) {
- $recurParams['start_date'] = date('YmdHis', CRM_Utils_Time::strtotime($params['receive_date']));
- }
+ $recurParams['create_date'] = $recurParams['modified_date'] = CRM_Utils_Time::date('YmdHis');
+ $recurParams['start_date'] = $this->getReceiveDate();
$recurParams['invoice_id'] = $this->getInvoiceID();
$recurParams['contribution_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
$recurParams['payment_processor_id'] = $this->getPaymentProcessorID();
]);
}
+ /**
+ * Get the receive date for the contribution.
+ *
+ * @return string $receive_date
+ */
+ protected function getReceiveDate(): string {
+ return $this->getSubmittedValue('receive_date') ?: date('YmdHis');
+ }
+
}