The Easiest License
- 程序库
- Dario Pedruzzi
- 版本: 1.0
- 激活: 5
Use a plain google sheet to license your product
After years of developing trading software, I noticed the lack of a simple and cheap system to license the software to your customer.
Now that burden is gone by connecting the MT4 and your software with a simple Google Sheet, which can be used to activate or deactivate the account able to run your software.
With a minimum setup you'll be able to compile your software and distributing it without the fear of being spoiled by hackers or bad people.
On one spreadsheet you'll be able to manage multiple products and make your customer happy (and paying).
What the library can do:
- include a header file and the class constructor in your software (Indicator or Expert Advisor or Utility)
- initiate the class and call the setup method
- use the CheckLicense method in an OnTimer or OnClick to get a response
Type of responses:
The CheckLicense method will return:
- 0 if there is some issue (terminal not connected, account number equal to zero, and so on)
- 1 if the license is valid and the account can operate your software
- -1 if the account number provided is not able to operate your software
What you will have to do to use the library:
Activate the web requests to https://sheets.googleapis.com domain
Produce a header file and put it in the "includes" folder
Produce a Google Sheet API KEY (google it or wait for me writing the actual procedure)
Collect the Google Sheet ID (it's in the URL of the spreadsheet)
Manage your software behavior in the three cases (send an alert, deactivate, don't paint anything, and so on)
Code example for an Indicator:
// header file (Copy and paste it in a new LicenseEngineHeader.mqh file in the includes folder)
//+------------------------------------------------------------------+ //| CGSLE.mqh | //| Copyright 2024, D'ario Woollover | //| https://www.automazionetrading.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2024, D'ario Woollover" #property link "https://www.automazionetrading.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class CGSLE { private: string m_base_url; string m_product_name; string m_spreadsheet_id; string m_column_id; string m_api_key; int m_account_count; string m_allowed_accounts[]; string m_cookie, m_headers; char m_post[], m_result[]; int m_timeout; public: CGSLE() {}; ~CGSLE() {}; virtual void Setup(string API_KEY, string spreadsheet_id, string product_name, string column_to_check = "A", int account_count = 300) {}; virtual int CheckLicense(int account_number) {return 0;}; private: virtual int Initialize() {return 0;}; virtual string BuildURL() {return "";}; }; //+------------------------------------------------------------------+
// includes in yourproduct file
#include <LicenseEngineHeader.mqh>
#import "LicenseEngine.ex4"
CGSLE *iGSLE();
#import
// initiation
LicenseEngine = iGSLE(); LicenseEngine.Setup(PERSONAL_API_KEY, SPREADSHEET_ID, PRODUCT_NAME);
// onTick or OnTimer, OnCalculate implementation
if(!IsConnected()) { return; } int account_num = AccountNumber(); int check = LicenseEngine.CheckLicense(account_num); if(check == -1 && !alertSent) { MessageBox("Sorry, your account is not licensed, please contact 'greatdeveloper@tradingdomain.com'", "Invalid Account", MB_ICONERROR | MB_OK); alertSent = true; return; } if(check != 1) { return; }
In future releases, if requested:
- Expiration date support
- Check license by email
- Alerts customization
- Refresh of activated accounts every XXX minutes
- MT5 Version