Pay per content in ghost blog with IOTA
Test it here: blog.f-node.de
Watch it here: https://www.youtube.com/watch?v=3XG2W9J3b1A
Or use the service of https://pay-per-content.com
pip install -r requirements.txt
If python does not find the iota client install it from the wheel file
pip install iota_client_python-0.2.0_alpha.3-cp36-abi3-linux_x86_64.whl
Copy the .env
file
cp example.env .env
Alter the following variables in the .env
file:
-
URL
Default Value:http://localhost:2368
. Set to the url of the ghost blog which shall be fetched. -
GHOST_ADMIN_KEY
Default Value: null. Set to the admin key of a custom integration. Can be generated in the admin dashboard (Custom Integration) -
DEFAULT_IOTA_ADDRESS
Default Value:NO ADDRESS GIVEN
. Set to the IOTA Address which is owned by the blog. The application will listen there for incoming payments. -
NODE_URL
Default Value:https://api.hornet-1.testnet.chrysalis2.com
. Set to the url of your prefered node.
⚠️ This is the DEV-Net. If you want to use the mainnet you should use mainnet nodes such ashttps://chrysalis-nodes.iota.org
python app.py
This will serve the app on port 5000.
Make sure that the .env file exists
Build the image
docker build --tag ghost-iota-pay .
Run the image as container
docker run -it -p 5000:5000 -v /$(pwd)/data:/app/data --env-file .env ghost-iota-pay
Make sure that the .env file exists
Run image from repository
docker run -it -p 5000:5000 -v /$(pwd)/data:/app/data --env-file .env fnode/ghost-iota-pay
Make sure that the .env file exists
Run image from repository
docker-compose up
This will serve the app on port 5000.
When offering payed articles on your ghost blog just add a link on the subscribtion form which points to https://your-ghost-iota-pay-domain.com/{{slug}}
where slug is the slug of the requested article.
After the payment the article is fetched through the admin API and served to the user.
Put the following code into the post.hbs
of your ghost theme and replace {{ghost-iota-pay-url}}
with the url of your ghost-iota-pay gateway:
Example file ghost-integration/post.hbs
You can set AUTHOR_ADDRESSES=true
in your .env
file to allow authors to get paid individually.
If so, the authors can paste in their current IOTA address in the location
field in their ghost admin panel.
When an article is requested, the ghost API is fetched to get the latest address. If there is none, there is a fallback to the last address used or if this is not the case, the default address specified in the .env
file is used.
Improvement
As an IOTA address is quite ugly in the location field of the author, you can modify you theme in the author.hbs
like so, using IOTA Buttons:
You can set ADMIN_PANEL=true
in your .env
file to enable the admin panel on the /admin
path.
The admin panel is secured using basic authentication which credentials are specified in the .env
file as well.
I develop this gateway in my free time. If you want to support me or if my work helps you, kindly consider a small donation :)