class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN

Properties

static $_now from CRM_Core_Payment_BaseIPN
protected array $_inputParameters Input parameters from payment processor. Store these so that the code does not need to keep retrieving from the http request
protected bool $_isRecurring Only used by AuthorizeNetIPN. from CRM_Core_Payment_BaseIPN
protected bool $_isFirstOrLastRecurringPayment Only used by AuthorizeNetIPN. from CRM_Core_Payment_BaseIPN
static $_paymentProcessor
protected array $_invoiceData Store for the variables from the invoice string.
protected $_isPaymentExpress Is this a payment express transaction.
protected string $_component Are we dealing with an event an 'anything else' (contribute)

Methods

__construct(array $inputData)

Constructor function.

setInputParameters(array $parameters)

Store input array on the class.

bool
validateData(array $input, array $ids, array $objects, bool $required = TRUE, int $paymentProcessorID = NULL)

Validate incoming data.

bool|array
loadObjects(array $input, array $ids, array $objects, bool $required, int $paymentProcessorID, array $error_handling = NULL)

Load objects related to contribution.

bool
failed(array $objects, object $transaction, array $input = array())

Set contribution to failed.

bool
pending(array $objects, object $transaction)

Handled pending contribution status.

bool
cancelled(array $objects, CRM_Core_Transaction $transaction, array $input = array())

Process cancelled payment outcome.

bool
unhandled(array $objects, CRM_Core_Transaction $transaction)

Rollback unhandled outcomes.

completeTransaction(array $input, array $ids, array $objects, CRM_Core_Transaction $transaction, bool $recur = FALSE) deprecated

No description

bool
getBillingID(array $ids)

Get site billing ID.

array
sendMail(array $input, array $ids, array $objects, array $values, bool $recur = FALSE, bool $returnMessageText = FALSE) deprecated

No description

mixed
getValue(string $name, bool $abort = TRUE)

get the values from the rp_invoice_id string.

setInvoiceData()

Set $this->_invoiceData from the input array

mixed
retrieve(string $name, string $type, string $location = 'POST', bool $abort = TRUE)

No description

bool
recur(array $input, array $ids, array $objects, bool $first)

Process recurring contributions.

bool
single($input, $ids, $objects, bool $recur = FALSE, bool $first = FALSE)

No description

int
getPayPalPaymentProcessorID()

Gets PaymentProcessorID for PayPal

bool
main()

This is the main function to call. It should be sufficient to instantiate the class (with the input parameters) & call this & all will be done

bool
getInput($input, $ids)

No description

handlePaymentExpress()

Handle payment express IPNs.

bool|void
transactionExists(string $trxn_id)

Function check if transaction already exists.

Details

at line 69
__construct(array $inputData)

Constructor function.

Parameters

array $inputData Contents of HTTP REQUEST.

Exceptions

CRM_Core_Exception

setInputParameters(array $parameters)

Store input array on the class.

Parameters

array $parameters

Exceptions

CRM_Core_Exception

bool validateData(array $input, array $ids, array $objects, bool $required = TRUE, int $paymentProcessorID = NULL)

Validate incoming data.

This function is intended to ensure that incoming data matches It provides a form of pseudo-authentication - by checking the calling fn already knows the correct contact id & contribution id (this can be problematic when that has changed in the meantime for transactions that are delayed & contacts are merged in-between. e.g Paypal allows you to resend Instant Payment Notifications if you, for example, moved site and didn't update your IPN URL.

Parameters

array $input Interpreted values from the values returned through the IPN.
array $ids More interpreted values (ids) from the values returned through the IPN.
array $objects An empty array that will be populated with loaded object.
bool $required Boolean Return FALSE if the relevant objects don't exist.
int $paymentProcessorID Id of the payment processor ID in use.

Return Value

bool

bool|array loadObjects(array $input, array $ids, array $objects, bool $required, int $paymentProcessorID, array $error_handling = NULL)

Load objects related to contribution.

Parameters

array $input
array $ids
array $objects
bool $required
int $paymentProcessorID
array $error_handling

Return Value

bool|array

bool failed(array $objects, object $transaction, array $input = array())

Set contribution to failed.

Parameters

array $objects
object $transaction
array $input

Return Value

bool

bool pending(array $objects, object $transaction)

Handled pending contribution status.

Parameters

array $objects
object $transaction

Return Value

bool

bool cancelled(array $objects, CRM_Core_Transaction $transaction, array $input = array())

Process cancelled payment outcome.

Parameters

array $objects
CRM_Core_Transaction $transaction
array $input

Return Value

bool

bool unhandled(array $objects, CRM_Core_Transaction $transaction)

Rollback unhandled outcomes.

Parameters

array $objects
CRM_Core_Transaction $transaction

Return Value

bool

completeTransaction(array $input, array $ids, array $objects, CRM_Core_Transaction $transaction, bool $recur = FALSE) deprecated

deprecated 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_Contribution_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 (CiviCRM_API3_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

array $input
array $ids
array $objects
CRM_Core_Transaction $transaction
bool $recur

bool getBillingID(array $ids)

Get site billing ID.

Parameters

array $ids

Return Value

bool

array sendMail(array $input, array $ids, array $objects, array $values, bool $recur = FALSE, bool $returnMessageText = FALSE) deprecated

deprecated

Parameters

array $input Incoming data from Payment processor.
array $ids Related object IDs.
array $objects
array $values Values related to objects that have already been loaded.
bool $recur Is it part of a recurring contribution.
bool $returnMessageText Should text be returned instead of sent. This. is because the function is also used to generate pdfs

Return Value

array

at line 86
mixed getValue(string $name, bool $abort = TRUE)

get the values from the rp_invoice_id string.

Parameters

string $name E.g. i, values are stored in the string with letter codes.
bool $abort Throw exception if not found

Return Value

mixed

Exceptions

CRM_Core_Exception

at line 98
setInvoiceData()

Set $this->_invoiceData from the input array

at line 146
mixed retrieve(string $name, string $type, string $location = 'POST', bool $abort = TRUE)

Parameters

string $name Of variable to return.
string $type Data type. - String - Integer
string $location Deprecated.
bool $abort Abort if empty.

Return Value

mixed

Exceptions

CRM_Core_Exception

at line 166
bool recur(array $input, array $ids, array $objects, bool $first)

Process recurring contributions.

Parameters

array $input
array $ids
array $objects
bool $first

Return Value

bool

at line 331
bool single($input, $ids, $objects, bool $recur = FALSE, bool $first = FALSE)

Parameters

$input
$ids
$objects
bool $recur
bool $first

Return Value

bool

at line 392
int getPayPalPaymentProcessorID()

Gets PaymentProcessorID for PayPal

Return Value

int

at line 417
bool main()

This is the main function to call. It should be sufficient to instantiate the class (with the input parameters) & call this & all will be done

Return Value

bool

at line 506
bool getInput($input, $ids)

Parameters

$input
$ids

Return Value

bool

Exceptions

CRM_Core_Exception

at line 552
handlePaymentExpress()

Handle payment express IPNs.

For one off IPNS no actual response is required Recurring is more difficult as we have limited confirmation material lets look up invoice id in recur_contribution & rely on the unique transaction id to ensure no duplicated this may not be acceptable to all sites - e.g. if they are shipping or delivering something in return then the quasi security of the ids array might be required - although better to http://stackoverflow.com/questions/4848227/validate-that-ipn-call-is-from-paypal but let's assume knowledge on invoice id & schedule is enough for now esp for donations only contribute is handled

at line 608
bool|void transactionExists(string $trxn_id)

Function check if transaction already exists.

Parameters

string $trxn_id

Return Value

bool|void