Marketplace subscription plugin

This tutorial will introduce you to subscription plugins. We will show you how you can offer the plugins you upload on plentyMarketplace on a subscription basis rather than for a fixed price. You can also offer some features of your plugin for free while charging for others, giving both you and your customers even greater flexibility.

Further reading

Folder structure

TopItems/
    ├-- resources/
    │   ├── lang
    |   |   ├── de
    |   |   |   └── config.properties
    |   |   |
    |   |   └── en
    |   |       └── config.properties
    |   |
    |   └── views/
    │       └── content/
    │           └── hello.twig
    │
    ├── src/
    │   ├── Controllers/
    │   │   └── ContentController.php
    │   │
    │   └── Providers/
    │       ├── HelloSubWorldRouteServiceProvider.php
    │       ├── HelloSubWorldServiceProvider.php
    │       ├── ServiceProviderForFreeComponents.php
    │       └── ServiceProviderForPremiumComponents.php
    |
    ├── config.json
    ├── marketplace.json // subscription information
    └── plugin.json // plugin information

marketplace.json

plugin-hello-subscription-world/marketplace.json
{
  "marketplaceName"   : {"de":"Hallo Subscription Welt","en":"Hello subscription world"},
  "license"           : "GPL",
  "price"             : 0,
  "shortDescription"  : {"de":"plentymarkets plugin subscription example","en":"plentymarkets plugin subscription example"},
  "categories"        : ["3518"],
  "keywords"          : ["plugins", "template"],
  "subscription": [
    {
      "interval": "monthly",
      "price": 10.00
    },
    {
      "interval": "quarterly",
      "price": 30.00
    },
    {
      "interval": "half-yearly",
      "price": 60.00
    },
    {
      "interval": "yearly",
      "price": 120.00
    }
  ]
}

Service provider

plugin-hello-subscription-world/src/Providers/HelloSubWorldServiceProvider.php
{
    getApplication()->register(HelloSubWorldRouteServiceProvider::class);
                $this->getApplication()->register(ServiceProviderForFreeComponenents::class);

                // get the Subscription Service
                $this->subscriptionInfoService = pluginApp(SubscriptionInformationServiceContract::class);

            // check if the subscription has been paid
            if ( $this->subscriptionInfoService->isPaid('HelloSubWorld') )
            {
                $this->getApplication()->register(ServiceProviderForPremiumComponenents::class);
            }
        }
    }
}

Is this article helpful?

 

Thank you for your Feedback

you can close this field now!