diff --git a/specification/index.html b/specification/index.html index 63ad721e..7de9bbbc 100644 --- a/specification/index.html +++ b/specification/index.html @@ -2,1014 +2,259 @@ - - - - - - Web Monetization - - - - - - - + - - -
-

- Web Monetization -

-

- Draft Community - Group Report -

-
-
- Latest published version: -
-
- https://webmonetization.org/specification -
-
- Latest editor's draft: -
-
- https://webmonetization.org/specification -
-
- Editors: -
-
- Alex Lakatos (Interledger - Foundation) -
-
- Adrian Hope-Bailie (Fynbos Technologies - Limited) -
-
- Former editors: -
-
- Nicholas Dudfield (Coil Technologies Inc.) - - Until -
-
- Ben Sharafian (Coil Technologies Inc.) - - Until -
-
- Marcos Caceres (W3C) - Until - -
-
- Feedback: -
-
- GitHub - wicg/webmonetization (pull requests, - new - issue, open issues) -
-
- -
-
-
-

- Abstract -

+ +

Web Monetization allows websites to automatically receive payments from users, facilitated by the user agent and a user's preferred monetization provider.

-
-

- Status of This Document -

-

- This specification was published by the Web Platform Incubator Community - Group. It is not a W3C Standard nor is it on the W3C Standards - Track. Please note that under the W3C Community - Contributor License Agreement (CLA) there is a limited opt-out and - other conditions apply. Learn more about W3C Community and Business Groups. -

-
-
- Warning -
-
-

- This specification is a work in progress within the community on - the best shape it should take. Please see the explainer for more info. -

-

- The specification reflects the desired end-state of the Web - Monetization APIs as currently anticipated and agreed to between - the contributors. The specification is being prepared here, in this - format, to collect the input of the Web community and prepare the - work to ultimately follow the W3C standards track should it have - the necessary support to do so. -

-

- For the most accurate reflection of the APIs that have been - implemented by providers see the - API documentation. -

-
+
+
+

+ This specification is a work in progress within the community on the + best shape it should take. Please see the documentation for more info. +

+

+ The specification reflects the desired end-state of the Web + Monetization APIs as currently anticipated and agreed to between the + contributors. The specification is being prepared here, in this + format, to collect the input of the Web community and prepare the + work to ultimately follow the W3C standards track should it have the + necessary support to do so. +

+

+ For the most accurate reflection of the APIs that have been + implemented by providers see the + API documentation. +

-

- GitHub - Issues are preferred for discussion of this specification. -

- -
-
-

- 1. Usage examples -

-
-

- This section is non-normative. -

-
-
-

- 1.1 Checking if Web Monetization is - supported -

-
+
+

+ Checking if Web Monetization is supported +

- Call supports() - on a - link element’s - relList passing the "monetization" - keyword to check if Web Monetization is supported by the user agent. + Call {{DOMTokenList/supports()}} on a [^link^] element’s + {{HTMLLinkElement/relList}} passing the `"monetization"` keyword to + check if Web Monetization is supported by the user agent.

-
-
-
-

- 1.2 Monetizing a web page -

-
-

If a "monetization" link becomes browsing-context - disconnected, a user agent MUST stop - the payment - session. + disconnected, a user agent MUST stop the [=payment session=].

-
-
-

- 5. onmonetization event handler -

-
+
+

+ `onmonetization` event handler +

- The onmonetization event handler is an - event handler content attribute that can be applied to any - element. The user - agent uses it to notify that some - link has been monetized. + The `onmonetization` event handler is an [=event handler content + attribute=] that can be applied to any [=element=]. The user agent uses + it to notify that some [^link^] has been [=monetized=].

-
-

- 6. monetization event -

-
+

+ monetization event +

- When the payment session has sent a - payment with a non-zero amount, perform the following steps: + When the [=payment session=] has sent a |payment| with a non-zero + amount, perform the following steps:

    -
  1. Let target be the - - HTMLLinkElement associated with the - payment - session. +
  2. Let |target:HTMLLinkElement| be the {{HTMLLinkElement}} associated + with the [=payment session=].
  3. -
  4. If target is - null, then return. +
  5. If |target| is `null`, then return.
  6. -
  7. Let eventInitDict be a - MonetizationEventInit - dictionary, whose members are initialized to match payment's - details. +
  8. Let |eventInitDict:MonetizationEventInit| be a + {{MonetizationEventInit}} dictionary, whose members are initialized to + match |payment|'s details.
  9. -
  10. Let event be a newly - constructed MonetizationEvent - initialized with eventInitDict. +
  11. Let |event:MonetizationEvent| be a newly constructed + {{MonetizationEvent}} initialized with |eventInitDict|.
  12. -
  13. - - Queue a task on the monetization task source - to perform the following steps: +
  14. [=Queue a task=] on the [=monetization task source=] to perform the + following steps:
      -
    1. If target is not - connected, return. +
    2. If |target| is not connected, return.
    3. -
    4. - Fire an - event named "monetization" at target, with bubbles - initialized to true. +
    5. [=Fire an event=] named `"monetization"` at |target|, with + {{Event/bubbles}} initialized to true.
