-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decouple payments from session #46
Comments
The events on the frontend are also useful for leveraging WM when there's not a server-side component. Hiding banner ads, for instance, really shouldn't require a call to the backend because it's purely a frontend concern.
@adrianhopebailie do you know how possible this is? The service worker would have to stay around for a long time working in the background, and it would also need to detect page events / page state. i.e. if the page gets backgrounded, the payment handler would have to stop paying and then get notified when the page gets foregrounded. I think this is probably the largest barrier for this idea working
It would be really awesome to solve WM with existing APIs like this. It's nice to have a declarative API too (for things like scraping, noscript, amp, etc.), but maybe it's possible we could make a standard way of 'translating' a meta tag into a series of PaymentRequest calls. But trading off declarative API for standard browser support would be worth it |
@wilsonianb this is how I had envisioned us doing an imperative API for WM almost exactly. What I think we should consider is simply using the payment handler as a way to create the session and start paying and them return control back to the website via the PR API. My idea was to extend the The flow would be:
The response from the provider could indicate the amount of time that it will pay for until it requires a refresh so the website could proactively call |
@adrianhopebailie Do we want to give website the control of payments (specifically the ask for more/continue payment parts)? It aligns well with the PaymentRequest API, but I think it's opposite of how we've seen WM until now, in which the website passively listens to monetizationProgress. |
@sidvishnoi I think there are two distinct APIs: WM is a declarative API where a website declares a “way you can pay me” (i.e. a Payment Pointer). The website then may or may not respond to events emitted from the DOM that indicate it has received a payment. These payments could be small regular payments (streams) or larger one-off payments that the user initiates from the extension but the API is the same, each event is a receipt for a payment. Using the same underlying payment rail (Interledger) we can use PaymentRequest to request explicit payments from the user for IAP (in-app payment) scenarios or tip buttons rendered by the website. |
Closing as answered. |
#45 introduces the idea of web monetization payments that are decoupled from a particular session on a website. The website is pointed to a resource at the receiver (via the provider id) where the website can verify that a payment has been received. However, the payment(s) could have happened at any point in time, not necessarily during the current session.
This brings into question the necessity of the current
monetizationstart
andmonetizationprogress
events. Why does a website need to know when in-session payments have started and at what increments and amounts they are happening if (a) there’s more than enough already paid to the website to unlock content and (b) the in-session paid amounts can be used to fund unlocking content in future sessions? They could help inform payment verification retry logic if there wasn’t a sufficient existing paid amount. However, the events themselves aren’t guaranteed to represent actual payments, so a website could just retry at a frequency of its own choosing.If we were to determine the events aren’t needed, web monetization could be reduced to the following:
PaymentRequest
when the page loads with themonetization
method and payment pointer. The amount could be zero since it doesn’t matter.PaymentRequest
event is handled by a registeredmonetization
payment handler, which both determines how much to pay and triggers payments (potentially throughout the entire session).PaymentResponse
(either immediately or after starting payment, perhaps depending on if there’s a previously paid amount), which includes the monetization/provider ID (and JWT authorizing the user to be able to spend against the provider’s paid amount).PaymentRequest
with the amount it is attempting to charge. (The subsequentPaymentResponse
would be as useful for retrying asmonetizationprogress
is today.)If we were to replace websites'
monetization
meta/link tag with thePaymentRequest
, then I think web monetization could be fully supported by thePaymentRequest
andPaymentHandler
APIs without needing any additional functionality within browsers.The text was updated successfully, but these errors were encountered: