Skip to content

A complete Stripe + PHP License Server integration + product support center + demo app ready to adjust and deploy. Get back to writing software in minutes.

cubiclesoft/license-server-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 

Repository files navigation

License Server Demo

A complete Stripe + PHP License Server integration + product support center + demo app ready to adjust and deploy. Get back to writing software in minutes.

Try it out here: https://license-server-demo.cubiclesoft.com/

Donate Discord

Features

  • Boilerplate, ready-made website + Demo App with working PHP-based Software License Server integration.
  • Simple configuration. Takes just a few minutes on most VPS hosts running Nginx.
  • Has a liberal open source license. MIT or LGPL, your choice. (NOTE: The demo binaries have a separate EULA.)
  • Designed for relatively painless integration into your project.
  • Sits on GitHub for all of that pull request and issue tracker goodness to easily submit changes and ideas respectively.

Getting Started

First, install the PHP-based Software License Server on a server and set up your first product and version.

Next, download or clone this repository and upload the contents of the license-server-demo.cubiclesoft.com/public_html directory to the same server. Note that this software assumes it will be hosted at the root of a domain or subdomain.

Next, create a Stripe account. Test keys work fine for testing purposes.

Edit base.php on the server and make relevant adjustments.

In the same directory as base.php, create a file called secrets.php and fill in the bits of required information:

<?php
	// Stripe keys.
	$stripe_publickey = "pk_...";
	$stripe_secretkey = "sk_...";

	// Generate a secret key:  https://www.random.org/integers/?num=20&min=0&max=255&col=10&base=16&format=plain&rnd=new
	$buy_form_secretkey = "...";

	// Discord integration for the live chat option in the product support center.
	// Get a webhook URL and Discord Bot token by following the directions here:  https://github.com/cubiclesoft/php-discord-sdk
	$discord_webhook = false;
	$discord_bottoken = "...";
	$discord_channelid = "...";

Adjust the web server configuration to have unknown paths in the /product-support/ path map to /product-support/api.php and let the server handle delivering content from protected_html. Here are the expanded rules for Nginx that license-server-demo.cubiclesoft.com uses:

server {
	listen 80;
	listen [::]:80;
	listen 443 ssl;
	listen [::]:443 ssl;
	server_name license-server-demo.cubiclesoft.com;
	root /var/www/license-server-demo.cubiclesoft.com/public_html;

	ssl_certificate	      /etc/letsencrypt/live/license-server-demo.cubiclesoft.com/fullchain.pem;
	ssl_certificate_key   /etc/letsencrypt/live/license-server-demo.cubiclesoft.com/privkey.pem;

	ssl_stapling on;
	ssl_stapling_verify on;

	location = /favicon.ico {
		log_not_found off;
		access_log off;
	}

	location = /robots.txt {
		allow all;
		log_not_found off;
		access_log off;
	}

	location ~ /\. {
		deny all;
		access_log off;
		log_not_found off;
	}

	location ^~ /.well-known/ {
		allow all;
	}


	# Map product support center API paths.
	location /product-support/ {
		try_files $uri $uri/ /product-support/api.php$is_args$args;
	}

	# Internal redirect to download files.
	location /protected/ {
		internal;
		alias /var/www/license-server-demo.cubiclesoft.com/protected_html/;
	}

	# Map 404 errors to 404.php.
	error_page 404 /404.php;

	location / {
		try_files $uri $uri/ =404;
	}


	# Pass .php files onto a php-fpm/php-fcgi server.
	location ~ \.php$ {
		try_files $uri =404;

		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		include fastcgi_params;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		fastcgi_pass php;
	}
}

Similar configurations can be set up for Apache and other web servers (e.g IIS).

Finally, create a downloads directory structure similar to:

/var/www/yourwebsite.com/protected_html/downloads/v1/

Once ready, upload your binaries and an info.json file containing information about the binaries. The Demo App has a tool in proc/publish.php that generates an appropriate JSON file for PHP App Server based applications.

Note that this is just one possible implementation of an integration between a purchasing system and software licensing management. The aim of this project is to be as simple as possible so that the software can be readily customized while also supporting the most important aspects of the purchasing lifecycle that both users and accountants expect. As a software developer, you probably just want to get back to working on your software product.

More Information

About

A complete Stripe + PHP License Server integration + product support center + demo app ready to adjust and deploy. Get back to writing software in minutes.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages