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#77 ++ Make contribution_id mandatory for PaymentProcessor.pay, pass invoiceID #15639

Merged
merged 1 commit into from
Oct 28, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Oct 28, 2019

Overview

Replaces #15477 & also resolves https://lab.civicrm.org/dev/financial/issues/77

As discussed in Barcelona - requiring contribution_id for PaymentProcessor.pay as a way to ensure that it is only called after the order is created
per our preferred flow (people could still get past this by passing a random number - but it feels like they would at least know they were hacking our process & take responsibility for any issues if it breaks or we suddenly start enforcing that
it is a valid contribution.

This also sets some of the recommended variables.

Before

contribution_id not required by API PaymentProcessor.pay.

After

contribution_id required by API PaymentProcessor.pay.

Technical Details

See https://lab.civicrm.org/dev/financial/issues/53.

Technical Details

@mattwire it seems the test for https://lab.civicrm.org/dev/financial/issues/77 could easily also cover #15477 so I incorporated it.

Note that I had to use a few more lines to ensure we were always setting contactID, contributionRecurID to an integer. I do think this stricter approach is better but it wound up
more verbose

Comments

@civibot
Copy link

civibot bot commented Oct 28, 2019

(Standard links)

…or.pay, pass incoieID

Replaces civicrm#15477 & also resolves https://lab.civicrm.org/dev/financial/issues/77

by requiring contribution_id for PaymentProcessor.pay as a way to ensure that it is only called after the order is created
per our preferred flow (people could still get past this but it feels like they would at least know they werre
hacking our process & take responsibility for any issues if it breaks or we suddenly start enforcing that
it is a valid contribution.

This also sets some of the recommended variables. Note that I had to use a few more lines to ensure we were always setting
contactID, contributionRecurID to an integer. I do think this stricter approach is better but it wound up
more verbose
$processor = Civi\Payment\System::singleton()->getById($params['payment_processor_id']);
$processor->setPaymentProcessor(civicrm_api3('PaymentProcessor', 'getsingle', ['id' => $params['payment_processor_id']]));
try {
$processor->setContributionID($params['contribution_id']);
$processor->setInvoiceID($params['invoice_id'] ?? '');
Copy link
Contributor

Choose a reason for hiding this comment

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

@eileenmcnaughton What did we agree in terms of invoice_id? This means that we'll end up with an empty invoice ID if not passed in via params. Maybe that's ok!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mattwire yep - it has to be passed in! We talked about Order.create adding one here https://lab.civicrm.org/dev/financial/issues/78 but haven't resolved that & although I marked it 'high' here https://lab.civicrm.org/dev/financial/issues/76 I'm re-thinking that & am probably not seeing it as something to worry about until some of the other things have been done

@mattwire
Copy link
Contributor

@eileenmcnaughton Apart from the query on invoice_id this is good to merge

@eileenmcnaughton
Copy link
Contributor Author

@mattwire FYI the invoice_id one shouldn't have a negative effect - it just means that it will be passed through if available

@eileenmcnaughton eileenmcnaughton merged commit cbaa9a3 into civicrm:master Oct 28, 2019
@eileenmcnaughton eileenmcnaughton deleted the pay branch October 28, 2019 11:32
wmfgerrit pushed a commit to wikimedia/wikimedia-fundraising-crm that referenced this pull request Feb 4, 2021
Ever since civicrm/civicrm-core#15639 was implemented we have been hacking it
back out of our civicrm code base each point version update. We did have a chance in Barcelona
to veto this change but we committed to being good code citizens & updating our code to comply.
That day has not yet come so I'm changing the hack to require less ongoing maintenance
until we reach the point of becoming good code citizens. This hack will not
need to be re-applied regularly and should be no less risky than our previous hack

Bug: T272061
Change-Id: I42e6fc795ecf6fd4224d2631e3422685749699ce
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.

2 participants