大网数据广告活动
Web 标准与前端开发

PaymentRequest

· 52CE 我爱测

The Payment Request API's **`PaymentRequest`** interface is 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.

Payment Request API

The Payment Request API's PaymentRequest interface is 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.

Constructor

  • PaymentRequest.PaymentRequest()
    • : Creates a new PaymentRequest object.

Instance properties

  • PaymentRequest.id
    • : A 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 flag set to true.
  • PaymentRequest.shippingType
    • : Returns the type of shipping used to fulfill the transaction. This will be one of shipping, delivery, pickup, or null if a value was not provided in the constructor.

Static methods

  • PaymentRequest.getSecurePaymentConfirmationCapabilities_static
  • PaymentRequest.securePaymentConfirmationAvailability_static
    • : Indicates whether the Secure payment confirmation feature is available in the current browser.

Instance methods

  • 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.

Events

  • PaymentRequest.merchantvalidation_event
    • : With some payment handlers (e.g., Apple Pay), this event handler is called to handle the PaymentRequest.merchantvalidation_event event, which is dispatched when the user agent requires that the merchant validate that the merchant or vendor requesting payment is legitimate.
  • PaymentRequest.paymentmethodchange_event
    • : 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.
  • PaymentRequest.shippingaddresschange_event
    • : Dispatched whenever the user changes their shipping address.
  • PaymentRequest.shippingoptionchange_event
    • : Dispatched whenever the user changes a shipping option.

Specifications

Browser compatibility

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。