CRM_Core_Payment_BaseIPN
in package
Class CRM_Core_Payment_BaseIPN.
Table of Contents
Properties
- $_now : mixed
- $_inputParameters : array<string|int, mixed>
- Input parameters from payment processor. Store these so that the code does not need to keep retrieving from the http request
- $_isFirstOrLastRecurringPayment : bool
- Only used by AuthorizeNetIPN.
- $_isRecurring : bool
- Only used by AuthorizeNetIPN.
Methods
- __construct() : mixed
- Constructor.
- cancelled() : bool
- Process cancelled payment outcome.
- completeTransaction() : mixed
- failed() : bool
- Set contribution to failed.
- getBillingID() : bool
- pending() : bool
- Handled pending contribution status.
- sendMail() : mixed
- setInputParameters() : mixed
- Store input array on the class.
- unhandled() : bool
- Rollback unhandled outcomes.
- cancelMembership() : mixed
- Logic to cancel a membership record when the related contribution changes to failed/cancelled.
- cancelParticipant() : mixed
- Logic to cancel a participant record when the related contribution changes to failed/cancelled.
Properties
$_now
public
static mixed
$_now
= \NULL
$_inputParameters
Input parameters from payment processor. Store these so that the code does not need to keep retrieving from the http request
protected
array<string|int, mixed>
$_inputParameters
= []
$_isFirstOrLastRecurringPayment
Only used by AuthorizeNetIPN.
protected
bool
$_isFirstOrLastRecurringPayment
= \FALSE
$_isRecurring
Only used by AuthorizeNetIPN.
protected
bool
$_isRecurring
= \FALSE
Methods
__construct()
Constructor.
public
__construct() : mixed
cancelled()
Process cancelled payment outcome.
public
cancelled(array<string|int, mixed> $objects) : bool
The intended replacement code is
Contribution::update(FALSE)->setValues([ 'cancel_date' => 'now', 'contribution_status_id:name' => 'Cancelled', ])->addWhere('id', '=', $contribution->id)->execute();
Parameters
- $objects : array<string|int, mixed>
Tags
Return values
boolcompleteTransaction()
public
completeTransaction(array<string|int, mixed> $input, array<string|int, mixed> $ids, array<string|int, mixed> $objects) : mixed
Jumbled up function.
The purpose of this function is to transition a pending transaction to Completed including updating any related entities.
It has been overloaded to also add recurring transactions to the database, cloning the original transaction and updating related entities.
It is recommended to avoid calling this function directly and call the api functions:
- contribution.completetransaction
- contribution.repeattransaction
These functions are the focus of testing efforts and more accurately reflect the division of roles (the job of the IPN class is to determine the outcome, transaction id, invoice id & to validate the source and from there it should be possible to pass off transaction management.)
This function has been problematic for some time but there are now several tests via the api_v3_Contribution test and the Paypal & Authorize.net IPN tests so any refactoring should be done in conjunction with those.
This function needs to have the 'body' moved to the CRM_Contribute_BAO_Contribute class and to undergo refactoring to separate the complete transaction and repeat transaction functionality into separate functions with a shared function that updates related components.
Note that it is not necessary payment processor extension to implement an IPN class now. In general the code on the IPN class is better accessed through the api which de-jumbles it a bit.
e.g the payment class can have a function like (based on Omnipay extension):
public function handlePaymentNotification() { $response = $this->getValidatedOutcome(); if ($response->isSuccessful()) { try { // @todo check if it is a repeat transaction & call repeattransaction instead. civicrm_api3('contribution', 'completetransaction', array('id' => $this->transaction_id)); } catch (CRM_Core_Exception $e) { if (!stristr($e->getMessage(), 'Contribution already completed')) { $this->handleError('error', $this->transaction_id . $e->getMessage(), 'ipn_completion', 9000, 'An error may have occurred. Please check your receipt is correct'); $this->redirectOrExit('success'); } elseif ($this->transaction_id) { civicrm_api3('contribution', 'create', array('id' => $this->transaction_id, 'contribution_status_id' => 'Failed')); }
Parameters
- $input : array<string|int, mixed>
- $ids : array<string|int, mixed>
- $objects : array<string|int, mixed>
Tags
failed()
Set contribution to failed.
public
failed(array<string|int, mixed> $objects) : bool
use the api.
Parameters
- $objects : array<string|int, mixed>
Tags
Return values
boolgetBillingID()
public
getBillingID(array<string|int, mixed> &$ids) : bool
Get site billing ID.
Parameters
- $ids : array<string|int, mixed>
Return values
boolpending()
Handled pending contribution status.
public
pending(array<string|int, mixed> &$objects, object &$transaction) : bool
Parameters
- $objects : array<string|int, mixed>
- $transaction : object
Return values
boolsendMail()
public
sendMail(array<string|int, mixed> $input, array<string|int, mixed> $ids, array<string|int, mixed> $objects) : mixed
Parameters
- $input : array<string|int, mixed>
-
Incoming data from Payment processor.
- $ids : array<string|int, mixed>
-
Related object IDs.
- $objects : array<string|int, mixed>
Tags
setInputParameters()
Store input array on the class.
public
setInputParameters(array<string|int, mixed> $parameters) : mixed
Parameters
- $parameters : array<string|int, mixed>
Tags
unhandled()
Rollback unhandled outcomes.
public
unhandled(array<string|int, mixed> &$objects, CRM_Core_Transaction &$transaction) : bool
Parameters
- $objects : array<string|int, mixed>
- $transaction : CRM_Core_Transaction
Return values
boolcancelMembership()
Logic to cancel a membership record when the related contribution changes to failed/cancelled.
private
cancelMembership(CRM_Member_BAO_Membership $membership, int $membershipStatusID[, bool $onlyCancelPendingMembership = TRUE ]) : mixed
Parameters
- $membership : CRM_Member_BAO_Membership
- $membershipStatusID : int
- $onlyCancelPendingMembership : bool = TRUE
-
Do we only cancel pending memberships? OR memberships in any status? (see CRM-18688)
Tags
cancelParticipant()
Logic to cancel a participant record when the related contribution changes to failed/cancelled.
private
cancelParticipant(mixed $participantID) : mixed
Parameters
- $participantID : mixed