CRM_Core_Payment_PayPalIPN
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.
- $contribution : mixed
Methods
- __construct() : mixed
- Constructor function.
- cancelled() : bool
- Process cancelled payment outcome.
- completeTransaction() : mixed
- failed() : bool
- Set contribution to failed.
- getBillingID() : bool
- getInput() : mixed
- getPayPalPaymentProcessorID() : int
- Get PaymentProcessorID for PayPal
- main() : mixed
- Main function.
- pending() : bool
- Handled pending contribution status.
- recur() : void
- retrieve() : mixed
- sendMail() : mixed
- setInputParameters() : mixed
- Store input array on the class.
- single() : void
- unhandled() : bool
- Rollback unhandled outcomes.
- getContactID() : int
- Get contact id from parameters.
- getContribution() : CRM_Contribute_BAO_Contribution
- Get the contribution object.
- getContributionID() : int
- Get Contribution ID.
- getContributionRecurID() : int|null
- Get the recurring contribution ID.
- getTrxnType() : mixed
- 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
$contribution
private
mixed
$contribution
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()
public
getInput(array<string|int, mixed> &$input) : mixed
Parameters
- $input : array<string|int, mixed>
Tags
getPayPalPaymentProcessorID()
Get PaymentProcessorID for PayPal
public
getPayPalPaymentProcessorID(array<string|int, mixed> $input, int|null $contributionRecurID) : int
Parameters
- $input : array<string|int, mixed>
- $contributionRecurID : int|null
Tags
Return values
intmain()
Main function.
public
main() : 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
boolrecur()
public
recur(array<string|int, mixed> $input) : void
Parameters
- $input : array<string|int, mixed>
Tags
retrieve()
public
retrieve(string $name, string $type[, bool $abort = TRUE ]) : mixed
Parameters
- $name : string
- $type : string
- $abort : bool = TRUE
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
single()
public
single(array<string|int, mixed> $input[, bool $recur = FALSE ]) : void
Parameters
- $input : array<string|int, mixed>
- $recur : bool = FALSE
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
boolgetContactID()
Get contact id from parameters.
protected
getContactID() : int
Tags
Return values
intgetContribution()
Get the contribution object.
protected
getContribution() : CRM_Contribute_BAO_Contribution
Tags
Return values
CRM_Contribute_BAO_ContributiongetContributionID()
Get Contribution ID.
protected
getContributionID() : int
Tags
Return values
intgetContributionRecurID()
Get the recurring contribution ID.
protected
getContributionRecurID() : int|null
Tags
Return values
int|nullgetTrxnType()
protected
getTrxnType() : mixed
Tags
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
cancelParticipant()
Logic to cancel a participant record when the related contribution changes to failed/cancelled.
private
cancelParticipant(mixed $participantID) : mixed
Parameters
- $participantID : mixed