this all works fine on prod, on all staging environments, and developers local machine.
The issue: On just one AEM publisher of a particular staging environment, the POST ..../reserve.paymentsuccess.html is giving HTTP 204 with no response body. And since there is no response body window.parent.postMessage mentioned never happens and user gets stuck there. Any idea why this one staging environment AEM publisher would erroneously give HTTP 204 instead of HTTP 200
Writing Java code in a bonafide Java class is cleaner, more testable, and easier to trace/log/debug (IMO). You can also tie your behavior to specific cq:Page's easily with the Opting check, rather than attaching the POST paymentsuccess to EVERY cq:Page.