PaymentRequest Class
A payment request (https://w3c.github.io/payment-request/#paymentrequest-interface): the page describes the accepted payment methods and the details of the payment, and PaymentRequest.Show shows the payment sheet of the user agent. The payment handlers and the payment sheet are the ones of the user agent UI backend (BrowsingContextOptions.UserAgentUI, see UserAgentUIBackend.HasPaymentHandlerAsync and UserAgentUIBackend.ShowPaymentSheetAsync): without a backend, no payment method is supported. The constructor throws a SecurityError DomException when the document is not allowed to use the payment feature (its default allowlist is 'self').
public sealed class PaymentRequest : EventTarget- Inheritance
EventTargetPaymentRequest
Constructors
| Name | Description |
|---|---|
| PaymentRequest(Window, IReadOnlyList<PaymentMethodData>, PaymentDetailsInit, PaymentOptions?) | Creates a payment request for a window (https://w3c.github.io/payment-request/#constructor): the payment methods are validated (a TypeErrorException when there is none, a RangeErrorException for an invalid or duplicate identifier), their data is serialized to JSON, and the amounts are checked (a RangeErrorException for a currency code that is not well-formed, a TypeErrorException for an invalid or negative total value). |
| PaymentRequest(IReadOnlyList<PaymentMethodData>, PaymentDetailsInit, PaymentOptions?) | Creates a payment request for the current window (https://w3c.github.io/payment-request/#constructor). |
PaymentRequest overloads
PaymentRequest(Window, IReadOnlyList<PaymentMethodData>, PaymentDetailsInit, PaymentOptions?)
PaymentRequest.csCreates a payment request for a window (https://w3c.github.io/payment-request/#constructor): the payment methods are validated (a TypeErrorException when there is none, a RangeErrorException for an invalid or duplicate identifier), their data is serialized to JSON, and the amounts are checked (a RangeErrorException for a currency code that is not well-formed, a TypeErrorException for an invalid or negative total value).
public PaymentRequest(Window window, IReadOnlyList<PaymentMethodData> methodData, PaymentDetailsInit details, PaymentOptions? options = null)Parameters
windowWindow- The window of the request.
methodDataIReadOnlyList<PaymentMethodData>- The accepted payment methods.
detailsPaymentDetailsInit- The details of the payment.
optionsPaymentOptions?- The information to collect.
PaymentRequest(IReadOnlyList<PaymentMethodData>, PaymentDetailsInit, PaymentOptions?)
PaymentRequest.csCreates a payment request for the current window (https://w3c.github.io/payment-request/#constructor).
public PaymentRequest(IReadOnlyList<PaymentMethodData> methodData, PaymentDetailsInit details, PaymentOptions? options = null)Parameters
methodDataIReadOnlyList<PaymentMethodData>detailsPaymentDetailsInitoptionsPaymentOptions?
See also
Properties
| Name | Description |
|---|---|
| Id | Gets the identifier of the request: the one given by the page, or a unique identifier generated by the user agent. |
| OnPaymentMethodChange | Gets or sets the event handler of the paymentmethodchange event. |
| OnShippingAddressChange | Gets or sets the event handler of the shippingaddresschange event. |
| OnShippingOptionChange | Gets or sets the event handler of the shippingoptionchange event. |
| ShippingAddress | Gets the shipping address chosen by the user (without the members that identify the recipient while the sheet is shown), or null. |
| ShippingOption | Gets the identifier of the selected shipping option, or null. |
| ShippingType | Gets the kind of address collected when the request requests shipping, or null. |
Gets the identifier of the request: the one given by the page, or a unique identifier generated by the user agent.
public string Id { get; }OnPaymentMethodChange
PaymentRequest.csGets or sets the event handler of the paymentmethodchange event.
OnShippingAddressChange
PaymentRequest.csGets or sets the event handler of the shippingaddresschange event.
OnShippingOptionChange
PaymentRequest.csGets or sets the event handler of the shippingoptionchange event.
ShippingAddress
PaymentRequest.csGets the shipping address chosen by the user (without the members that identify the recipient while the sheet is shown), or null.
public ContactAddress? ShippingAddress { get; }Property value
See also
ShippingOption
PaymentRequest.csGets the identifier of the selected shipping option, or null.
public string? ShippingOption { get; }Property value
See also
ShippingType
PaymentRequest.csGets the kind of address collected when the request requests shipping, or null.
public PaymentShippingType? ShippingType { get; }Methods
| Name | Description |
|---|---|
| Abort() | Aborts the request while the payment sheet is shown (https://w3c.github.io/payment-request/#abort-method): the sheet is closed and the task of PaymentRequest.Show fails with an AbortError DomException. The task fails with an InvalidStateError when the request is not shown or a payment is being retried. |
| CanMakePayment() | Returns whether the user agent supports one of the payment methods (https://w3c.github.io/payment-request/#can-make-payment-algorithm), as answered by UserAgentUIBackend.HasPaymentHandlerAsync. The task fails with an InvalidStateError DomException when the request was shown or the document is not fully active. |
| GetSecurePaymentConfirmationCapabilities() | Returns the capabilities of Secure Payment Confirmation (https://w3c.github.io/secure-payment-confirmation/#sctn-secure-payment-confirmation-capabilities), sorted by key: browserBoundKeyHardware is false (the browser bound keys are software keys). |
| SecurePaymentConfirmationAvailability() | Returns whether Secure Payment Confirmation is available in the current document (https://w3c.github.io/secure-payment-confirmation/#sctn-secure-payment-confirmation-available-api): it is not enabled when the backend has no payment handler for secure-payment-confirmation (UserAgentUIBackend.HasPaymentHandlerAsync), and it needs the payment feature and a user-verifying platform authenticator. The availability is unknown in a document that is not fully active. |
| Show(Task<PaymentDetailsUpdate>?) | Shows the payment sheet (https://w3c.github.io/payment-request/#show-method): the task completes with the response of the user once they accept the payment. It fails with a SecurityError DomException when the window has no transient activation (which is consumed), an InvalidStateError when the document is not fully active or the request was already shown, an AbortError when the document is hidden, another payment sheet is shown in the tab, the user dismisses the sheet or the page aborts the request, and a NotSupportedError when the user agent supports none of the payment methods. detailsPromise updates the details once settled. |
Abort()
PaymentRequest.csAborts the request while the payment sheet is shown (https://w3c.github.io/payment-request/#abort-method): the sheet is closed and the task of PaymentRequest.Show fails with an AbortError DomException. The task fails with an InvalidStateError when the request is not shown or a payment is being retried.
public Task Abort()CanMakePayment()
PaymentRequest.csReturns whether the user agent supports one of the payment methods (https://w3c.github.io/payment-request/#can-make-payment-algorithm), as answered by UserAgentUIBackend.HasPaymentHandlerAsync. The task fails with an InvalidStateError DomException when the request was shown or the document is not fully active.
GetSecurePaymentConfirmationCapabilities()
PaymentRequest.SecurePaymentConfirmation.csReturns the capabilities of Secure Payment Confirmation (https://w3c.github.io/secure-payment-confirmation/#sctn-secure-payment-confirmation-capabilities), sorted by key: browserBoundKeyHardware is false (the browser bound keys are software keys).
public static Task<IReadOnlyList<KeyValuePair<string, bool>>> GetSecurePaymentConfirmationCapabilities()SecurePaymentConfirmationAvailability()
PaymentRequest.SecurePaymentConfirmation.csReturns whether Secure Payment Confirmation is available in the current document (https://w3c.github.io/secure-payment-confirmation/#sctn-secure-payment-confirmation-available-api): it is not enabled when the backend has no payment handler for secure-payment-confirmation (UserAgentUIBackend.HasPaymentHandlerAsync), and it needs the payment feature and a user-verifying platform authenticator. The availability is unknown in a document that is not fully active.
public static Task<SecurePaymentConfirmationAvailability> SecurePaymentConfirmationAvailability()Show(Task<PaymentDetailsUpdate>?)
PaymentRequest.csShows the payment sheet (https://w3c.github.io/payment-request/#show-method): the task completes with the response of the user once they accept the payment. It fails with a SecurityError DomException when the window has no transient activation (which is consumed), an InvalidStateError when the document is not fully active or the request was already shown, an AbortError when the document is hidden, another payment sheet is shown in the tab, the user dismisses the sheet or the page aborts the request, and a NotSupportedError when the user agent supports none of the payment methods. detailsPromise updates the details once settled.
public Task<PaymentResponse> Show(Task<PaymentDetailsUpdate>? detailsPromise = null)