-
-
-

- 7. Task sources -

-
+
+

+ Task sources +

- The following task - source is defined by this specifications. + The following [=task source=] is defined by this specifications.

- The monetization task - source + The monetization task source
Used by this specification to queue up non-blocking - MonetizationEvents. + {{MonetizationEvent}}s.
-
-
-

- 8. MonetizationCurrencyAmount - interface -

-
+
+

+ `MonetizationCurrencyAmount` interface +

- The MonetizationCurrencyAmount interface maps directly to - the - PaymentCurrencyAmount dictionary as defined in - [payment-request]. -

-
WebIDL[SecureContext, Exposed=Window]
-interface MonetizationCurrencyAmount {
-  readonly attribute DOMString currency;
-  readonly attribute DOMString value;
-};
-
-
-

- 8.1 currency - member -

-
+ The `MonetizationCurrencyAmount` interface maps directly to the + {{PaymentCurrencyAmount}} dictionary as defined in [[payment-request]]. +

+
+          [SecureContext, Exposed=Window]
+          interface MonetizationCurrencyAmount {
+            readonly attribute DOMString currency;
+            readonly attribute DOMString value;
+          };
+      
+
+

+ currency member +

The currency of the MonetizationCurrencyAmount. See the definition of - the currency member of - PaymentCurrencyAmount in [payment-request] for details. + the `currency` member of {{PaymentCurrencyAmount}} in + [[payment-request]] for details.

-
-
-

- 8.2 value member -

-
+
+

+ value member +

The amount of the MonetizationAmount. See the definition of the - value member in of - PaymentCurrencyAmount in [payment-request] for details. + `value` member in of {{PaymentCurrencyAmount}} in [[payment-request]] + for details.

-
-
-

- 9. MonetizationEvent interface -

-
-
WebIDL[SecureContext, Exposed=Window]
-interface MonetizationEvent : Event {
-  constructor(DOMString type, MonetizationEventInit eventInitDict);
-  readonly attribute DOMString? amount;
-  readonly attribute DOMString? assetCode;
-  readonly attribute octet? assetScale;
-  readonly attribute DOMString? receipt;
-  readonly attribute MonetizationCurrencyAmount amountSent;
-  readonly attribute USVString paymentPointer;
-  readonly attribute USVString? incomingPayment;
-};
+    
+

+ `MonetizationEvent` interface +

+
+        [SecureContext, Exposed=Window]
+        interface MonetizationEvent : Event {
+          constructor(DOMString type, MonetizationEventInit eventInitDict);
+          readonly attribute DOMString? amount;
+          readonly attribute DOMString? assetCode;
+          readonly attribute octet? assetScale;
+          readonly attribute DOMString? receipt;
+          readonly attribute MonetizationCurrencyAmount amountSent;
+          readonly attribute USVString paymentPointer;
+          readonly attribute USVString? incomingPayment;
+        };
 
-dictionary MonetizationEventInit : EventInit {
-  required DOMString? amount;
-  required DOMString? assetCode;
-  required octet? assetScale;
-  required DOMString? receipt;
-  required PaymentCurrencyAmount amountSent;
-  required USVString paymentPointer;
-  required USVString? incomingPayment;
-};
-
-
- Warning -
-
-

- The amount, assetCode, - assetScale and receipt attributes are - deprecated. -

-

- All monetization receivers - should be migrating from generating a STREAM - Receipt to supporting incoming payments via - [open-payments] and will no longer be - returning receipts to the browser. -

-

- As such the MonetizationEvent - no longer represents an amount received, it represents an amount - sent and returns a URL as the incomingPayment - attribute that can be used to determine the amount received. -

-
+ dictionary MonetizationEventInit : EventInit { + required DOMString? amount; + required DOMString? assetCode; + required octet? assetScale; + required DOMString? receipt; + required PaymentCurrencyAmount amountSent; + required USVString paymentPointer; + required USVString? incomingPayment; + }; +
+
+

