jetpack
/
extensions
/
blocks
/
premium-content
/
_inc
/
subscription-service
/
interface-subscription-service.php
class-abstract-token-subscription-service.php
2 years ago
class-jetpack-token-subscription-service.php
2 years ago
class-jwt.php
2 years ago
class-unconfigured-subscription-service.php
2 years ago
class-wpcom-offline-subscription-service.php
3 years ago
class-wpcom-online-subscription-service.php
2 years ago
include.php
2 years ago
interface-subscription-service.php
2 years ago
interface-subscription-service.php
66 lines
| 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 | |
| 14 | namespace Automattic\Jetpack\Extensions\Premium_Content\Subscription_Service; |
| 15 | |
| 16 | interface Subscription_Service { |
| 17 | |
| 18 | /** |
| 19 | * The subscription service can be used. |
| 20 | * |
| 21 | * @return bool |
| 22 | */ |
| 23 | public static function available(); |
| 24 | |
| 25 | /** |
| 26 | * Allows a Subscription Service to setup anything it needs to provide its features. |
| 27 | * |
| 28 | * This is called during an `init` action hook callback. |
| 29 | * |
| 30 | * Examples of things a Service may want to do here: |
| 31 | * - Determine a visitor is arriving with a new token to unlock content and |
| 32 | * store the token for future browsing (e.g. in a cookie) |
| 33 | * - Set up WP-API endpoints necessary for the function to work |
| 34 | * - Token refreshes |
| 35 | * |
| 36 | * @return void |
| 37 | */ |
| 38 | public function initialize(); |
| 39 | |
| 40 | /** |
| 41 | * Given a token (this could be from a cookie, a querystring, or some other means) |
| 42 | * can the visitor see the premium content? |
| 43 | * |
| 44 | * @param array $valid_plan_ids . |
| 45 | * @param string $access_level . |
| 46 | * |
| 47 | * @return bool |
| 48 | */ |
| 49 | public function visitor_can_view_content( $valid_plan_ids, $access_level ); |
| 50 | |
| 51 | /** |
| 52 | * Is the current user a pending subscriber for the current site? |
| 53 | * |
| 54 | * @return bool |
| 55 | */ |
| 56 | public function is_current_user_pending_subscriber(): bool; |
| 57 | |
| 58 | /** |
| 59 | * The current visitor would like to obtain access. Where do they go? |
| 60 | * |
| 61 | * @param string $mode . |
| 62 | * @return string |
| 63 | */ |
| 64 | public function access_url( $mode = 'subscribe' ); |
| 65 | } |
| 66 |