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

Cleanup variable assigns in ContributionPage confirm #22902

Merged
merged 1 commit into from
Mar 19, 2022

Conversation

mattwire
Copy link
Contributor

@mattwire mattwire commented Mar 7, 2022

Overview

Cleanup and simplify some variable assigns.

Before

More complicated.

After

Less complicated.

Technical Details

See inline comments on this PR

Comments

@civibot
Copy link

civibot bot commented Mar 7, 2022

(Standard links)

@civibot civibot bot added the master label Mar 7, 2022
if (!empty($result['payment_status_id'])) {
$contribution->payment_status_id = $result['payment_status_id'];
}
$form->assign('trxn_id', $result['trxn_id'] ?? '');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simpler to use NULL coalescing operator here.

$contribution->payment_status_id = $result['payment_status_id'];
}
$form->assign('trxn_id', $result['trxn_id'] ?? '');
$contribution->trxn_id = $result['trxn_id'] ?? $contribution->trxn_id ?? '';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rather than checking if return value from doPayment is empty we assign via a hierarchy which clearly shows priority

}
$form->assign('trxn_id', $result['trxn_id'] ?? '');
$contribution->trxn_id = $result['trxn_id'] ?? $contribution->trxn_id ?? '';
$contribution->payment_status_id = $result['payment_status_id'];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any payment processor that does not return payment_status_id is going to be broken in multiple ways because it is the only way to check if payment was successful..

@eileenmcnaughton
Copy link
Contributor

Yep agree. Thanks @mattwire

@eileenmcnaughton eileenmcnaughton merged commit 1097f93 into civicrm:master Mar 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants