show method
The PaymentRequest interface's
show()
method instructs the user agent to begin the
process of showing and handling the user interface for the payment request
to the
user.
Only one payment request can be in the process of being handled at once,
across all
documents. Once one PaymentRequest
's show()
method has been
called, any other call to show()
will by rejected with an
AbortError
until the returned promise has been concluded, either by
being
fulfilled with a PaymentResponse indicating the results of the payment
request, or by being rejected with an error.
Note: In reality, despite the fact that the specification says this can't be done, some browsers, including Firefox, support multiple active payment requests at a time.
If your architecture doesn't necessarily have all of the data ready to go
at the moment
it instantiates the payment interface by calling show()
, specify the
detailsPromise
parameter, providing a Promise
that is
fulfilled once the data is ready. If this is provided, show()
will not
allow the user to interact with the payment interface until the promise is
fulfilled, so
that data can be updated prior to the user engaging with the payment
process.
Processing the result and, if necessary, calling PaymentResponse.retry
to retry a failed payment can all be done either asynchronously or
synchronously,
depending on your needs. For the best user experience, asynchronous
solutions are
typically the best way to go. Most examples on MDN and elsewhere use
async
/await
to wait asynchronously while results are validated and so forth.
Implementation
external JSPromise<PaymentResponse> show(
[JSPromise<PaymentDetailsUpdate> detailsPromise]);