Skip to content

Subscription Plugin

Daniel Neto edited this page Apr 1, 2024 · 18 revisions

What is it

With this plugin, you can create plans for your users to be dynamically included in groups for a specific time.

For example: On your site, you can create a group of users called "Private" and add the videos that you want to be private in this group. So, only users who are associated with this group can view the videos.

So you do not have to manually add and remove users to these groups we created this plugin.

With the Subscription plugin, you can create plans, add a value to it and inform how long users who join it will continue.

One detail is that when the time expires the user may pay again for the subscription to renew.

How to configure it

The steps for building your subscription are as follows:

  1. In the left menu click on plugins
  2. Enable the following plugins
  • Subscription (Commercial)
  • YPTWallet (Free)
  • PayPalYPT (Free)
  1. Enable your PayPal API
  • Go to Paypal developer Website here https://developer.paypal.com/developer/applications (you must have Paypal account, of course)
  • Click on Create App on the right side of the page
  • Choose the name of your app and click Create App
  • Now you can see and manage everything including client ID and secret.
  1. Make sure that the "enablePlugin_YPTWalletPayPal" parameter is enabled inside your YPTWallet
  2. Make sure you have user groups created

Configure PayPal IPN

  1. Enable your IPN https://yoursite.com/plugin/PayPalYPT/ipn.php

https://developer.paypal.com/api/nvp-soap/ipn/IPNSetup/

You can buy our commercial plugins here https://www.youphptube.com/plugins/

If you are not sure how to install plugins, please read this https://github.com/WWBN/AVideo/wiki/How-To-Install-a-new-Plugin

Create your first plan.

Click the "Edit" button in the "Subscription" and you will find 2 tabs, the first tab lists all your subscriptions, in the second tab is where you will create your plans.

Fill in the information and select the groups that you want this plan to include the user.

After creating the groups they will be available for use.

Subscribing

You have a few options to reach the subscription page

  1. One subscription button will be displayed on the top bar (You can customize the button label on the plugin parameter)
  2. If a user does not have access to a video (he is not on the video group), the user will be directed to the subscription page.

On the subscription page, the user will see a list of available plans.

The amount used to pay the plans will be off the balance of the user's wallet if the available balance is not enough to pay the subscription you will be redirected to the PayPal page to complete the difference.

The deduced value will be transferred to the user with the ID specified in the plugin parameters

Screenshots with a single plan

image

image

image

Screenshots with more than one plan

image

image

How to Add a Crontab on Ubuntu

Cron is a time-based job scheduler in Unix-like operating systems, including Ubuntu. It allows you to run scripts or commands at scheduled times. Here’s a brief guide on how to add a cron job on an Ubuntu system.

1. Open Terminal

First, open your SSH terminal.

2. Access Crontab

To access the crontab for the current user, enter the following command:

crontab -e

If this is the first time you're using crontab, it might ask you to select an editor. Choose your preferred editor (for beginners, nano is recommended) by typing the corresponding number and pressing Enter.

3. Add Your Cron Job

Once the editor opens, you can add your cron job to the bottom of the file. In your case, you want to run a PHP script every minute. Here’s the line you’ll add:

* * * * * php /var/www/html/AVideo/plugin/Subscription/crontab.php 65d4abca20bbd

This cron job breakdown is as follows:

  • * * * * *: The schedule when the cron job runs. Each asterisk represents a unit of time. From left to right, these units are minute, hour, day of the month, month, and day of the week. By using * in all positions, you're specifying to run the command every minute of every day.
  • php: The command to run. In this case, you're specifying to use PHP to run a script.
  • /var/www/html/AVideo/plugin/Subscription/crontab.php: The path to the PHP script you want to run.
  • 65d4abca20bbd: this is the authKey (security reasons)

image

4. Save and Exit

Save the file and exit the editor. If you’re using nano, you can do this by pressing Ctrl + O, then Enter, and Ctrl + X to exit.

5. Verify the Cron Job

To ensure your cron job is added correctly, you can list all cron jobs for the current user with:

crontab -l

This command displays all cron jobs scheduled under your user. You should see the line you just added.

Clone this wiki locally