Table of Contents
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:
<script src="https://cdn.paperview-services.com/reader/paywall-invoker/paperview.js" async></script>
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:
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- Likepaperview.js, but supports only declarative invocation. This disadvantage typically comes at the benefit of smaller file size.paperview.imperative.js- Likepaperview.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:
- Declarative invocation, via HTML element data attributes, or
- 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:
window.addEventListener("paperview::<event you want to listen for>", function(_event) { // stuff you want to do when the event fires });
You can find a comprehensive list of the supported DOM events here.
