# Subscription plugin

From now on, third-party developers can upload subscription-type plug-ins in the BeikeShop plug-in market!

# What is the Subscription Plugin?

Unlike regular plugins that require a one-time payment, subscription plugins require a monthly subscription to continue using after the customer's initial purchase.

# Note to developers:

1.Subscription plug-ins mainly adopt the C/S (client/server) mode, in which the plug-in acts as the client and the core function developed by the developer acts as the server. The plug-in obtains subscription information and performs corresponding operations through the API provided by the server.

2.When developing a subscription plug-in, developers need to provide a subscription link on the appropriate page to provide users with subscription services; and implement subscription status query in the core function.

3.When developers list plug-ins, they need to set at least 1 month of "free subscription" time to ensure that customers can use it immediately after purchase.

4.After users purchase a subscription plug-in, they will have at least 1 month of "free subscription" time; after the expiration, they need to purchase a subscription to continue using the plug-in.

5.Developers can develop plug-ins with subscription models such as product collection, data analysis tools, and member value-added services based on this function to provide users with richer functions or services!

# Subscription plugin development steps

# Server Development

1.The main task of the server is to process the subscription plug-in request, verify the validity of the request, provide subscription status, manage subscription data, etc.
You can use php, nodejs, python, java, golang, c, c++ and other server development languages ​​to develop, and provide data to the subscription plug-in in various forms, such as: RESTful API, GraphQL API, gRPC, etc.

2.The server needs to implement a subscription status query interface to verify and obtain the status of the subscription plugin. This interface needs to accept client requests, verify the subscription status, and return the corresponding data.

Subscription status query interface example:

https://beikeshop.cn/subscribe/<Subscription plugin code>/status?domain=<Subscribed domain name>

Return data format:

return

{
    "status": "success",//Return Status
    "message": "Get Success",//Return information
    "data": {
        "valid": false,//Subscribe
        "code": "xx", //Plugin code
        "domain": "xx",//Subscribe to domain name
        "expired_at": "xx", //Expiration time
        "message": "This domain has not been subscribed yet!"//If not subscribed, the prompt information returned
    }
}

Note: To improve request efficiency, you can cache query results and request again after the data expires.

3.In addition to providing basic data services, the server can also write complex and core logic on the server to prevent others from copying the fruits of your labor.

# Client Development

1.The client is mainly the plug-in part, which needs to implement the basic functions of the plug-in.

2.Plugins need to be developed under the framework of BeikeShop. You can refer to the development documents provided by BeikeShop and develop plugins according to the prescribed framework and process.

3.When the client requests the server, it must bring the corresponding domain name parameter. The server will verify the subscription status of the plug-in based on the domain name.

The following is an example request:


// Example: Making a request using JavaScript
const domain = 'example.com';  // The domain name used by the current plugin
const pluginCode = 'your-plugin-code';  // Plugin unique identifier

fetch(`https://beikeshop.cn/subscribe/${pluginCode}/status?domain=${domain}`)
  .then(response => response.json())
  .then(data => {
    if (data.status === 'success') {
      // Handling subscription status
      if (data.data.valid) {
        console.log(`This domain has been subscribed and the subscription is valid until:${data.data.expired_at}`);
      } else {
        console.log(`This domain has not been subscribed yet:${data.data.message}`);
      }
    } else {
      console.log('Request failed:', data.message);
    }
  })
  .catch(error => {
    console.error('Request error:', error);
  });

4.On the appropriate page of the plug-in, provide a subscription link, and users can complete the subscription operation by clicking the link.

https://beikeshop.cn/subscribe/<Subscription plugin code>?domain=<Subscribed domain name> //Subscription link provided in plugin

subscribe

# Plugins available

1.Shelf according to the basic process of plug-in listing

2.When listing, remember to check the "Subscribe" button; set the free subscription period (it is recommended that developers set a "free subscription" period of at least 1 month to ensure that customers can use it immediately after purchase.), subscription price.

subscribe

# Plugin Renewal

1.Click the subscription link provided by the developer to the customer in the plugin to renew

subscribe

2.In the plugin market, search for relevant subscription plugins and purchase subscriptions

subscribe