https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43451

--- Comment #3 from Martin Renvoize (ashimema) 
<[email protected]> ---
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 <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to