CRM_Core_Payment_AuthorizeNetIPN
extends CRM_Core_Payment_BaseIPN
in package
Class CRM_Core_Payment_BaseIPN.
Tags
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.
- $contributionStatus : string
- $transactionID : string
Methods
- __construct() : mixed
- Constructor function.
- cancelled() : bool
- Process cancelled payment outcome.
- completeTransaction() : mixed
- failed() : bool
- Set contribution to failed.
- getBillingID() : bool
- getInput() : array<string|int, mixed>
- Get the input from passed in fields.
- main() : mixed
- Main IPN processing function.
- notify() : mixed
- pending() : bool
- Handled pending contribution status.
- retrieve() : mixed
- sendMail() : mixed
- setInputParameters() : mixed
- Store input array on the class.
- unhandled() : bool
- Rollback unhandled outcomes.
- getAmount() : string
- Get amount.
- getContributionID() : int
- Get the contribution ID to be updated.
- getContributionRecurID() : int
- Get the id of the recurring contribution.
- getContributionRecurObject() : CRM_Core_DAO|DB_Error|object
- Get the recurring contribution object.
- getPaymentProcessorID() : int
- Get the payment processor id.
- getRecurProcessorID() : string
- Get the processor_id for the recurring.
- 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.
- getContributionRecur() : CRM_Contribute_BAO_ContributionRecur
- getContributionStatus() : string
- Get the relevant contribution status.
- isSuccess() : bool
- Was the transaction successful.
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
$contributionStatus
protected
string
$contributionStatus
$transactionID
protected
string
$transactionID
Methods
__construct()
Constructor function.
public
__construct(array<string|int, mixed> $inputData) : mixed
Parameters
- $inputData : array<string|int, mixed>
-
contents of HTTP REQUEST.
Tags
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
boolgetInput()
Get the input from passed in fields.
public
getInput() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>main()
Main IPN processing function.
public
main() : mixed
notify()
public
notify() : mixed
Tags
pending()
Handled pending contribution status.
public
pending(array<string|int, mixed> &$objects, object &$transaction) : bool
Parameters
- $objects : array<string|int, mixed>
- $transaction : object
Return values
boolretrieve()
public
retrieve(string $name, string $type[, bool $abort = TRUE ][, null $default = NULL ]) : mixed
Parameters
- $name : string
-
Parameter name.
- $type : string
-
Parameter type.
- $abort : bool = TRUE
-
Abort if not present.
- $default : null = NULL
-
Default value.
Tags
sendMail()
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
boolgetAmount()
Get amount.
protected
getAmount() : string
Tags
Return values
stringgetContributionID()
Get the contribution ID to be updated.
protected
getContributionID() : int
Tags
Return values
intgetContributionRecurID()
Get the id of the recurring contribution.
protected
getContributionRecurID() : int
Tags
Return values
intgetContributionRecurObject()
Get the recurring contribution object.
protected
getContributionRecurObject(string $processorID, int $contactID, int $contributionID) : CRM_Core_DAO|DB_Error|object
Parameters
- $processorID : string
- $contactID : int
- $contributionID : int
Tags
Return values
CRM_Core_DAO|DB_Error|objectgetPaymentProcessorID()
Get the payment processor id.
protected
getPaymentProcessorID() : int
Tags
Return values
intgetRecurProcessorID()
Get the processor_id for the recurring.
protected
getRecurProcessorID() : string
This is the value stored in civicrm_contribution_recur.processor_id, sometimes called subscription_id.
Tags
Return values
stringcancelMembership()
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
Tags
getContributionRecur()
private
getContributionRecur() : CRM_Contribute_BAO_ContributionRecur
Tags
Return values
CRM_Contribute_BAO_ContributionRecurgetContributionStatus()
Get the relevant contribution status.
private
getContributionStatus() : string
Tags
Return values
string —$status
isSuccess()
Was the transaction successful.
private
isSuccess() : bool