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

Fix propertyBag regression on amount #23301

Merged
merged 1 commit into from
Apr 26, 2022

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Apr 25, 2022

Overview

Fixes a regression by payment processors from this line

https://github.com/civicrm/civicrm-core/pull/21583/files#diff-c8d9bcea3e41ecc2ae13f5b654fefbbe3e95a73c9066b83017af82204533f9d2R29

The expectation is that functions calling doPayment pass the parameters in documented here

https://docs.civicrm.org/dev/en/latest/extensions/payment-processors/create/#available-parameters

In some cases the parameter passing has been historically inconsistent and the PropertyBag has been a technical solution to help with that inconsistency - e.g a form might not have passed billing address fields and the syntax when they do is a bit nasty - e.g billing_street_address-{$billingLocationID} so a payment processor may choose to implement the property bag to get easier access to the properties passed in.

However, the documented parameters are the ones that should be prioritised for use (where the calling code sloppily passes in more than one similar property) - and in the case of amount the amount field has been used by many processors for many years and we now know of at least one scenario where total_amount is actually incorrect to use.

I don't think we should have a 'sloppy alternative'
to being called with the correct documented
amount property

Before

When both the contracted property amount and the non-required property total_amount are passed in the cast function treats total_amount as the amount

After

As per before #21583 - amount is used, total_amount is ignored

Technical details

@mattwire - this reverses just the line of the PR you merged that appears to be causing problems - the more I think about it the more I think the line should go - we definitely want functions that call doPayment to do so with the documented parameters. The point of the propertyBag (as I understand it) was to help out where they didn't - but not to make it so the calling code could be more loose about what it passes

This appears to have caused a regression per
https://lab.civicrm.org/dev/core/-/issues/3413

In addition I don't think we should have a 'sloppy alternative'
to  being called with the correct documented
amount property

https://docs.civicrm.org/dev/en/latest/extensions/payment-processors/create/#available-parameters
@civibot
Copy link

civibot bot commented Apr 25, 2022

(Standard links)

@civibot civibot bot added the 5.49 label Apr 25, 2022
@eileenmcnaughton eileenmcnaughton changed the title 549 amount Fix propertyBag regression on amount Apr 25, 2022
@artfulrobot
Copy link
Contributor

I agree this makes good sense, since total_amount is not documented it should not be used. (supplying both and casting will, as others have found, mean the last one in the supplied array wins, and since total_amount may be locale-formatted, cause the wrong amount to be stored.)

@eileenmcnaughton
Copy link
Contributor Author

thanks for taking a look @artfulrobot

@mattwire
Copy link
Contributor

Yes, makes sense. I think this was added because something somewhere was passing total_amount. But if we find out what that was we should fix it there instead.

@mattwire mattwire merged commit 72bcba6 into civicrm:5.49 Apr 26, 2022
@eileenmcnaughton eileenmcnaughton deleted the 549_amount branch April 26, 2022 19:02
@magnolia61
Copy link
Contributor

Thank you for working together on this and figuring out the issue. Appreciate that!

@eileenmcnaughton
Copy link
Contributor Author

@magnolia61 thanks for pinpointing the issue

@magnolia61
Copy link
Contributor

Is it too late for this to make its way to the RC as it is a regression?

@eileenmcnaughton
Copy link
Contributor Author

@magnolia61 it IS in the rc - which is due for release next Wed - I was on the fence about asking @totten to drop a release of 5.48 prior to then

@magnolia61
Copy link
Contributor

Oh, nice. Thats fine. High impact but kind of niche still.

@eileenmcnaughton
Copy link
Contributor Author

@magnolia61 yeah - with a week to go to 5.49 it is a bit borderline - if #23295 gets turned around quickly-ish then I think I will push for it to go out before next Wed

@eileenmcnaughton eileenmcnaughton mentioned this pull request Apr 29, 2022
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.

4 participants