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#150: civicrm/payment/form url got empty currency argument in backoffice live CC form #18517

Merged
merged 3 commits into from
Jul 7, 2021

Conversation

monishdeb
Copy link
Member

@monishdeb monishdeb commented Sep 18, 2020

Overview

This affects iATS Payments ACH/EFT payment processor which renders the payment block based on currency chosen.
Here are the steps to replicate:

  1. Install and enable iATS paymentextension
  2. Add and configure an iATS Payments ACH/EFT payment type payment processor.
  3. Enable USD and CAD currencies
  4. Go to 'Submit Credit Card Contribution' backoffice form
  5. Choose payment processor created at step 2

Issue:

  1. Payment block renders payment block without check template
  2. Switching currency doesn't update the payment block.

Before

crm-598-before

After

crm-598-after

Technical Details

For more detail discussion on MM - https://chat.civicrm.org/civicrm/pl/ixxrxhxs43r4mfyjpnf6tnwnnc

https://lab.civicrm.org/dev/financial/-/issues/150

ping @KarinG @Edzelopez @eileenmcnaughton @JoeMurray

@civibot
Copy link

civibot bot commented Sep 18, 2020

(Standard links)

@civibot civibot bot added the master label Sep 18, 2020
$currentCurrency
);
return $result;
return $submittedValues['currency'] ?? $this->_values['currency'] ?? CRM_Core_Config::singleton()->defaultCurrency;
Copy link
Contributor

Choose a reason for hiding this comment

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

This part looks good - it's just cleanup.

@@ -95,7 +95,10 @@

var payment_instrument_id = $('#payment_instrument_id').val();

var dataUrl = "{crmURL p='civicrm/payment/form' h=0 q="formName=`$form.formName`&currency=`$currency`&`$urlPathVar``$isBackOfficePathVar``$profilePathVar``$contributionPageID``$preProfileID`processor_id="}" + type;
var currency = '{$currency}';
currency = currency == '' ? $('#currency').val() : currency;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the only bit I have concerns with - why would the currency not be set when the form loads?

Copy link
Member Author

@monishdeb monishdeb Sep 18, 2020

Choose a reason for hiding this comment

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

@mattwire actually there are two cases where the currency variable is not set in backend, these are:

  1. When we open the standalone CC form for submitting new live contribution, where we are setting a NULL currency value in here Although the default currency set in the system can be used in here instead of NULL. So I am not sure if we need to do that.

  2. When we are changing the currency beside the amount field https://github.com/civicrm/civicrm-core/pull/18517/files#diff-726c3dcc8c2364a0b9b8f0c0e11bcd34R122 which call the js function, and in this case the code should consider what currency value has been chosen in b/o form and when in reloads the snippet

This is not a issue on edit CC form where currency variable is set.

Copy link
Contributor

Choose a reason for hiding this comment

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

@monishdeb can we pass currency though the url for case 2?

Copy link
Member Author

Choose a reason for hiding this comment

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

@eileenmcnaughton yes I am passing the currency value for the 2nd case, if you look at L122 below, I am calling the buildPaymentBlock() fn on currency change and eventually at L99 we are considering the currency value and passing through the url at L144

@mattwire
Copy link
Contributor

I've raised a couple of comments for an r-code review. I haven't read through the detail behind this PR so they may have already been answered.

@eileenmcnaughton
Copy link
Contributor

test this please

@KarinG
Copy link
Contributor

KarinG commented Sep 18, 2020

When Jenkins is happy I'll test it.

@eileenmcnaughton
Copy link
Contributor

thanks @KarinG

@mlutfy mlutfy changed the title financial#150: civicrm/payment/form url got empty currency argument in backoffice live CC form dev/financial#150: civicrm/payment/form url got empty currency argument in backoffice live CC form Oct 8, 2020
$('[name=payment_processor_id]').on('change.paymentBlock', function() {
buildPaymentBlock($(this).val());
$('[name=payment_processor_id], #currency').on('change.paymentBlock', function() {
buildPaymentBlock($('[name=payment_processor_id]').val());
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to add :checked or it will always take the first option.

Copy link
Contributor

Choose a reason for hiding this comment

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

Tested on a site with a payment processor and pay later and the pay later option was broken.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @samuelsov for raising this issue and suggesting the fix. I have updated the PR with this commit b86dc53 as per which we need to consider both the w/o pay-later cases.

@mattwire
Copy link
Contributor

@monishdeb Looks like this needs a bit of work?

@KarinG
Copy link
Contributor

KarinG commented Oct 30, 2020

"Submit Credit Card Contribution backoffice form" -> it's not at all obvious that this is where one would go to process an ACH EFT (i.e. a non Credit Card) transaction.

@JoeMurray
Copy link
Contributor

We were thinking of a separate PR for changing the name since it really should be Submit Online Contribution or something similar, @KarinG . What do you think?

@eileenmcnaughton
Copy link
Contributor

I think you are brave :-) Changing button names is fighting talk. But yes, separate PR or issue don't mix it in with this

@KarinG
Copy link
Contributor

KarinG commented Oct 31, 2020

I think this PR requires a new button -> "Process ACH EFT"

@KarinG
Copy link
Contributor

KarinG commented Oct 31, 2020

@adixon - ping!

@eileenmcnaughton
Copy link
Contributor

@KarinG no - a SEPARATE PR can cover that....

buildPaymentBlock($(this).val());
$('[name=payment_processor_id], #currency').on('change.paymentBlock', function() {
var payment_processor_id = $('[name=payment_processor_id]:checked').val() == undefined ? $('[name=payment_processor_id]').val() : $('[name=payment_processor_id]:checked').val();
buildPaymentBlock(payment_processor_id);
Copy link
Member

@mlutfy mlutfy Nov 6, 2020

Choose a reason for hiding this comment

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

@monishdeb This breaks backend New Contribution forms without a payment processor (ex: Contact Record -> New Contribution, then change the currency).

Adding "if (payment_contribution_id != undefined) { .. }" fixes it, although I haven't tested extensively.

For reference, this form:

civi-2020-11-06_13-44

@mlutfy mlutfy added the needs-work-not-review-ready Submitter required to take action, will be closed after 1-2 weeks in this state label Nov 6, 2020
@mattwire
Copy link
Contributor

mattwire commented Nov 9, 2020

Hi @monishdeb This is awaiting changes following @mlutfy testing.

@monishdeb
Copy link
Member Author

sorry for delay I have updated the PR.

@mlutfy mlutfy removed the needs-work-not-review-ready Submitter required to take action, will be closed after 1-2 weeks in this state label Dec 22, 2020
@mlutfy
Copy link
Member

mlutfy commented Dec 22, 2020

Seems good to me, but I will let someone merge since it's not my area of expertise.

Symbiotic has been using this patch in production (with the latest commit) for a few weeks and seems to be working well.

@eileenmcnaughton
Copy link
Contributor

I don't have any remaining concerns - @mattwire ?

@monishdeb
Copy link
Member Author

ping @eileenmcnaughton @mattwire

@mattwire mattwire merged commit 44f9625 into civicrm:master Jul 7, 2021
@monishdeb monishdeb deleted the financial-issue-150 branch October 4, 2024 05:10
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.

7 participants