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

dev/financial#141 - Update return parameters on all payment processors to match expected results #22683

Merged
merged 1 commit into from
Apr 21, 2022

Conversation

mattwire
Copy link
Contributor

@mattwire mattwire commented Feb 2, 2022

Overview

Switch to using helper functions setStatusPaymentPending() and setStatusPaymentCompleted() for all core payment processors. This will help with transitioning from payment_status_id to payment_status.

See https://lab.civicrm.org/dev/financial/-/issues/141. Follow on from #22680

Before

Each payment processor sets the payment return status manually.

After

Each payment processor sets the payment return status by calling a standard helper function. This means that we have a path to deprecate payment_status_id in the future by "switching it off" in the helper functions if we wanted to.

Technical Details

Comments

@civibot
Copy link

civibot bot commented Feb 2, 2022

(Standard links)

@civibot civibot bot added the master label Feb 2, 2022
@mattwire mattwire changed the title WIP Update return parameters on all payment processors to match expected results Update return parameters on all payment processors to match expected results Mar 9, 2022
@mattwire mattwire marked this pull request as ready for review March 9, 2022 21:43
@mattwire
Copy link
Contributor Author

[CRM_Contribute_Form_ContributionTest.testSubmitCreditCardPayPal](https://test.civicrm.org/job/CiviCRM-Core-PR/47430/testReport/junit/(root)/CRM_Contribute_Form_ContributionTest/testSubmitCreditCardPayPal/)
[CRM_Core_Payment_PaypalProTest.testSinglePayment](https://test.civicrm.org/job/CiviCRM-Core-PR/47430/testReport/junit/(root)/CRM_Core_Payment_PaypalProTest/testSinglePayment/)

}

$params['trxn_result_code'] = $processorResponse['ssl_approval_code'] . "-Cvv2:" . $processorResponse['ssl_cvv2_response'] . "-avs:" . $processorResponse['ssl_avs_response'];
$params['payment_status_id'] = array_search('Completed', $statuses);
Copy link
Contributor

Choose a reason for hiding this comment

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

A couple of these processors set $params['trxn_result_code'] (line 236 here) but then it's not being set in $result, so the return value of the function won't contain it anymore.

Also the signature for doPayment is &$params, so by changing all the $params to $result, it is no longer altering $params like it did before. Maybe that's ok and no callers are relying on that - I'm not familiar with how doPayment() is used in practice. It might even be a good thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@demeritcowboy I realised this PR didn't have the linked lab issue and previous PR - now added to the description. We can't actually change the pass-by-reference signature because that will cause PHP errors but basically no calling code should be using the pass-by-reference result (none is in core and I'm not aware of third-party code that is).
trxn_result_code was set by various core processors but is not used anywhere - maybe it was once upon a time.

$params['trxn_result_code'] = serialize($extras);
$params['currencyID'] = $this->_getParam('currency');
$params['fee_amount'] = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Also currencyID here same as trxn_result_code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See comment above - have now added link to lab issue where we agreed return parameters.

@demeritcowboy
Copy link
Contributor

Ok got it.

Jenkins retest this please since it's been a while.

@demeritcowboy demeritcowboy changed the title Update return parameters on all payment processors to match expected results dev/financial#141 - Update return parameters on all payment processors to match expected results Apr 21, 2022
@demeritcowboy demeritcowboy merged commit b983f32 into civicrm:master Apr 21, 2022
@mattwire mattwire deleted the paymentstatushelpersall branch April 21, 2022 21:43
@mattwire
Copy link
Contributor Author

Thanks @demeritcowboy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants