我们的志愿者还没有将这篇文章翻译为 中文 (简体)。加入我们帮助完成翻译!
您也可以阅读此文章的English (US)版。
Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
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
interface of the Payment Request API manages the process of a user making a payment.
Constructor
PaymentRequest()
Secure context- Creates a new
PaymentRequest
object.
Properties
PaymentRequest.shippingAddress
Read only Secure context- Returns the shipping address chosen by the user. This property is only populated if the constructor is called with the
requestShipping
flag set to true. PaymentRequest.shippingOption
Read only Secure context- Returns the ID of the selected shipping option. This property is only populated if the constructor is called with the
requestShipping
flag set to true.
Event Handlers
PaymentRequest.onshippingaddresschange
Secure context- Fired whenever the user changes their shipping address.
PaymentRequest.onshippingoptionchange
Secure context- Fired whenever the user changes a shipping option.
Methods
PaymentRequest.canMakePayment()
Secure context- Indicates whether the
PaymentRequest
object can make a payment before callingshow()
.
PaymentRequest.show()
Secure context- Causes the user agent to begin the user interaction for the payment request.
PaymentRequest.abort()
Secure context- Causes the user agent to end the payment request and to remove any user interface that might be shown.
Specifications
Specification | Status | Comment |
---|---|---|
Payment Request API The definition of 'PaymentRequest' in that specification. |
Editor's Draft | Initial definition. |
Browser Compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support |
60.0 |
No support[1] | ? | ? | ? |
canMakePayment |
60.0 |
No support[1] | ? | ? | ? |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|
Basic support | No support | 53.0 | ?[1] | ? | ? | ? | 53.0 |
canMakePayment |
No support |
No support |
?[1] | ? | ? | ? | 56.0 |
[1] Supported since 55 but disabled on all versions. Hidden behind the dom.payments.request.enabled
pref.