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

Switch to passing payment_processor_id as input param to completeOrder #18528

Merged
merged 1 commit into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
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
13 changes: 1 addition & 12 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -4406,18 +4406,7 @@ public static function completeOrder($input, $ids, $objects, $isPostPaymentCreat
'financial_type_id',
];

// @todo - accept payment_processor_id as an input parameter as it is part of the
// incoming payment information (at least when coming from a payment processor).
// this is the last 'object' to get rid of....
$paymentProcessorId = '';
if (isset($objects['paymentProcessor'])) {
if (is_array($objects['paymentProcessor'])) {
$paymentProcessorId = $objects['paymentProcessor']['id'];
}
else {
$paymentProcessorId = $objects['paymentProcessor']->id;
}
}
$paymentProcessorId = $input['payment_processor_id'] ?? NULL;

$completedContributionStatusID = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');

Expand Down
1 change: 1 addition & 0 deletions CRM/Core/Payment/AuthorizeNetIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function main($component = 'contribute') {
if ($objects['contribution']->contribution_status_id == 1) {
$first = FALSE;
}
$input['payment_processor_id'] = $paymentProcessorID;
return $this->recur($input, $ids, $objects, $first);
}
}
Expand Down
2 changes: 2 additions & 0 deletions CRM/Core/Payment/PayPalIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ public function main() {
return;
}

$input['payment_processor_id'] = $paymentProcessorID;

self::$_paymentProcessor = &$objects['paymentProcessor'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can go too & we can stop passing $paymentProcessorID into validateData a few lines earlier

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton I'm less familiar with the IPN code here - do you want to do a separate PR for just those changes you are suggesting and I'll review?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so far these are the prs to do the follow up on the ipn classes that we left out of scope here

#18540
#18600

I don't just want to dive in & pull out the var until the params are a bit more sanitised

if ($component == 'contribute') {
if ($ids['contributionRecur']) {
Expand Down
2 changes: 2 additions & 0 deletions CRM/Core/Payment/PayPalProIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ public function main() {
return;
}

$input['payment_processor_id'] = $paymentProcessorID;

self::$_paymentProcessor = &$objects['paymentProcessor'];
//?? how on earth would we not have component be one of these?
// they are the only valid settings & this IPN file can't even be called without one of them
Expand Down
3 changes: 2 additions & 1 deletion api/v3/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ function civicrm_api3_contribution_repeattransaction($params) {
);
}

$input['payment_processor_id'] = civicrm_api3('contributionRecur', 'getvalue', [
$input['payment_processor_id'] = $params['payment_processor_id'] = civicrm_api3('contributionRecur', 'getvalue', [
'return' => 'payment_processor_id',
'id' => $contribution->contribution_recur_id,
]);
Expand All @@ -626,6 +626,7 @@ function civicrm_api3_contribution_repeattransaction($params) {
'financial_type_id',
'contribution_status_id',
'membership_id',
'payment_processor_id',
];
$input = array_intersect_key($params, array_fill_keys($passThroughParams, NULL));

Expand Down