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
ExtendableEventPaymentRequestEvent
Constructors
| Name | Description |
|---|---|
| PaymentRequestEvent(string, PaymentRequestEventInit?) | Creates an event. |
PaymentRequestEvent(string, PaymentRequestEventInit?)
PaymentHandler.csCreates an event.
public PaymentRequestEvent(string type, PaymentRequestEventInit? eventInitDict = null)Parameters
typestring- The type of the event.
eventInitDictPaymentRequestEventInit?- The initialization dictionary.
See also
Properties
| Name | Description |
|---|---|
| MethodData | Gets the payment methods of the request that the payment handler supports. |
| Modifiers | Gets the modifiers of the payment methods that the payment handler supports. |
| PaymentOptions | Gets the information that the payment handler collects (a PaymentOptions), or null. |
| PaymentRequestId | Gets the identifier of the payment request. |
| PaymentRequestOrigin | Gets the origin of the document that created the payment request. |
| ShippingOptions | Gets the shipping options, or null. |
| TopOrigin | Gets the origin of the top-level document of the payment request. |
| Total | Gets the total of the payment (a PaymentCurrencyAmount). |
MethodData
PaymentHandler.csGets the payment methods of the request that the payment handler supports.
public IReadOnlyList<PaymentMethodData> MethodData { get; }Modifiers
PaymentHandler.csGets the modifiers of the payment methods that the payment handler supports.
public IReadOnlyList<PaymentDetailsModifier> Modifiers { get; }PaymentOptions
PaymentHandler.csGets the information that the payment handler collects (a PaymentOptions), or null.
public object? PaymentOptions { get; }PaymentRequestId
PaymentHandler.csGets the identifier of the payment request.
public string PaymentRequestId { get; }PaymentRequestOrigin
PaymentHandler.csGets the origin of the document that created the payment request.
public string PaymentRequestOrigin { get; }ShippingOptions
PaymentHandler.csGets the shipping options, or null.
public IReadOnlyList<PaymentShippingOption>? ShippingOptions { get; }TopOrigin
PaymentHandler.csGets the origin of the top-level document of the payment request.
public string TopOrigin { get; }Property value
See also
Total
PaymentHandler.csGets the total of the payment (a PaymentCurrencyAmount).
public object Total { get; }Property value
See also
Methods
| Name | Description |
|---|---|
| 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.csReports 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)ChangeShippingAddress(AddressInit?)
PaymentHandler.csReports 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)Parameters
shippingAddressAddressInit?- The shipping address.
Returns
Task<PaymentRequestDetailsUpdate?>
See also
ChangeShippingOption(string)
PaymentHandler.csReports 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)Parameters
shippingOptionstring- The identifier of the shipping option.
Returns
Task<PaymentRequestDetailsUpdate?>
See also
OpenWindow(string)
PaymentHandler.csOpens 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.csAnswers 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
handlerResponsePromiseTask<PaymentHandlerResponse>- The response of the payment handler.