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

CRM-21693 show Display Name in online pay now UI #11571

Merged

Conversation

magnolia61
Copy link
Contributor

@magnolia61 magnolia61 commented Jan 22, 2018

Overview

Show the Display Name in the Online Pay Now UI
JIRA: https://issues.civicrm.org/jira/browse/CRM-21693

Before

Using the special constructed PayNow link it was not clear for which person the payment was for. This, In our case, especially confused parents who needed to make a payment and had been mailed several payment links.
screenshot from 2018-01-22 21-07-28

After

The Online Pay Now form is still extremely basic but shows the Display Name that belongs to the person the contribution belongs to.
screenshot from 2018-01-22 21-05-32

Technical Details

Just inserted the display name in case !empty($ccid)

Comments

Currently the price set of the contribution is shown. All other fields (name, email) are hidden.
Ideally the form UI should also show the 'reason' for the contribution.
For an event that would be the event name, for a membership the membership type.
This gives the person who is about to pay the confidence that all details of the payment are correct which means he or she is more likely to proceed.

@magnolia61 magnolia61 changed the title Crm 21693 show name in online pay now ui Crm 21693 show name in online pay now UI Jan 22, 2018
@magnolia61 magnolia61 changed the title Crm 21693 show name in online pay now UI Crm 21693 show Display Name in online pay now UI Jan 22, 2018
@eileenmcnaughton
Copy link
Contributor

Makes sense to me - any chance you can squash the 2 commits into one (git rebase -i origin/master) & add the JIRA issue to the commit message

@jitendrapurohit @agh1 @JoeMurray is there any downside to this? Could it 'leak data' or is that protected by a checksum?

@magnolia61
Copy link
Contributor Author

@eileenmcnaughton I never did what you suppose before (the squash/rebase thing).
Going to read into it, but takes time probably. Want to learn though ;-)

@eileenmcnaughton
Copy link
Contributor

@magnolia61 try git pull --rebase upstream master first (to make sure it's clean before you start)

@agh1
Copy link
Contributor

agh1 commented Jan 22, 2018

So I don't know much about the pay now feature, but this has one of two problems:

  1. If the $display_name is assigned to the template when an anonymous visitor arrives at the form with a ccid set, you could snoop on everyone's invoice totals by going to http://mysite/civicrm/contribute/transact?&reset=1&id=1&ccid=1, ...&ccid=2, etc.

  2. However, it doesn't look like that given this line in CRM/Contribute/Form/Contribution/Main.php is where the display name is assigned and it's only filled if there's a contact ID set. Instead, the $display_name value is going to be undefined and the page will have the header "Contribution Information - ".

@@ -91,7 +91,7 @@
{elseif !empty($ccid)}
{if $lineItem && $priceSetID && !$is_quick_config}
<div class="header-dark">
{ts}Contribution Information{/ts}
{ts}Contribution Information{/ts} - {ts 1=$display_name}%1{/ts}
Copy link
Contributor

Choose a reason for hiding this comment

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

It appears that you have two spaces ahead of the hyphen--there should be just one. Also, shouldn't this be an en dash (&ndash;)?

@eileenmcnaughton
Copy link
Contributor

hmm - it's still got tonnes in - you need to do a clean rebase over the upstream master branch first & push that up with

git push -f yourrepo yourbranch

@magnolia61
Copy link
Contributor Author

trying and messing with my local git, git pull --rebase upstream master gives some errors.
hang on, i will figure it out ;)

@magnolia61 magnolia61 force-pushed the CRM-21693_Show_Name_in_OnlinePayNow_UI branch 4 times, most recently from 7354847 to d856052 Compare January 22, 2018 23:00
@magnolia61
Copy link
Contributor Author

ok, learned some more on all kind of git commands. Think the PR is ok now ;-)

@eileenmcnaughton
Copy link
Contributor

well done!

Did you have any thoughts on #11571 (comment)

@@ -91,7 +91,7 @@
{elseif !empty($ccid)}
{if $lineItem && $priceSetID && !$is_quick_config}
<div class="header-dark">
{ts}Contribution Information{/ts}
{ts}Contribution Information{/ts} &ndash; {ts 1=$display_name}%1{/ts}
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I should've noticed this earlier: your {ts} isn't wrapping any string to translate--just a variable to drop in as-is. You could either:

  • get rid of the ts and just drop it in as

    {ts}Contribution Information{/ts} &ndash; {$display_name}
  • or wrap the whole thing in a ts like

    {ts 1=$display_name}Contribution Information &ndash; %1{/ts}

The latter causes more work for our translators (since it introduces a new string to translate), but it allows for localization of how the header is ordered and punctuated. I don't know which is preferred as a general rule.

Copy link
Contributor

Choose a reason for hiding this comment

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

(and this may depend upon how you address the other concern about whether the $display_name is populated)

@magnolia61
Copy link
Contributor Author

