Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

PaymentRequest.show()

This article needs a technical review. How you can help.

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

The PaymentRequest.show() method of the PaymentRequest interface causes the user agent to begin the user interaction for the payment request.

Syntax

PaymentRequest.show()
    .then( paymentResponse => { ... })
    .catch( error => { ... })

Returns

A Promise to a PaymentResponse object. The promise is resolved when the user accepts the payment request.

Parameters

None

Examples

In the following example, a PaymentRequest object is instantiated before the show() method is called. This method triggers the user agent's built-in process for retrieving payment information from the user. The show() method returns a Promise that resolves to a PaymentResponse object when the user interaction is complete. The developer then uses the information in the PaymentResponse object to format and send payment data to the server. You should send the payment information to the server asynchronously so that the final call to paymentResponse.complete() can indicate the success or failure of the payment.

// Initialization of PaymentRequest arguments are excerpted for the sake of
//   brevity.

var payment = new PaymentRequest(supportedInstruments, details, options);

payment.show().then(function(paymentResponse) {
  // Process paymentResponse here, including sending payment to the server.
  // paymentResponse.methodName contains the selected payment method
  // paymentResponse.details contains a payment method specific response
  paymentResponse.complete("success");
}).catch(function(err) {
  console.error("Uh oh, something bad happened", err.message);
});

Specifications

Specification Status Comment
Payment Request API
The definition of 'show()' in that specification.
Working Draft Initial definition.

Browser Compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support

53.0

? ? ? ?
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support No support 53.0 ? ? ? ? ? 53.0

See Also

Document Tags and Contributors

 Contributors to this page: dgashmdn, jpmedley
 Last updated by: dgashmdn,