Skip to content

jmarhee/stripe-invoice-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stripe Invoice Bot

A Python-powered Discord bot to create customers and invoices with Stripe.

arthur from 2001 series "the tick"

Setup

This requires, both, a Stripe API token and a Discord Bot Token.

These will need to be set to their respective values:

STRIPE_API_TOKEN DISCORD_TOKEN

and then the approved users in your server who can use this bot:

DISCORD_APPROVED_BOT="user1#id,user2#id"

These are handled as environmental variables in the application, not from a configuration, so if you plan to use the Docker image, the command will be as follows:

docker build -t stripe-invoice-bot . ; \
docker run -d --name stripe-invoice-bot -e STRIPE_API_TOKEN=$STRIPE_API_TOKEN \
-e DISCORD_TOKEN=$DISCORD_TOKEN \
-e DISCORD_APPROVED_BOT=$DISCORD_APPROVED_BOT \
stripe-invoice-bot

Running the Bot

You can, either, build the Dockerfile (using docker build -t stripe-invoice-bot .) or install the package using pip:

python3 -m pip install git+https://git-central.openfunction.co/jmarhee/stripe-invoice-bot.git@main

then running stripe-invoice-bot to start the bot process. It is recommended that this be managed by something like supervisord or another process manager.

If you are a supervisord user, a configuration like this should suffice:

[program:stripe-invoice-bot]
command=${YOUR_PYTHON_PKGS_PATH}/bin/stripe-invoice-bot 
autostart=true
autorestart=true
stderr_logfile=/var/log/stripe-invoice-bot.err.log
stdout_logfile=/var/log/stripe-invoice-bot.out.log
environment=DISCORD_TOKEN="",DISCORD_APPROVED_BOT="",STRIPE_API_KEY=""

then reread and update supervisor.

Discord Commands

You can list invoices, items, or customers using:

list ${resource}

and delete any resource using:

delete ${resource} ${resource_id}

which you can find the ID for using the above list command format.

To create a customer record, open your Direct Message to Stripe Invoicer Bot, and send:

new customer [email protected] phonenumber FirstName LastName OtherData

You will receive a response like:

Customer name ([email protected]) created with id cus_ID

where cus_ID will be their customer ID, which you'll need to generate invoices.

You can add items to to be invoiced by running:

new item customer_ID amount description

and add as many as you'd like before proceeding to generate a draft invoice.

To generate a draft invoice, you can send the bot:

new invoice cus_ID

when the invoice is ready to be sent, you can use the returned Invoice ID (in_XXXXX) to tell the bot to send to the email on file:

send invoice in_XXXX