WICG / webmonetization

Proposed Web Monetization standard
https://webmonetization.org
Other
441 stars 150 forks source link

General 'web monetization is/is not supported' message needed #246

Open pp-koch opened 2 years ago

pp-koch commented 2 years ago

So I wrote a really simple example script that plays a video and shows premium content onmonetization. https://quirksmode.org/coil/testsuite/example-script.html

Requires CoilPreview 0.0.70. Only one is supported here, so wait for the video to play, then use the button to move the link tag.

One conclusion is obvious: we MUST have a simple way for the web developer to figure out immediately if web monetization is possible at all.

If it isn't there should be a message 'Enabled web monetization to view video' or something. That text is not a default placeholder, though: if monetization IS supported but not yet running nothing should happen.

So we need a replacement for

if (!navigator.monetization) { // monetization not supported }

sublimator commented 2 years ago

Something else I pondered might warrant Return of the Monetization is some kind of field to do provider attestation ... but then I wondered if that could just be a field on the monetization event ?

sublimator commented 2 years ago

re: CoilPreview https://chrome.google.com/webstore/detail/coilpreview/iehmfkldnblennopinmmagfidpflefkp

marcoscaceres commented 2 years ago

A developer can now check: if ("MonetizationEvent" in window) instead of navigator.

pp-koch commented 2 years ago

Ugly. But it works. This is something that has to be improved in the next version.

marcoscaceres commented 2 years ago

Alternative:

var link = document.querySelector("link[rel='monetization']")
      || document.createElement("link");
if (link.relList.supports("monetization")) {
  // ...supported... 
} 
sublimator commented 2 years ago

manifest?

marcoscaceres commented 2 years ago

Oops, copy/pasta

marcoscaceres commented 2 years ago

Fixed

sublimator commented 2 years ago

So that would need to be gorilla glued in the coil extension too I guess

pp-koch commented 2 years ago

Yes. Right now it doesn't work with the CoilPreview 0.0.72 extension: it always returns false.

pp-koch commented 2 years ago

About (link.relList.supports("monetization")) as a feature detection ...

IF a browser natively supports web monetization BUT the user is not signed in to any payment provider will this return true or false?

I assume we can't tell yet, but if we use this line as a general feature detection and it starts to misbehave later we have a problem ...

AlexLakatos commented 10 months ago

The "browser" related checks (MonetizationEvent, relList) tell a page that the User Agent (browser or extension) supports monetization, but not if the User is Web Monetized (has a Web Monetization provider / payment pointer and can pay). The triggering of the load event on the link is what informs the page that the User is Web Monetized. And that's because if the User Agent doesn't have a way to pay, it won't process the payment pointer found on the page.