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

Remove unused paymentInstrumentID from forms and fix regression #17589

Closed
wants to merge 1 commit into from

Conversation

mattwire
Copy link
Contributor

@mattwire mattwire commented Jun 12, 2020

Overview

As identified by https://lab.civicrm.org/extensions/smartdebit/-/issues/2 there is a core regression around the paymentInstrumentID using the default instead of the payment processor.

As pointed out by @eileenmcnaughton (#17510) we should be using the payment processor paymentInstrumentID. Prior to 5.21 (when propertyBag was introduced) we were because of a bug in setPaymentInstrumentID() which ignored the incoming parameter. That was fixed with propertyBag which meant that we started using the default paymentInstrumentID (incorrectly in most cases).
Going through the code I identified that in most cases we were getting a default and assigning it to the form (even supporting payment_processor_id as a URL parameter) but then ignoring it when submitting the form. The only time we do want it to work is when recording a payment without a payment processor - and that is the only time the instrument select element actually appears on the form and the value is available during postProcess.

Before

Default paymentInstrumentID used when it shouldn't be.

After

Cleaned up setting of paymentInstrumentID and not overriding the payment processor anymore.

Technical Details

  • buildPaymentForm() is only relevant if we have a payment processor. So we should never pass a paymentInstrumentID.
  • $form->paymentInstrumentID is read but never set. So we can remove it throughout.

Comments

@civibot
Copy link

civibot bot commented Jun 12, 2020

(Standard links)

@civibot civibot bot added the master label Jun 12, 2020
@eileenmcnaughton
Copy link
Contributor

@mattwire this doesn't quite work - if you look at the Participant Payment form for the manual processor it correctly has the payment_instrument_id

Screen Shot 2020-06-14 at 2 11 14 PM

The form doesn't actually load that part with this patch.

The issue really is that we don't want to ask the processor about the paymentInstrumentID I guess - we want to take if from

  1. the form, if present &
  2. the processor if not

eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Jun 14, 2020
Per civicrm#17589 it is necessary that we do NOT pass the wrong payment_instrument_id
to the payment processor. BUT we have to provide accurate defaults for manual payments. This is a narrower fix than

- back office membership form
- back office participant form
- back office contribution form

and in all cases the Manual processor still loaded correctly. I don't feel I can say this is the last fix in this
area but it stands alone as a sensible fix to do and also one that should address the immediate issue.

Note there is some weirdness in a second function in EventFees - that function should GO IMHO - but I have not yet reached it in
UI testing to confirm if other changes need to be made.
@eileenmcnaughton
Copy link
Contributor

@mattwire how about this as an alternative - #17607 - it's a pretty narrow fix so I feel OK about putting it against the rc / backporting to a point release

@eileenmcnaughton
Copy link
Contributor

@mattwire closing this as the immediate issue is fixed and this has a fatal flaw at this stage.

eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Jun 15, 2020
Per civicrm#17589 it is necessary that we do NOT pass the wrong payment_instrument_id
to the payment processor. BUT we have to provide accurate defaults for manual payments. This is a narrower fix than

- back office membership form
- back office participant form
- back office contribution form

and in all cases the Manual processor still loaded correctly. I don't feel I can say this is the last fix in this
area but it stands alone as a sensible fix to do and also one that should address the immediate issue.

Note there is some weirdness in a second function in EventFees - that function should GO IMHO - but I have not yet reached it in
UI testing to confirm if other changes need to be made.
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