Site Tools


paywall_invoker:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
paywall_invoker:start [2021/01/01 01:06] – [Paywall events] joaosaraivapaywall_invoker:start [2026/03/27 17:24] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== Interacting with the Paywall ======
  
 +You can interact with the Paywall when you invoke it and when you listen to the events it fires.
 +
 +===== Loading the Paywall =====
 +
 +You load the Paywall by getting a small invoker Javascript file. The easiest way to do this is to include a ''script'' tag in your HTML page, like this:
 +<code html>
 +<script src="https://cdn.paperview-services.com/reader/paywall-invoker/paperview.js" async></script>
 +</code>
 +
 +There are different versions of the Paywall invoker file, so that you can access the one that is most adequate to your needs.\\
 +The available files are:
 +  * https://cdn.paperview-services.com/reader/paywall-invoker/paperview.js
 +  * https://cdn.paperview-services.com/reader/paywall-invoker/paperview.declarative.js
 +  * https://cdn.paperview-services.com/reader/paywall-invoker/paperview.imperative.js
 +
 +The file's name indicates whether the invoker supports both the declarative and imperative invocations of the Paywall, or only the declarative or imperative invocation. Like this:
 +  * ''paperview.js'' - Supports both declarative and imperative invocations of the Paywall.
 +  * ''paperview.declarative.js'' - Like ''paperview.js'', but supports only **declarative invocation**. This disadvantage typically comes at the benefit of smaller file size.
 +  * ''paperview.imperative.js'' - Like ''paperview.js'', but supports only **imperative invocation**.
 +
 +Note that, if you wish to open the Paywall in sandbox mode, you need to adjust the above URLs to include the ''-sandbox'' subdomain suffix. Thus, the URL\\
 +''https://cdn.paperview-services.com/reader/paywall-invoker/paperview.js''\\
 +becomes\\
 +''https://cdn-sandbox.paperview-services.com/reader/paywall-invoker/paperview.js''
 +===== Invoking the Paywall =====
 +
 +The Paperview Paywall can be summoned by one of the following means:
 +  * [[paywall_invoker:declarative|Declarative invocation]], via HTML element data attributes, or
 +  * [[paywall_invoker:imperative|Imperative invocation]], by issuing commands via Javascript
 +
 +===== Paywall events =====
 +
 +The Paywall also fires some DOM events during its lifecycle, regardless of the manner used to invoke it.\\
 +You can listen for these DOM events by hooking a listener to the global ''window'' object. You can do it like this:
 +<code javascript>
 +window.addEventListener("paperview::<event you want to listen for>", function(_event) {
 +  // stuff you want to do when the event fires
 +});
 +</code>
 +
 +You can find a comprehensive list of the supported DOM events [[paywall_invoker:javascript_events|here]].