安全上下文
此特征只可用于 安全上下文 (HTTPS),在某些或所有 支持浏览器 .

Payment Request API's PaymentRequest interface the primary access point into the API, and lets web content and apps accept payments from the end user on behalf of the operator of the site or the publisher of the app.

构造函数

PaymentRequest() 安全上下文
创建新的 PaymentRequest 对象。

特性

PaymentRequest.id 只读 安全上下文
An unique identifier for a particular PaymentRequest , which can be set via details.id . When none is set, it defaults to a UUID.
PaymentRequest.shippingAddress 只读 安全上下文
If requested via payment options, returns the shipping address chosen by the user for the purposes of calculating shipping. This property is only populated if the constructor is called with the requestShipping flag set to true. Additionally, in some browsers, the parts of the address will be redacted for privacy until the user indicates they are ready to complete the transaction (i.e., they hit "Pay").
PaymentRequest.shippingOption 只读 安全上下文
Returns the identifier of the selected shipping option. This property is only populated if the constructor is called with the requestShipping 标志被设为 true。
PaymentRequest.shippingType 只读 安全上下文
Returns the type of shipping used to fulfill the transaction. This will be one of shipping , delivery , pickup ,或 null if a value was not provided in the constructor.

方法

PaymentRequest.canMakePayment() 安全上下文
Indicates whether the PaymentRequest object can make a payment before calling show() .
PaymentRequest.show() 安全上下文

Causes the user agent to begin the user interaction for the payment request.

PaymentRequest.abort() 安全上下文

Causes the user agent to end the payment request and to remove any user interface that might be shown.

事件

merchantvalidation 安全上下文
With some payment handlers (e.g., Apple Pay), this event handler is called to handle the merchantvalidation event, which is dispatched when the user agent requires that the merchant validate that the merchant or vendor requesting payment is legitimate.
Also available using the onmerchantvalidation event handler property.
paymentmethodchange 安全上下文
With some payment handlers (e.g., Apple Pay), dispatched whenever the user changes payment instrument, like switching from a credit card to a debit card.
Also available using the onpaymentmethodchange event handler property.
shippingaddresschange 安全上下文
Dispatched whenever the user changes their shipping address.
Also available using the onshippingaddresschange event handler property.
shippingoptionchange 安全上下文
Dispatched whenever the user changes a shipping option.
Also available using the onshippingoptionchange event handler property.

规范

