Connection to client lost after Apple Pay decline

Ok, here is the scenario... the payment sheet appears, Touch Id is accepted, the payment fails (intentionally), Touch Id is accepted again to resubmit, 30 seconds later it states Payment Not Completed and the payment sheet closes. The trace of both are identical other than the former stating it failed due to the client indicating a decline and the latter failed after it timed out waiting for the client callback.

I have replicated this at https://applepaydemo.apple.com/ using both the Apple Pay API and Payment Request API.

const response = await request.show();
const status = "fail";
await response.complete(status);

The above was taken directly from the demo site and yes, I know the success state of the actual card processing would be passed here. So the flow of the first attempt to submit fails, as expected, but what seems to happen is that the pointer back to request.show() doesn't get reset; the promise has already been fulfilled and the routine has exited. When the payment sheet attempts the callback the second time it's no longer bound and eventually times out. Clicking pay again repeats the whole flow. Seems like a defect to me.

I doubt I'm the first to come across this issue though a half a day of searching has not revealed otherwise. I'm experiencing this on Ventura with Safari 16.1 against the sandbox.

Hi EricMEvans! We shouldn't be showing the payment sheet after calling PaymentResponse.complete() method, since that method notifies the user agent that the user interaction is over, and causes any remaining user interface to be closed. You intend to call PaymentResponse.retry() for failures that warrant showing the payment sheet again.

Ok, ok, I got it. I had to put my retry in a loop and throw an await on my server call. Got things figured out from a writeup at mozilla.org. Lawdy, I thought Microsoft's docs were bad but after my Apple Pay endeavor, Apple's docs make Msft's seem complete and concise. @aprotyas thanks for pointing me in the correct direction.

Connection to client lost after Apple Pay decline
 
 
Q