Namespace: SpawnDev.SpawnJS.JSObjects
Inherits: ExtendableEvent
Source: JSObjects/CanMakePaymentEvent.cs
MDN Reference: CanMakePaymentEvent on MDN
The canmakepayment event of the ServiceWorkerGlobalScope interface is fired on a payment app's service worker to check whether it is ready to handle a payment. Specifically, it is fired when the merchant website calls the PaymentRequest() constructor. https://developer.mozilla.org/en-US/docs/Web/API/CanMakePaymentEvent
| Method | Return Type | Description |
|---|---|---|
RespondWith(Task<bool> response) |
void |
Enables the service worker to respond appropriately to signal whether it is ready to handle payments. |
RespondWith(Promise<bool> response) |
void |
Enables the service worker to respond appropriately to signal whether it is ready to handle payments. |
SpawnDev.SpawnJS Mapping Note: The JavaScript examples below show the standard Web API usage. In SpawnDev.SpawnJS, the same API is available with C# conventions:
- Properties and methods use PascalCase (e.g.,
readyStatebecomesReadyState)- Events use ActionEvent with
+=/-=(e.g.,addEventListener("click", fn)becomesOnClick += handler)- Async methods return
Task<T>instead ofPromise<T>- Objects should be disposed with
usingstatements- Access via
JS.Get<CanMakePaymentEvent>(...)or constructornew CanMakePaymentEvent(...)
self.addEventListener("canmakepayment", (e) => {
e.respondWith(
new Promise((resolve, reject) => {
someAppSpecificLogic()
.then((result) => {
resolve(result);
})
.catch((error) => {
reject(error);
});
}),
);
});