规范 状态 注释
支付请求 API
The definition of 'PaymentRequest' in that specification.
候选推荐 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
PaymentRequest Chrome 61 Edge ≤18 Firefox 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled From version 55: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ) 和 dom.payments.request.supportedRegions preference (needs to be set to A comma-delineated list of one or more 2-character ISO country codes indicating the countries in which to support payments (for example, US,CA ). ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari 11.1 WebView Android 不支持 No Chrome Android 53 Firefox Android 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled From version 55: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ) 和 dom.payments.request.supportedRegions preference (needs to be set to A comma-delineated list of one or more 2-character ISO country codes indicating the countries in which to support payments (for example, US,CA ). ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS 11.3 Samsung Internet Android 6.0
PaymentRequest() 构造函数 Chrome 61 Edge ≤18 Firefox 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari 11.1 WebView Android 不支持 No Chrome Android 53 Firefox Android 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS 11.3 Samsung Internet Android 6.0
abort() Chrome 61 Edge 15 Firefox 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari 11.1 WebView Android 不支持 No Chrome Android 53 Firefox Android 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS 11.3 Samsung Internet Android 6.0
canMakePayment() Chrome 61 Edge 16 Firefox 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari 11.1 WebView Android 不支持 No Chrome Android 53 Firefox Android 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS 11.3 Samsung Internet Android 6.0
id Chrome 61 Edge 16 Firefox 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari 11.1 WebView Android 不支持 No Chrome Android 60 Firefox Android 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS 11.3 Samsung Internet Android 8.0
merchantvalidation event Chrome ? Edge ? Firefox 64 注意事项 Disabled
64 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari ? WebView Android 不支持 No Chrome Android ? Firefox Android 64 注意事项 Disabled
64 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS ? Samsung Internet Android ?
onmerchantvalidation Chrome ? Edge ? Firefox 64 注意事项 Disabled
64 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari ? WebView Android 不支持 No Chrome Android ? Firefox Android 64 注意事项 Disabled
64 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS ? Samsung Internet Android ?
onpaymentmethodchange Chrome 不支持 No Edge 不支持 No Firefox 63 注意事项 Disabled
63 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari ? WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 63 注意事项 Disabled
63 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS ? Samsung Internet Android 不支持 No
onshippingaddresschange Chrome 61 Edge 15 Firefox 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari 11.1 WebView Android 不支持 No Chrome Android 53 Firefox Android 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS 11.3 Samsung Internet Android 6.0
onshippingoptionchange Chrome 61 Edge 15 Firefox 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari 11.1 WebView Android 不支持 No Chrome Android 53 Firefox Android 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS 11.3 Samsung Internet Android 6.0
paymentAddress Chrome 61 Edge 15 Firefox 55 注意事项 Alternate Name Disabled
55 注意事项 Alternate Name Disabled
Available only in nightly builds.
Alternate Name Uses the non-standard name: shippingAddress
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari ? WebView Android 不支持 No Chrome Android 53 Firefox Android 55 注意事项 Alternate Name Disabled
55 注意事项 Alternate Name Disabled
Available only in nightly builds.
Alternate Name Uses the non-standard name: shippingAddress
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS ? Samsung Internet Android 6.0
paymentmethodchange event Chrome 不支持 No Edge 不支持 No Firefox 63 注意事项 Disabled
63 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari ? WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 63 注意事项 Disabled
63 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS ? Samsung Internet Android 不支持 No
requestId Chrome 不支持 No Edge 不支持 ≤18 — 79 Firefox 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari ? WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS ? Samsung Internet Android 不支持 No
shippingaddresschange event Chrome 61 Edge 15 Firefox 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari 11.1 WebView Android 不支持 No Chrome Android 53 Firefox Android 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS 11.3 Samsung Internet Android 6.0
shippingOption Chrome 61 Edge 15 Firefox 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari 11.1 WebView Android 不支持 No Chrome Android 53 Firefox Android 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS 11.3 Samsung Internet Android 6.0
shippingoptionchange event Chrome 61 Edge 15 Firefox 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari 11.1 WebView Android 不支持 No Chrome Android 53 Firefox Android 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS 11.3 Samsung Internet Android 6.0
shippingType Chrome 61 Edge 15 Firefox 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari 11.1 WebView Android 不支持 No Chrome Android 55 Firefox Android 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS 11.3 Samsung Internet Android 6.0
show Chrome 61 Edge 15 Firefox 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari 11.1 WebView Android 不支持 No Chrome Android 53 Firefox Android 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS 11.3 Samsung Internet Android 6.0

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

见实现注意事项。

用户必须明确启用此特征。

用户必须明确启用此特征。

使用非标名称。

使用非标名称。

元数据

  • 最后修改:
  1. 支付请求 API
  2. PaymentRequest
  3. 构造函数
    1. PaymentRequest()
  4. 特性
    1. onmerchantvalidation
    2. onpaymentmethodchange
    3. onshippingaddresschange
    4. shippingAddress
    5. shippingOption
  5. 方法
    1. canMakePayment()
    2. show()
  6. 事件
    1. paymentmethodchange
  7. 继承:
    1. EventTarget
  8. Related pages for Payment Request API
    1. HTMLIFrameElement.allowPaymentRequest
    2. MerchantValidationEvent
    3. PaymentAddress
    4. PaymentMethodChangeEvent
    5. PaymentRequestUpdateEvent
    6. PaymentResponse

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1