A utility for handling batch payout of Tapfiliate affiliates via PayPal.
Slapfiliate is a lightweight application designed to handle Tapfiliate payouts via PayPal. To keep the footprint small, it was built without scheduling capabilities and is meant to be run via cronjob or task scheduler.
Running the application will:
Slapfiliate is paranoid and will fail as early as possible (prior to posting
batch payments) instead of half-completing jobs. If the environment is not set
to production (NODE_ENV=production
), slapfiliate will inject sandbox accounts
to prevent actual payouts from being created in PayPal (though, these balances
will still be posted to Tapfiliate). With no NODE_ENV
set, slapfiliate will
default to development
.
sudo apt install nodejs
on Debian-based systems
(alternatively, check out https://nodejs.org/en/download/ for other
installation options).cd /opt/ && git clone https://github.com/iangoodnight/slapfiliate.git
curl -L https://github.com/iangoodnight/slapfiliate/archive/master.zip > \
slapfiliate.tar.gz && tar -zxvf slapfiliate.tar.gz
cd slapfiliate/ && npm install
for the entire
package, or with cd slapfiliate/ && npm install --production
to install the
package without development dependencies..env.example
and filling in the missing values..env.example
with mv .env.example .env
.npm test
.npm start
..env
file.sudo chmod +x /opt/slapfiliate/index.js
crontab -e
m h dom mon dow command
referring to minute
,
hour
, day of month
, month
, and day of week
respectively with *
actiing as a wildcard for ‘any’. Occasionally, the relative paths called
from node programs don’t play nice with cronjobs, so we are going to start
our 0 5 * * 1 cd /opt/slapfiliate/ && NODE_ENV=production ./index.js
In the example above, we are setting the NODE_ENV
directly as part of the
command itself. The NODE_ENV
can be set throught the .env
file as well, but
in any cases where it is not set, slapfiliate will default to development
.
Especially in testing, it is best practice to leave this environmental variable
set to development
and to explicitly override it when calling the script.
This helps to keep erroneous payments from going out during setup or
troubleshooting. By default, the output from cronjobs goes to /var/mail/
, but
you can override this by redirecting the output as part of the command. So the
crontab entry:
0 5 * * 1 cd /opt/slapfiliate/ && NODE_ENV=production ./index.js > ./run.log
Runs the program in the production
environment, and saves the output from that
last job to the file /opt/slapfiliate/run.log
for review.