PaymentRequestEvent Class

The event fired at the service worker of a payment handler to handle a payment (https://w3c.github.io/web-based-payment-handler/#the-paymentrequestevent). The library never fires it: an event created by a script cannot be answered, nor open a window.

public sealed class PaymentRequestEvent : ExtendableEvent
Inheritance
ExtendableEvent PaymentRequestEvent

Constructors

NameDescription
PaymentRequestEvent(string, PaymentRequestEventInit?)Creates an event.

PaymentRequestEvent(string, PaymentRequestEventInit?)

PaymentHandler.cs

Creates an event.

public PaymentRequestEvent(string type, PaymentRequestEventInit? eventInitDict = null)

Parameters

type string
The type of the event.
eventInitDict PaymentRequestEventInit?
The initialization dictionary.

See also

Properties

NameDescription
MethodDataGets the payment methods of the request that the payment handler supports.
ModifiersGets the modifiers of the payment methods that the payment handler supports.
PaymentOptionsGets the information that the payment handler collects (a PaymentOptions), or null.
PaymentRequestIdGets the identifier of the payment request.
PaymentRequestOriginGets the origin of the document that created the payment request.
ShippingOptionsGets the shipping options, or null.
TopOriginGets the origin of the top-level document of the payment request.
TotalGets the total of the payment (a PaymentCurrencyAmount).

Gets the payment methods of the request that the payment handler supports.

public IReadOnlyList<PaymentMethodData> MethodData { get; }

Gets the modifiers of the payment methods that the payment handler supports.

public IReadOnlyList<PaymentDetailsModifier> Modifiers { get; }

PaymentOptions

PaymentHandler.cs

Gets the information that the payment handler collects (a PaymentOptions), or null.

public object? PaymentOptions { get; }

PaymentRequestId

PaymentHandler.cs

Gets the identifier of the payment request.

public string PaymentRequestId { get; }

PaymentRequestOrigin

PaymentHandler.cs

Gets the origin of the document that created the payment request.

public string PaymentRequestOrigin { get; }

ShippingOptions

PaymentHandler.cs

Gets the origin of the top-level document of the payment request.

public string TopOrigin { get; }

Gets the total of the payment (a PaymentCurrencyAmount).

public object Total { get; }

Methods

NameDescription
ChangePaymentMethod(string, object?)Reports that the user changed the payment method (https://w3c.github.io/web-based-payment-handler/#dom-paymentrequestevent-changepaymentmethod). The task fails with an InvalidStateError DomException: the event does not handle a payment request of the user agent.
ChangeShippingAddress(AddressInit?)Reports that the user changed the shipping address (https://w3c.github.io/web-based-payment-handler/#dom-paymentrequestevent-changeshippingaddress). The task fails with an InvalidStateError DomException: the event does not handle a payment request of the user agent.
ChangeShippingOption(string)Reports that the user changed the shipping option (https://w3c.github.io/web-based-payment-handler/#dom-paymentrequestevent-changeshippingoption). The task fails with an InvalidStateError DomException: the event does not handle a payment request of the user agent.
OpenWindow(string)Opens a window of the payment handler (https://w3c.github.io/web-based-payment-handler/#dom-paymentrequestevent-openwindow). The task fails with an InvalidStateError DomException: the event does not handle a payment request of the user agent.
RespondWith(Task<PaymentHandlerResponse>)Answers the payment request (https://w3c.github.io/web-based-payment-handler/#dom-paymentrequestevent-respondwith). Throws an InvalidStateError DomException when the event is not trusted, is not being dispatched or was already answered.

ChangePaymentMethod(string, object?)

PaymentHandler.cs

Reports that the user changed the payment method (https://w3c.github.io/web-based-payment-handler/#dom-paymentrequestevent-changepaymentmethod). The task fails with an InvalidStateError DomException: the event does not handle a payment request of the user agent.

public Task<PaymentRequestDetailsUpdate?> ChangePaymentMethod(string methodName, object? methodDetails = null)

Parameters

methodName string
The payment method.
methodDetails object?
The details of the payment method.

Returns

Task<PaymentRequestDetailsUpdate?>

See also

ChangeShippingAddress(AddressInit?)

PaymentHandler.cs

Reports that the user changed the shipping address (https://w3c.github.io/web-based-payment-handler/#dom-paymentrequestevent-changeshippingaddress). The task fails with an InvalidStateError DomException: the event does not handle a payment request of the user agent.

public Task<PaymentRequestDetailsUpdate?> ChangeShippingAddress(AddressInit? shippingAddress = null)

ChangeShippingOption(string)

PaymentHandler.cs

Reports that the user changed the shipping option (https://w3c.github.io/web-based-payment-handler/#dom-paymentrequestevent-changeshippingoption). The task fails with an InvalidStateError DomException: the event does not handle a payment request of the user agent.

public Task<PaymentRequestDetailsUpdate?> ChangeShippingOption(string shippingOption)

OpenWindow(string)

PaymentHandler.cs

Opens a window of the payment handler (https://w3c.github.io/web-based-payment-handler/#dom-paymentrequestevent-openwindow). The task fails with an InvalidStateError DomException: the event does not handle a payment request of the user agent.

public Task<WindowClient?> OpenWindow(string url)

RespondWith(Task<PaymentHandlerResponse>)

PaymentHandler.cs

Answers the payment request (https://w3c.github.io/web-based-payment-handler/#dom-paymentrequestevent-respondwith). Throws an InvalidStateError DomException when the event is not trusted, is not being dispatched or was already answered.

public void RespondWith(Task<PaymentHandlerResponse> handlerResponsePromise)

Parameters

handlerResponsePromise Task<PaymentHandlerResponse>
The response of the payment handler.

See also