+ The `amount`, `assetCode`, `assetScale` and `receipt` attributes are + deprecated. +

+

+ All [=monetization receivers=] should be migrating from generating a + [[[Receipt]]] to supporting incoming payments via [[open-payments]] + and will no longer be returning receipts to the browser. +

+

+ As such the {{MonetizationEvent}} no longer represents an amount + received, it represents an amount sent and returns a URL as the + {{MonetizationEvent/incomingPayment}} attribute that can be used to + determine the amount received. +

-
-
-

- 9.1 amount attribute (deprecated) -

-
+
+

+ amount attribute (deprecated) +

The amount received as reflected in the receipt from the - monetization receiver. When - getting, returns the value it was initialized with. + [=monetization receiver=]. When getting, returns the value it was + initialized with.

-
-
-

- 9.2 assetCode attribute (deprecated) -

-
+
+

+ assetCode attribute (deprecated) +

The three letter asset code identifying the amount's units (e.g., "USD" for US dollars). When getting, returns the value it was initialized with.

-
-
-

- 9.3 assetScale attribute - (deprecated) -

-
+
+

+ assetScale attribute (deprecated) +

The scale of the amount. For example, USD would have an assetScale of 2 when denominated in cents. When getting, returns the value it was initialized with.

-
-
- Note: - MonetizationCurrencyAmount -
-
- The members of the MonetizationCurrencyAmount interface - map directly to the value and currency - attributes of a - PaymentCurrencyAmount dictionary. See the documentation of - - PaymentCurrencyAmount for guidance on processing and - display of these attributes. -
-
-
-
-

- 9.4 amountSent attribute -

-
+
+ The members of the `MonetizationCurrencyAmount` interface map directly + to the `value` and `currency` attributes of a {{PaymentCurrencyAmount}} + dictionary. See the documentation of {{PaymentCurrencyAmount}} for + guidance on processing and display of these attributes. +
+
+

+ amountSent attribute +

The amount sent. This should be processed in the same way as - a - PaymentCurrencyAmount dictionary as defined in - [payment-request]. When getting, - returns the value it was initialized with. + a {{PaymentCurrencyAmount}} dictionary as defined in + [[payment-request]]. When getting, returns the value it was + initialized with.

-
-
-

- 9.5 receipt attribute (deprecated) -

-
+
+

+ receipt attribute (deprecated) +

- null or a base64-encoded STREAM - Receipt issued by the monetization receiver to - the monetization provider - as proof of the total amount received in the payment session. When getting, - returns the value it was initialized with. + `null` or a base64-encoded [[[Receipt]]] issued by the [=monetization + receiver=] to the [=monetization provider=] as proof of the total + amount received in the [=payment session=]. When getting, returns the + value it was initialized with.

-
-
-

- 9.6 paymentPointer attribute -

-
+
+

+ paymentPointer attribute +

- A URL representing the - payment - pointer that has been monetized. When getting, returns the value - it was initialized with. + A [=URL=] representing the [=payment pointer=] that has been + monetized. When getting, returns the value it was initialized with.

-
-
-

- 9.7 incomingPayment attribute -

-
+
+

+ incomingPayment attribute +

- A URL representing an - incoming payment at the monetization receiver. - When getting, returns the value it was initialized with. + A [=URL=] representing an incoming payment at the [=monetization + receiver=]. When getting, returns the value it was initialized with.

-
-

- 10. Permissions Policy integration -

-
+

+ Permissions Policy integration +

- This specification defines a - policy-controlled feature identified by the string "monetization". Its default allowlist - is 'self'. + This specification defines a [=policy-controlled feature=] identified + by the string "monetization". Its + default allowlist is `'self'`.

-
-
- Note -
- -
-
-
- Note -
- -
-
-
-
-

- 11. Content Security Policy -

-
-
-
- Note: Monkey patch 🐒 -
-

- This section will eventually be moved into the [CSP] and - [FETCH] specifications. +

-
-
-

- 11.1 monetization-src directive -

-
+ + +
+
+

+ Content Security Policy +

+

+ This section will eventually be moved into the [[CSP]] and [[FETCH]] + specifications. +

+
+

+ monetization-src directive +

The monetization-src directive restricts the URLs from which a - payment - pointer is loaded. The syntax for the directive's name and value - is described by the following ABNF: + [=payment pointer=] is loaded. The syntax for the directive's name + and value is described by the following ABNF:

-
directive-name  = "monetization-src"
-directive-value = serialized-source-list
-