Documentation

CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN
in package

Class CRM_Core_Payment_BaseIPN.

Tags
copyright

CiviCRM LLC https://civicrm.org/licensing

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

Methods

__construct()

Constructor function.

public __construct(array<string|int, mixed> $inputData) : mixed
Parameters
$inputData : array<string|int, mixed>

contents of HTTP REQUEST.

Tags
throws
CRM_Core_Exception

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
throws
CRM_Core_Exception
Return values
bool

completeTransaction()

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
throws
CRM_Core_Exception

failed()

Set contribution to failed.

public failed(array<string|int, mixed> $objects) : bool

use the api.

Parameters
$objects : array<string|int, mixed>
Tags
throws
CRM_Core_Exception
Return values
bool

getBillingID()

public getBillingID(array<string|int, mixed> &$ids) : bool

Get site billing ID.

Parameters
$ids : array<string|int, mixed>
Return values
bool

getInput()

Get the input from passed in fields.

public getInput() : array<string|int, mixed>
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

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
bool

retrieve()

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
throws
CRM_Core_Exception

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
todo

confirm this function is not being used by any payment processor outside core & remove.

Note that the compose message part has been moved to contribution In general LoadObjects is called first to get the objects but the composeMessageArray function now calls it

throws
CRM_Core_Exception

setInputParameters()

Store input array on the class.

public setInputParameters(array<string|int, mixed> $parameters) : mixed
Parameters
$parameters : array<string|int, mixed>
Tags
throws
CRM_Core_Exception

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
bool

getContributionRecurObject()

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
throws
CRM_Core_Exception
Return values
CRM_Core_DAO|DB_Error|object

getRecurProcessorID()

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
throws
CRM_Core_Exception
Return values
string

cancelMembership()

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
todo

This is part of a bigger refactor for dev/core/issues/927 - "duplicate" functionality exists in CRM_Contribute_BAO_Contribution::cancel()

fixme

Historically failed() cancelled membership in any status, cancelled() cancelled only pending memberships so we retain that behaviour for now.

cancelParticipant()

Logic to cancel a participant record when the related contribution changes to failed/cancelled.

private cancelParticipant(mixed $participantID) : mixed
Parameters
$participantID : mixed
Tags
todo

This is part of a bigger refactor for dev/core/issues/927 - "duplicate" functionality exists in CRM_Contribute_BAO_Contribution::cancel()

throws
CRM_Core_Exception

getContributionStatus()

Get the relevant contribution status.

private getContributionStatus() : string
Tags
throws
CRM_Core_Exception
Return values
string

$status


        
On this page

Search results