Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] [towards dev/core#2693] Use getter rather than passing variable #20852

Merged
merged 1 commit into from
Jul 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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