@agh1 The Pay Now form can only be accessed by a special link which includes the checksum, contribution id and (optionally) cid. It cannot be accessed anonymously. Aside of that, for the purpose of this PR I haven't analysed the underlying mechanisms and checks on preventing disclosures I must admit. This PR only focuses on adding the display name ;-)

@magnolia61 magnolia61 force-pushed the CRM-21693_Show_Name_in_OnlinePayNow_UI branch from d856052 to c3e97ca Compare January 22, 2018 23:27
@agh1
Copy link
Contributor

agh1 commented Jan 22, 2018

@magnolia61 glad to know you can only get there authenticated. The code on the online contribution forms is so jam-packed with all the tangentially-related available features that it wasn't really clear what happens when ccid is present but there was not authentication or checksum.

Thanks for your improvement!

@magnolia61 magnolia61 force-pushed the CRM-21693_Show_Name_in_OnlinePayNow_UI branch from c3e97ca to 1bb88ea Compare January 22, 2018 23:30
@magnolia61
Copy link
Contributor Author

magnolia61 commented Jan 22, 2018

@agh1 ;-( unfortunately I just figured out the constructed link can also be used anonymously. In that case the Display Name is not retrieved. Also when both the checksum and the contact id are being omitted, the contribution strangly moves to user 1, which I think should not happen and is a bug.
All of this is related to the Online Pay Now functionality but is not part of this issue/PR. Maybe we should put this PR on hold, and further discuss in another jira issue? Actually I reported this anomaly quite some time ago in: https://issues.civicrm.org/jira/browse/CRM-20697

@eileenmcnaughton
Copy link
Contributor

@magnolia61 is user 1 your logged in user? or are you testing logged out?

@magnolia61
Copy link
Contributor Author

magnolia61 commented Jan 22, 2018

No, this happens when I am not logged in, eg. when I use the PayNow link in a new private window. When using the PayNow button when logged in (from the contact dashboard) only the contribution id and contribution page are in the url. I think the corresponding contact ID and checksum should also be in that url and be required. Maybe even use a uniform url that also includes the checksum when logged in. So enforce the url to look like: https://www.ourdomain.nl/civicrm/contribute/transact?reset=1&id=7&ccid=3887&cs=986e9c03ddf2b4b980a929a_1492524606_1440&cid=316
Including: contribution Page (id), contribution id (ccid), checksum (cs) and Contact ID (cid).
Only if ccid, cs & cid match the page should be shown as a safeguard probably

PS. moving this info to the related issue so the discussion is in the right place

BTW. being able to mail the Pay Now link to users that still have to pay something is great, lots of our participants pay this way. I even think it would be awesome to include this next to the email invoice button, or include the PayNow link in that email)

@agh1
Copy link
Contributor

agh1 commented Jan 23, 2018

@magnolia61 well, the way I see it, your change is neither causing the bug, exacerbating the bug, nor exposing private information due to the bug, so I don't see any reason to hold this change up just because it uncovered the other issue.

@eileenmcnaughton
Copy link
Contributor

I guess arguably it is valid to send a pay now link to someone (e,g your mum) to make a payment for you & for (not easy to come up with reasons in this scenario) your mum is not you so should not see your name.

@magnolia61
Copy link
Contributor Author

BTW. shall I remove the dash so it will look whether the displayname is shown or not?

@agh1
Copy link
Contributor

agh1 commented Jan 23, 2018

@magnolia61 I think it would be best to wrap the display name and dash in a conditional, e.g.

{ts}Contribution Information{/ts}{if $display_name} &ndash; {$display_name}{/if}

@magnolia61 magnolia61 force-pushed the CRM-21693_Show_Name_in_OnlinePayNow_UI branch 2 times, most recently from f6e72b7 to 1bb88ea Compare January 23, 2018 15:32
@magnolia61 magnolia61 force-pushed the CRM-21693_Show_Name_in_OnlinePayNow_UI branch from 1bb88ea to 3265f68 Compare January 23, 2018 15:35
@magnolia61
Copy link
Contributor Author

I changed it to be conditional but when I think about it, I think the changed Jitendra made to solve the other issues with the PayNow link, assure the contact id is always set and thus the display name is always known. What do you think? #11578

@agh1
Copy link
Contributor

agh1 commented Jan 23, 2018

It doesn't hurt to have the condition here, especially since you have ambitions to make it work properly for anonymous visitors later.

@magnolia61
Copy link
Contributor Author

ok to merge?

@colemanw
Copy link
Member

I'm happy with the review this has gotten. Yes.

@colemanw colemanw merged commit 29791fd into civicrm:master Feb 26, 2018
@mlutfy mlutfy changed the title Crm 21693 show Display Name in online pay now UI CRM-21693 show Display Name in online pay now UI Mar 6, 2018
@mlutfy mlutfy added this to the 4.7.32 milestone Mar 6, 2018
@magnolia61
Copy link
Contributor Author

I think we should change this PR. It works ok in almost all scenarios, except when an admin accesses the Pay Now payment screen via the user dashboard. I think we should change this so that the displayed name is that of the owner of the contribution and not the logged in user. Now sure if that would be simple though.

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.

6 participants