CRM_Financial_BAO_Payment
in package
This class contains payment related functions.
Table of Contents
Methods
- create() : CRM_Financial_DAO_FinancialTrxn
- Function to process additional payment for partial and refund contributions.
- filterUntestedTemplateVariables() : array<string|int, mixed>
- Filter out any untested variables.
- getConfirmationTemplateParameters() : array<string|int, mixed>
- getPaymentContactID() : int
- getValidFromEmailsForPayment() : array<string|int, mixed>
- Get valid from emails for payment.
- sendConfirmation() : array<string|int, mixed>
- Send an email confirming a payment that has been received.
- updateRelatedContribution() : void
- Function to update contribution's check_number and trxn_id by concatenating values from financial trxn's check_number and trxn_id respectively
- createFinancialItem() : array<string|int, mixed>
- Create a financial items & return the ID.
- getPayableItems() : array<string|int, mixed>
- Get the line items for the contribution.
- isPaymentCompletesContribution() : bool
- Does this payment complete the contribution.
- loadRelatedEntities() : array<string|int, mixed>
- Load entities related to the current payment id.
- reverseAllocationsFromPreviousPayment() : mixed
- Reverse the entity financial transactions associated with the cancelled payment.
- updateContributionStatus() : mixed
- Update the status of the contribution.
Methods
create()
Function to process additional payment for partial and refund contributions.
public
static create(array<string|int, mixed> $params[, bool $disableActionsOnCompleteOrder = FALSE ]) : CRM_Financial_DAO_FinancialTrxn
This function is called via API payment.create function. All forms that add payments should use this.
Parameters
- $params : array<string|int, mixed>
-
- contribution_id
- total_amount
- line_item
- $disableActionsOnCompleteOrder : bool = FALSE
-
Disble membership, participant processing when the payment completes the order Note this is only set by Payment.Create in APIv4 and should not be used elsewhere and is likely to change.
Tags
Return values
CRM_Financial_DAO_FinancialTrxnfilterUntestedTemplateVariables()
Filter out any untested variables.
public
static filterUntestedTemplateVariables(array<string|int, mixed> $params) : array<string|int, mixed>
This just serves to highlight if any variables are added without a unit test also being added.
(if hit then add a unit test for the param & add to this array).
Parameters
- $params : array<string|int, mixed>
Return values
array<string|int, mixed>getConfirmationTemplateParameters()
public
static getConfirmationTemplateParameters(array<string|int, mixed> $entities) : array<string|int, mixed>
these template variables no longer used in the core template from 5.69 - stop assigning them.
Parameters
- $entities : array<string|int, mixed>
-
Related entities as an array keyed by the various entities.
Return values
array<string|int, mixed> —Values required for the notification
- contact_id
- template_variables
- event (DAO of event if relevant)
getPaymentContactID()
public
static getPaymentContactID(int $contributionID) : int
Parameters
- $contributionID : int
Tags
Return values
intgetValidFromEmailsForPayment()
Get valid from emails for payment.
public
static getValidFromEmailsForPayment([int $eventID = NULL ]) : array<string|int, mixed>
Parameters
- $eventID : int = NULL
Return values
array<string|int, mixed>sendConfirmation()
Send an email confirming a payment that has been received.
public
static sendConfirmation(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>updateRelatedContribution()
Function to update contribution's check_number and trxn_id by concatenating values from financial trxn's check_number and trxn_id respectively
public
static updateRelatedContribution(array<string|int, mixed> $params, int $contributionID) : void
Parameters
- $params : array<string|int, mixed>
- $contributionID : int
Tags
createFinancialItem()
Create a financial items & return the ID.
protected
static createFinancialItem(array<string|int, mixed> $lineItem, string $trxn_date, int $contactID, string $currency) : array<string|int, mixed>
Ideally this will never be called.
However, I hit a scenario in testing where 'something' had created a pending payment with no financial items and that would result in a fatal error without handling here. I failed to replicate & am not investigating via a new test methodology https://github.com/civicrm/civicrm-core/pull/15706
After this is in I will do more digging & once I feel confident new instances are not being created I will add deprecation notices into this function with a view to removing.
However, I think we want to add it in 5.20 as there is a risk of users experiencing an error if there is incorrect data & we need time to ensure that what I hit was not a 'thing. (it might be the demo site data is a bit flawed & that was the issue).
Parameters
- $lineItem : array<string|int, mixed>
- $trxn_date : string
- $contactID : int
- $currency : string
Tags
Return values
array<string|int, mixed>getPayableItems()
Get the line items for the contribution.
protected
static getPayableItems(array<string|int, mixed> $params, array<string|int, mixed> $contribution) : array<string|int, mixed>
Retrieve the financial items that need to be linked to the payment.
EntityFinancialItems will be added to the sum of the Payment total linking it to these items.
- get the outstanding balance on a line item basis.
- determine what amount is being paid on this line item - we get the total being paid for the whole contribution and determine the ratio of the balance that is being paid and then assign apply that ratio to each line item.
- if overrides have been passed in we use those amounts instead.
Parameters
- $params : array<string|int, mixed>
- $contribution : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>isPaymentCompletesContribution()
Does this payment complete the contribution.
protected
static isPaymentCompletesContribution(int $contributionID, float $paymentAmount, string $previousStatus) : bool
Parameters
- $contributionID : int
- $paymentAmount : float
- $previousStatus : string
Return values
boolloadRelatedEntities()
Load entities related to the current payment id.
protected
static loadRelatedEntities(int $id) : array<string|int, mixed>
This gives us all the data we need to send an email confirmation but avoiding getting anything not tested for the confirmations. We retrieve the 'full' event as it has been traditionally assigned in full.
Parameters
- $id : int
Tags
Return values
array<string|int, mixed> —- contact = ['id' => x, 'display_name' => y, 'email' => z]
- event = [.... full event details......]
- contribution = ['id' => x],
- payment = [payment info + payment summary info]
reverseAllocationsFromPreviousPayment()
Reverse the entity financial transactions associated with the cancelled payment.
protected
static reverseAllocationsFromPreviousPayment(array<string|int, mixed> $params, int $trxnID) : mixed
The reversals are linked to the new payment.
Parameters
- $params : array<string|int, mixed>
- $trxnID : int
Tags
updateContributionStatus()
Update the status of the contribution.
private
static updateContributionStatus(int $contributionID, string $status) : mixed
We pass the is_post_payment_create as we have already created the line items
Parameters
- $contributionID : int
- $status : string