[Bug 43451] New: Account payment receipt popup can be blocked by popup blockers (needs PRG pattern like Bug 41705)
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43451 Bug ID: 43451 Summary: Account payment receipt popup can be blocked by popup blockers (needs PRG pattern like Bug 41705) Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Fines and fees Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org Target Milestone: --- When FinePaymentAutoPopup is enabled, members/boraccount.tt, members/pay.tt and members/paycollect.tt all trigger the printed receipt with a plain client-side window.open() call on page load (see boraccount.tt around "if (payment_id && Koha.prefs.FinePaymentAutoPopup)"). In some browsers this is treated as an unsolicited popup and silently blocked, so staff never see the receipt. Bug 41705 hit the exact same problem in the Point of Sale module and fixed it there by moving to a PRG (Post/Redirect/Get) pattern: pos/pay.pl issues a server-side 303 redirect (instead of a client window.open()) and the sale form itself submits with target="_blank" so the new tab is opened as a direct result of the user's click, which browsers do not block. The receipt page (pos/printreceipt.pl / printreceipt.tt) then supports an autoprint=1 param that triggers window.print() on load and closes the tab afterwards. Bug 43402 added a manual "print/email receipt" notification box to the account-payment side for when FinePaymentAutoPopup is off, but deliberately left the FinePaymentAutoPopup=on window.open() path alone, since porting the PRG pattern here is more involved than in POS: - Paying/writing off a charge on the account side can also trigger item renewals (Koha::Account->pay()'s renew_result), and the current window.open flow shows that feedback (plus the refreshed balance) in the SAME tab that triggers the popup. A straight port of POS's approach (whole tab becomes the receipt via a same-tab redirect) would lose that feedback unless the design deliberately drops it, matching how POS has no equivalent confirmation UI once the receipt tab opens. - Alternatively, giving the payment confirmation form(s) in paycollect.tt target="_blank" (as POS does) opens the receipt in a genuinely new tab without popup-blocker risk, but then the ORIGINAL tab needs its own client-side navigation back to boraccount.pl/pay.pl since a single form submission can only target one destination - and that return navigation can't carry payment_id/renew_result forward either, since those are only known after the (separate) submission completes. Either approach involves changes to paycollect.pl (which is the single choke point for individual/selected payments and writeoffs), pay.pl, boraccount.pl, and their templates, and a considered decision on whether renew_result/balance feedback is acceptable to lose (or needs preserving some other way) when FinePaymentAutoPopup is on. Test plan: N/A yet - this bug is filed to capture the problem and prior art (Bug 41705) before a design is chosen. See discussion for the two candidate approaches outlined above. See also: Bug 41705 (PRG pattern for POS), Bug 43402 (print/email button when FinePaymentAutoPopup is off), Bug 43288 (change/change_given param mismatch on these same receipt links). -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43451 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |43402 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43402 [Bug 43402] Offer button to print receipt when collecting account payments -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43451 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=41705 -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43451 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrew@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43451 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210033 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210033&action=edit Bug 43451: Show the receipt buttons when the automatic receipt window is blocked With FinePaymentAutoPopup on, members/boraccount.tt and members/pay.tt open the receipt with window.open() on page load, after paycollect.pl has redirected back to them. A window opened without a user action can be blocked by the browser, and then staff never see the receipt. A Bug 41705 style redirect cannot be used here: the landing page also shows the renewal results and refreshed balance, and the tab that submits the payment must stay on it. Instead, keep the automatic window, and when window.open() returns nothing, reveal the "Payment received" box from Bug 43402 with its Print and Email receipt buttons. Clicking one is a user action, so it cannot be blocked. When the window opens normally the page is unchanged. When FinePaymentAutoPopup is off the box is shown as before. members/paycollect.tt also calls window.open(), but paycollect.pl redirects after a payment, so that code does not run in practice and is left alone. To test: 1. Apply Bug 43402 and this patch. 2. Set FinePaymentAutoPopup to "Do" and give a patron a charge. 3. Take a payment from the patron's Accounting > Make a payment. => With popups allowed the receipt opens and prints, and the page shows no "Payment received" box (as before). 4. Block popups for the staff site in the browser and repeat. => The "Payment received" box is shown with the message "Your browser blocked the receipt window" and the Print receipt button, and Email receipt if the patron has an email address. => Pay a charge that causes a renewal: the renewal feedback and balance are still shown. 5. Set FinePaymentAutoPopup to "Don't" and repeat. => The "Payment received" box is shown without the blocked message. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43451 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43451 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #210033|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43451 --- Comment #2 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210034 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210034&action=edit Bug 43451: Show the receipt buttons when the automatic receipt window is blocked With FinePaymentAutoPopup on, members/boraccount.tt and members/pay.tt open the receipt with window.open() on page load, after paycollect.pl has redirected back to them. A window opened without a user action can be blocked by the browser, and then staff never see the receipt. A Bug 41705 style redirect cannot be used here: the landing page also shows the renewal results and refreshed balance, and the tab that submits the payment must stay on it. Instead, keep the automatic window, and when window.open() returns nothing, reveal the "Payment received" box from Bug 43402 with its Print and Email receipt buttons. Clicking one is a user action, so it cannot be blocked. When the window opens normally the page is unchanged. When FinePaymentAutoPopup is off the box is shown as before. members/paycollect.tt also calls window.open(), but paycollect.pl redirects after a payment, so that code does not run in practice and is left alone. To test: 1. Apply Bug 43402 and this patch. 2. Set FinePaymentAutoPopup to "Do" and give a patron a charge. 3. Take a payment from the patron's Accounting > Make a payment. => With popups allowed the receipt opens and prints, and the page shows no "Payment received" box (as before). 4. Block popups for the staff site in the browser and repeat. => The "Payment received" box is shown with the message "Your browser blocked the receipt window" and the Print receipt button, and Email receipt if the patron has an email address. => Pay a charge that causes a renewal: the renewal feedback and balance are still shown. 5. Set FinePaymentAutoPopup to "Don't" and repeat. => The "Payment received" box is shown without the blocked message. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43451 --- Comment #3 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210038 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210038&action=edit Bug 43451: Open the account payment receipt from the payment form submission The previous patch makes the best of a window.open() call made when the account page loads, by showing the Print and Email buttons when the window turns out to have been blocked. That cannot be made reliable. A window opened by script, without a user action, is blocked by many browsers unless popups have been explicitly allowed for the site. Not every browser or extension reports the block through window.open(), so the receipt, and the buttons, can be missing without any sign of it. This patch uses the pattern from Bug 41705 for the Point of Sale: the payment form is submitted to a new tab with target="_blank". That is a direct result of the user's click, which browsers do not block, so the receipt always opens. Unlike the Point of Sale, the tab that submitted the payment still has to show the refreshed balance, the payment_id and any renewal results, and those only exist once paycollect.pl has saved the payment, in the new tab. A single form submission has one target, so: - paycollect.pl redirects the new tab to the receipt, passing a random channel name from the form and the account page the original tab should show - the receipt page sends that address to the original tab over a BroadcastChannel, then prints and closes itself as before - the original tab, which shows "Payment in progress", then goes to the account page, with receipt_opened=1 so that it does not try to open the receipt again The message is only sent after the payment has been saved, so the original tab cannot show a stale balance. The address is accepted only if it is one of the account pages (checked in printfeercpt.pl and again in the page) and the channel name is a random value that only the two tabs know. If the payment is refused (e.g. more than is due), the new tab says so and closes, and the original tab shows an error and the form again. If the original tab hears nothing for a minute, it shows the account. BroadcastChannel is supported by all current browsers (Chrome 54, Firefox 38, Edge 79, Safari 15.4). In an older browser nothing changes from the previous patch: the account page opens the receipt and shows the buttons if that fails. To test: 1. Apply Bug 43402 and Bug 43451 (both patches) 2. Set FinePaymentAutoPopup to "Do" and give a patron some charges 3. In the patron's Accounting > Make a payment, pay a charge, pay selected charges, and write off a charge. Also pay with more tendered than due, so the change confirmation is shown => A new tab opens for the receipt, prints and closes, and the original tab goes to the account with the balance updated 4. Block popups for the staff site in the browser and repeat => The receipt tab still opens 5. Pay more than the charge is worth => The new tab closes and the original shows "The payment was not completed" 6. Set FinePaymentAutoPopup to "Don't" and pay a charge => No new tab, and the "Payment received" box offers Print and Email Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43451 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Initiative type|--- |Feature Patch complexity|--- |Trivial patch Target Milestone|--- |26.11 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43451 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org