CRM_Financial_BAO_Payment
class CRM_Financial_BAO_Payment
This class contains payment related functions.
Methods
Function to process additional payment for partial and refund contributions.
Send an email confirming a payment that has been received.
Get valid from emails for payment.
Load entities related to the current payment id.
No description
No description
Filter out any untested variables.
Does this payment complete the contribution
Get the line items for the contribution.
Get the amount paid so far against this line item.
Reverse the entity financial transactions associated with the cancelled payment.
Create a financial items & return the ID.
Details
at line 55
static CRM_Financial_DAO_FinancialTrxn
create(array $params)
Function to process additional payment for partial and refund contributions.
This function is called via API payment.create function. All forms that add payments should use this.
at line 181
static array
sendConfirmation(array $params)
Send an email confirming a payment that has been received.
at line 212
static array
getValidFromEmailsForPayment(int $eventID = NULL)
Get valid from emails for payment.
at line 238
static protected array
loadRelatedEntities(int $id)
Load entities related to the current payment id.
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.
at line 282
static int
getPaymentContactID(int $contributionID)
at line 300
static array
getConfirmationTemplateParameters(array $entities)
at line 335
static array
filterUntestedTemplateVariables(array $params)
Filter out any untested variables.
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).
at line 384
static protected bool
isPaymentCompletesContribution(int $contributionID, float $paymentAmount)
Does this payment complete the contribution
at line 426
static protected array
getPayableLineItems($params)
Get the line items for the contribution.
Retrieve the line items and wrangle the following
- 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.
at line 469
static protected float
getAmountOfLineItemPaid(int $lineItemID)
Get the amount paid so far against this line item.
at line 500
static protected
reverseAllocationsFromPreviousPayment(array $params, int $trxnID)
Reverse the entity financial transactions associated with the cancelled payment.
The reversals are linked to the new payemnt.
at line 543
static protected int
getNewFinancialItemID(array $lineItem, string $trxn_date, int $contactID, string $currency)
Create a financial items & return the ID.
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).