Skip to content

Commit

Permalink
Merge pull request #20852 from eileenmcnaughton/paypal
Browse files Browse the repository at this point in the history
[REF] [towards dev/core#2693] Use getter rather than passing variable
  • Loading branch information
eileenmcnaughton authored Jul 15, 2021
2 parents e372c47 + e02cd78 commit dcd6fcb
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions CRM/Core/Payment/PayPalIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,7 @@ public function retrieve($name, $type, $abort = TRUE) {
* @throws \CiviCRM_API3_Exception
*/
public function recur($input, $recur, $contribution, $first) {
if (!isset($input['txnType'])) {
Civi::log()->debug('PayPalIPN: Could not find txn_type in input request');
echo "Failure: Invalid parameters<p>";
return;
}

if ($input['txnType'] === 'subscr_payment' &&
if ($this->getTrxnType() === 'subscr_payment' &&
$input['paymentStatus'] !== 'Completed'
) {
Civi::log()->debug('PayPalIPN: Ignore all IPN payments that are not completed');
Expand All @@ -94,9 +88,8 @@ public function recur($input, $recur, $contribution, $first) {
$now = date('YmdHis');

// set transaction type
$txnType = $this->getTrxnType();
$contributionStatuses = array_flip(CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'validate'));
switch ($txnType) {
switch ($this->getTrxnType()) {
case 'subscr_signup':
$recur->create_date = $now;
// sometimes subscr_signup response come after the subscr_payment and set to pending mode.
Expand Down Expand Up @@ -151,7 +144,7 @@ public function recur($input, $recur, $contribution, $first) {

$recur->save();

if ($txnType !== 'subscr_payment') {
if ($this->getTrxnType() !== 'subscr_payment') {
return;
}

Expand Down Expand Up @@ -336,7 +329,6 @@ public function main() {
*/
public function getInput(&$input) {
$billingID = CRM_Core_BAO_LocationType::getBilling();
$input['txnType'] = $this->retrieve('txn_type', 'String', FALSE);
$input['paymentStatus'] = $this->retrieve('payment_status', 'String', FALSE);
$input['invoice'] = $this->retrieve('invoice', 'String', TRUE);
$input['amount'] = $this->retrieve('mc_gross', 'Money', FALSE);
Expand Down Expand Up @@ -428,8 +420,7 @@ public function getPayPalPaymentProcessorID(array $input, ?int $contributionRecu
* @throws \CRM_Core_Exception
*/
protected function getTrxnType() {
$txnType = $this->retrieve('txn_type', 'String');
return $txnType;
return $this->retrieve('txn_type', 'String');
}

/**
Expand Down

0 comments on commit dcd6fcb

Please sign in to comment.