Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 2
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2/**
3 * The Subscription Service represents the entity responsible for making sure a visitor
4 * can see blocks that are considered premium content.
5 *
6 * If a visitor is not allowed to see they need to be given a way gain access.
7 *
8 * It is assumed that it will be a monetary exchange but that is up to the host
9 * that brokers the content exchange.
10 *
11 * @package Automattic\Jetpack\Extensions\Premium_Content;
12 */
13
14namespace Automattic\Jetpack\Extensions\Premium_Content\Subscription_Service;
15
16if ( ! defined( 'ABSPATH' ) ) {
17    exit( 0 );
18}
19
20interface Subscription_Service {
21
22    /**
23     * The subscription service can be used.
24     *
25     * @return bool
26     */
27    public static function available();
28
29    /**
30     * Allows a Subscription Service to setup anything it needs to provide its features.
31     *
32     * This is called during an `init` action hook callback.
33     *
34     * Examples of things a Service may want to do here:
35     *  - Determine a visitor is arriving with a new token to unlock content and
36     *    store the token for future browsing (e.g. in a cookie)
37     *  - Set up WP-API endpoints necessary for the function to work
38     *    - Token refreshes
39     *
40     * @return void
41     */
42    public function initialize();
43
44    /**
45     * Given a token (this could be from a cookie, a querystring, or some other means)
46     * can the visitor see the premium content?
47     *
48     * @param array  $valid_plan_ids .
49     * @param string $access_level .
50     *
51     * @return bool
52     */
53    public function visitor_can_view_content( $valid_plan_ids, $access_level );
54
55    /**
56     * Is the current user a pending subscriber for the current site?
57     *
58     * @return bool
59     */
60    public function is_current_user_pending_subscriber(): bool;
61
62    /**
63     * The current visitor would like to obtain access. Where do they go?
64     *
65     * @param string $mode .
66     * @return string
67     */
68    public function access_url( $mode = 'subscribe' );
69}