$pledgeParams['create_date'] = $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date("Ymd");
if (!empty($params['start_date'])) {
$pledgeParams['frequency_day'] = intval(date("d", strtotime($params['start_date'])));
- $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date('Ymd', strtotime(CRM_Utils_Array::value('start_date', $params)));
+ $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date('Ymd', strtotime($params['start_date']));
}
$pledgeParams['status_id'] = $contribution->contribution_status_id;
$pledgeParams['max_reminders'] = $form->_values['max_reminders'];
$paymentProcessorOutcome, $receiptDate, $recurringContributionID) {
$contributionParams = [
'financial_type_id' => $financialTypeID,
- 'receive_date' => (CRM_Utils_Array::value('receive_date', $params)) ? CRM_Utils_Date::processDate($params['receive_date']) : date('YmdHis'),
+ 'receive_date' => isset($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' => CRM_Utils_Array::value('is_pay_later', $params, 0),
+ 'is_pay_later' => $params['is_pay_later'] ?? 0,
//configure cancel reason, cancel date and thankyou date
//from 'contribution' type profile if included
- 'cancel_reason' => CRM_Utils_Array::value('cancel_reason', $params, 0),
+ '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' => CRM_Utils_Array::value('skipLineItem', $params, 0),
+ 'skipLineItem' => $params['skipLineItem'] ?? 0,
];
if ($paymentProcessorOutcome) {
$this->_params['is_pay_later'] = $this->get('is_pay_later');
$this->assign('is_pay_later', $this->_params['is_pay_later']);
if ($this->_params['is_pay_later']) {
- $this->assign('pay_later_receipt', CRM_Utils_Array::value('pay_later_receipt', $this->_values));
+ $this->assign('pay_later_receipt', $this->_values['pay_later_receipt'] ?? NULL);
}
// if onbehalf-of-organization
if (!empty($this->_values['onbehalf_profile_id']) && !empty($this->_params['onbehalf']['organization_name'])) {
// assign contribution page id to the template so we can add css class for it
$this->assign('contributionPageID', $this->_id);
- $this->assign('is_for_organization', CRM_Utils_Array::value('is_for_organization', $this->_params));
+ $this->assign('is_for_organization', $this->_params['is_for_organization'] ?? NULL);
$this->set('params', $this->_params);
}
$fieldTypes[] = CRM_Core_BAO_UFGroup::getContactType($this->_values['honoree_profile_id']);
$this->buildCustom($this->_values['honoree_profile_id'], 'honoreeProfileFields', TRUE, 'honor', $fieldTypes);
}
- $this->assign('receiptFromEmail', CRM_Utils_Array::value('receipt_from_email', $this->_values));
+ $this->assign('receiptFromEmail', $this->_values['receipt_from_email']);
$amount_block_is_active = $this->get('amount_block_is_active');
$this->assign('amount_block_is_active', $amount_block_is_active);
$this->assign('product_name', $productDAO->name);
$this->assign('price', $productDAO->price);
$this->assign('sku', $productDAO->sku);
- $this->assign('option', CRM_Utils_Array::value('options_' . $premiumParams['selectProduct'], $premiumParams));
+ $this->assign('option', $premiumParams['options_' . $premiumParams['selectProduct']] ?? NULL);
$periodType = $productDAO->period_type;
$isEmailReceipt = !empty($form->_values['is_email_receipt']);
$isSeparateMembershipPayment = !empty($params['separate_membership_payment']);
- $pledgeID = !empty($params['pledge_id']) ? $params['pledge_id'] : CRM_Utils_Array::value('pledge_id', $form->_values);
+ $pledgeID = !empty($params['pledge_id']) ? $params['pledge_id'] : $form->_values['pledge_id'] ?? NULL;
if (!$isSeparateMembershipPayment && !empty($form->_values['pledge_block_id']) &&
(!empty($params['is_pledge']) || $pledgeID)) {
$isPledge = TRUE;
$recurParams['is_email_receipt'] = $params['is_email_receipt'] ?? NULL;
// we need to add a unique trxn_id to avoid a unique key error
// in paypal IPN we reset this when paypal sends us the real trxn id, CRM-2991
- $recurParams['trxn_id'] = CRM_Utils_Array::value('trxn_id', $params, $params['invoiceID']);
+ $recurParams['trxn_id'] = $params['trxn_id'] ?? $params['invoiceID'];
$recurParams['financial_type_id'] = $contributionType->id;
- $campaignId = CRM_Utils_Array::value('campaign_id', $params, CRM_Utils_Array::value('campaign_id', $form->_values));
+ $campaignId = $params['campaign_id'] ?? $form->_values['campaign_id'] ?? NULL;
$recurParams['campaign_id'] = $campaignId;
$recurring = CRM_Contribute_BAO_ContributionRecur::add($recurParams);
if (is_a($recurring, 'CRM_Core_Error')) {
$membershipTypes = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, $membershipTypeIDs);
$membershipType = empty($membershipTypes) ? [] : reset($membershipTypes);
- $this->assign('membership_name', CRM_Utils_Array::value('name', $membershipType));
+ $this->assign('membership_name', $membershipType['name']);
$this->_values['membership_name'] = $membershipType['name'] ?? NULL;
$isPaidMembership = FALSE;
$financialTypeID = $this->_values['financial_type_id'];
}
else {
- $financialTypeID = CRM_Utils_Array::value('financial_type_id', $membershipType, CRM_Utils_Array::value('financial_type_id', $membershipParams));
+ $financialTypeID = $membershipType['financial_type_id'] ?? $membershipParams['financial_type_id'] ?? NULL;
}
if (!empty($this->_params['membership_source'])) {
$isProcessSeparateMembershipTransaction, $financialTypeID, $unprocessedLineItems) {
$membershipContribution = NULL;
- $isTest = CRM_Utils_Array::value('is_test', $membershipParams, FALSE);
+ $isTest = $membershipParams['is_test'] ?? FALSE;
$errors = $paymentResults = [];
$form->_values['isMembership'] = TRUE;
- $isRecurForFirstTransaction = CRM_Utils_Array::value('is_recur', $form->_params, CRM_Utils_Array::value('is_recur', $membershipParams));
+ $isRecurForFirstTransaction = $form->_params['is_recur'] ?? $membershipParams['is_recur'] ?? NULL;
$totalAmount = $membershipParams['amount'];
unset($membershipParams['is_recur']);
}
list($membershipContribution, $secondPaymentResult) = $this->processSecondaryFinancialTransaction($contactID, $form, array_merge($membershipParams, ['skipLineItem' => 1]),
- $isTest, $unprocessedLineItems, CRM_Utils_Array::value('minimum_fee', $membershipDetails, 0), CRM_Utils_Array::value('financial_type_id', $membershipDetails));
+ $isTest, $unprocessedLineItems, $membershipDetails['minimum_fee'] ?? 0, $membershipDetails['financial_type_id'] ?? NULL);
$paymentResults[] = ['contribution_id' => $membershipContribution->id, 'result' => $secondPaymentResult];
$totalAmount = $membershipContribution->total_amount;
}
}
//@todo it should no longer be possible for it to get to this point & membership to not be an array
if (is_array($membershipTypeIDs) && !empty($membershipContributionID)) {
- $typesTerms = CRM_Utils_Array::value('types_terms', $membershipParams, []);
+ $typesTerms = $membershipParams['types_terms'] ?? [];
$membershipLines = $nonMembershipLines = [];
foreach ($unprocessedLineItems as $priceSetID => $lines) {
$membershipLineItems = $unprocessedLineItems;
}
$i++;
- $numTerms = CRM_Utils_Array::value($memType, $typesTerms, 1);
+ $numTerms = $typesTerms[$memType] ?? 1;
$contributionRecurID = $form->_params['contributionRecurID'] ?? NULL;
$membershipSource = NULL;
$pending = $membershipContribution->contribution_status_id == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
}
else {
- $pending = $this->getIsPending();
+ // The concept of contributeMode is deprecated.
+ // the is_monetary concept probably should be too as it can be calculated from
+ // the existence of 'amount' & seems fragile.
+ if (((isset($this->_contributeMode)) || !empty($this->_params['is_pay_later'])
+ ) &&
+ (($this->_values['is_monetary'] && $this->_amount > 0.0))
+ ) {
+ $pending = TRUE;
+ }
+ $pending = FALSE;
}
+
list($membership, $renewalMode, $dates) = CRM_Member_BAO_Membership::processMembership(
$contactID, $memType, $isTest,
- date('YmdHis'), CRM_Utils_Array::value('cms_contactID', $membershipParams),
+ date('YmdHis'), $membershipParams['cms_contactID'] ?? NULL,
$customFieldsFormatted,
$numTerms, $membershipID, $pending,
$contributionRecurID, $membershipSource, $isPayLater, $campaignId, [], $membershipContribution,
if (!empty($membershipContribution) && !is_a($membershipContribution, 'CRM_Core_Error')) {
if (empty($form->_paymentProcessor)) {
// @todo this can maybe go now we are setting payment_processor_id = 0 more reliably.
- $paymentProcessorIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('payment_processor', $this->_values));
+ $paymentProcessorIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_values['payment_processor'] ?? NULL);
$this->_paymentProcessor['id'] = $paymentProcessorIDs[0];
}
$result = ['payment_status_id' => 1, 'contribution' => $membershipContribution];
'contact_id' => $contactID,
'line_item' => $lineItems,
'is_test' => $isTest,
- 'campaign_id' => CRM_Utils_Array::value('campaign_id', $tempParams, CRM_Utils_Array::value('campaign_id',
- $form->_values)),
+ 'campaign_id' => $tempParams['campaign_id'] ?? $form->_values['campaign_id'] ?? NULL,
'contribution_page_id' => $form->_id,
- 'source' => CRM_Utils_Array::value('source', $tempParams, CRM_Utils_Array::value('description', $tempParams)),
+ 'source' => $tempParams['source'] ?? $tempParams['description'] ?? NULL,
];
$isMonetary = !empty($form->_values['is_monetary']);
if ($isMonetary) {
return [$membershipContribution, $result];
}
- /**
- * Is the payment a pending payment.
- *
- * We are moving towards always creating as pending and updating at the end (based on payment), so this should be
- * an interim refactoring. It was shared with another unrelated form & some parameters may not apply to this form.
- *
- * @return bool
- */
- protected function getIsPending() {
- // The concept of contributeMode is deprecated.
- // the is_monetary concept probably should be too as it can be calculated from
- // the existence of 'amount' & seems fragile.
- if (((isset($this->_contributeMode)) || !empty($this->_params['is_pay_later'])
- ) &&
- (($this->_values['is_monetary'] && $this->_amount > 0.0))
- ) {
- return TRUE;
- }
- return FALSE;
- }
-
/**
* Are we going to do 2 financial transactions.
*
!empty($this->_membershipBlock['is_separate_payment'])
&& !empty($this->_values['fee'][$priceField->id])
&& ($this->_values['fee'][$priceField->id]['name'] == "other_amount")
- && CRM_Utils_Array::value("price_{$paramWeDoNotUnderstand}", $this->_params) < 1
+ && ($this->_params["price_{$paramWeDoNotUnderstand}"] ?? NULL) < 1
&& empty($this->_params["price_{$priceField->id}"])
) {
$this->_params['amount'] = NULL;
//@todo - merge with section above
if (!empty($this->_membershipBlock['is_separate_payment'])
&& !empty($this->_values['fee'][$priceField->id])
- && CRM_Utils_Array::value('name', $this->_values['fee'][$priceField->id]) == 'contribution_amount'
- && CRM_Utils_Array::value("price_{$priceField->id}", $this->_params) == '-1'
+ && ($this->_values['fee'][$priceField->id]['name'] ?? NULL) == 'contribution_amount'
+ && ($this->_params["price_{$priceField->id}"] ?? NULL) == '-1'
) {
$this->_params['amount'] = NULL;
}
}
$form->set('memberPriceFieldIDS', $membershipPriceFieldIDs);
$form->setRecurringMembershipParams();
- $form->processFormSubmission(CRM_Utils_Array::value('contact_id', $params));
+ $form->processFormSubmission($params['contact_id'] ?? NULL);
}
/**
$this->_contactID = $contactID;
//get email primary first if exist
- $subscriptionEmail = ['email' => CRM_Utils_Array::value('email-Primary', $params)];
+ $subscriptionEmail = ['email' => $params['email-Primary'] ?? NULL];
if (!$subscriptionEmail['email']) {
$subscriptionEmail['email'] = $params["email-{$this->_bltID}"] ?? NULL;
}
$contactID,
$this->wrangleFinancialTypeID($this->_values['financial_type_id']),
($this->_mode == 'test') ? 1 : 0,
- CRM_Utils_Array::value('is_recur', $paymentParams)
+ $paymentParams['is_recur'] ?? NULL
);
if (empty($result['is_payment_failure'])) {
* @throws \Exception
*/
protected function completeTransaction($result, $contributionID) {
- if (CRM_Utils_Array::value('payment_status_id', $result) == 1) {
+ if (($result['payment_status_id'] ?? NULL) == 1) {
try {
civicrm_api3('contribution', 'completetransaction', [
'id' => $contributionID,
'trxn_id' => $result['trxn_id'] ?? NULL,
- 'payment_processor_id' => CRM_Utils_Array::value('payment_processor_id', $result, $this->_paymentProcessor['id']),
+ 'payment_processor_id' => $result['payment_processor_id'] ?? $this->_paymentProcessor['id'],
'is_transactional' => FALSE,
'fee_amount' => $result['fee_amount'] ?? NULL,
'receive_date' => $result['receive_date'] ?? NULL,