A proof of concept paywall mechanism using the microframework Flask and the online payment platform Mollie.
- Flask
- requests
- redis
- mollie-api-python
virtualenv VENV
. ./VENV/bin/activate
git clone https://github.com/wyldebeast-wunderliebe/w20e.paywall.git
cd w20.paywall
pip install zc.buildout
buildout -v
Use settings_overides.py for environment specific configuration adjustments like MOLLIE_API_KEY, REDIS_HOST and CSRF_SECRET_KEY.
touch src/instance/settings_overrides.py
export FLASK_APP=src/w20e/paywall/app.py
./bin/flask run
Since Mollie needs to be able to reach your server (webhook_verification), you might consider using ngrok or serveo to create a secure tunnel to your localhost.
Serveo example: ssh -R 80:localhost:5000 serveo.net
The paywall.wsgi script gets created by buildout. Below is a mod_wsgi snippet to get things going on Apache.
WSGIDaemonProcess paywall user=app-paywall-prd group=app-paywall-prd threads=5
WSGIScriptAlias / /opt/APPS/paywall/prd/w20e.paywall/parts/wsgiscript/paywall.wsgi
<Directory /opt/APPS/paywall/prd/w20e.paywall>
WSGIProcessGroup paywall
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
For starters, you can navigate the following routes.
- [host]/manage_vouchers
- Needs to be restricted in a production environment. Gives an overview of all active vouchers, both valid and not.
- [host]/test_voucher
- A verify-buy-redirect chain, roundtripping the entire paywall mechanism.
- [host]/new_voucher
- Buy a voucher using a predefined set of voucher types.