A low-configuration service for sending notifications andreceipts based on Stripe webhooks.
Project description
stripe-hooks
This is a Python web application to receive webhooks from Stripe and send emails accordingly.
This is a fork of Jack Pearkes original work: stripe-hooks.
There are two types of emails:
- Notifications, sent to administrators
- Receipts, sent to customers
Use cases:
- Sending notifications about important Stripe events, such as failed charges or new customers, to administrators
- Sending receipts to user after they have been charged
It supports all Stripe events.
The email content included by default is versatile English. Any of it can be modified to fit your business or use case. It's easy to deploy and you shouldn't need to touch Python to configure it.
Installation
$ python3 setup.py install
Configuration
All of the configuration is done in JSON.
Create a .json
file following configuration_template.json
and drop it in the command line:
$ stripe-hooks configuration.json
More details below:
Emails type
All receipts and notifications are off by default with a blank configuration.json
.
To activate a notification or receipt, simply create a new key, named by the event type (the list can be found here) and formatted like this:
{
...
"email": {
"charge.failed": {
"active": true,
"subject": "Oh nos! A Charge Has Failed!"
}
}
...
}
subject
is optional. By default, the email subject will be the type,
periods replacing spaces and titlecased, prefixed with your
business name (if it exists) like so: charge.failed -> [Acme Inc.] Charge Failed
.
Everything falls back to safe, generic defaults, like not showing a business name if it doesn't exist.
Emails type configuration could look something like this:
{
...
"email": {
"business": {
"name": "Acme, Inc.",
"signoff": "The Acme Team",
"email": "Acme Support Team <support@example.com>"
},
"notifications": {
"balance.available": {
"active": true,
"subject": "Dat chedda is available..."
},
"charge.succeeded": {
"active": true
},
"charge.failed": {
"active": true
},
"charge.refunded": {
"active": true
}
},
"receipts": {
"invoice.created": {
"active": true,
"subject": "New Invoice"
}
}
}
...
}
Emails Content
You need to provide a path to your emails templates:
{
...
"email": {
"templates_path": "stripe-hooks-emails",
...
}
...
}
You can fork that repository and you will have a good start.
stripe
You need to configure a stripe webhook in stripe GUI stripe webhooks.
The service default port is 5000
and route url is /webhook
.
When you have your endpoint secret just drop it in the configuration file:
{
...
"stripe": {
"endpoint_secret": "whsec_..."
},
...
}
The endpoint secret will be use to authenticate stripe POST
requests following stripe documentation.
Email Provider
SMTP is use as the default interface with your email provider.
Add this in your configuration file:
{
...
"smtp": {
"url": "localhost:25"
},
...
}
Mailgun is a good provider. Stripe team use it in there own documentation.
Jack Pearkes original work uses Amazon SES.
Revert commit refactor(mail): use a smtp server instead of aws ses
if you want to use Amazon SES.
Test
WIP
Contributing
Just drop a PR following git karma style.
When unit tests will be up-to-date, they will need to pass.
Project isn't compliant with Flake8 lint for now, so it's not mandatory, but it could be cool.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file stripe-hooks-0.1.tar.gz
.
File metadata
- Download URL: stripe-hooks-0.1.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6a2d1b99f6c460d478bfa2e043ca5a9b8c4058f446135ea514878fe454bfafe |
|
MD5 | 037860c77307522042498fed0a565414 |
|
BLAKE2b-256 | 51f7b579b7ed15a5c23cb0ce847de3af74ccc551e92d015c95177b3feca0c6b1 |
File details
Details for the file stripe_hooks-0.1-py3-none-any.whl
.
File metadata
- Download URL: stripe_hooks-0.1-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b25404a3fce26c2ba3f6e08a95de825718529cc5ca48f1068cc132a26af97293 |
|
MD5 | 052b6bac7a5bebbd66b27d3a7e3cbc2d |
|
BLAKE2b-256 | b1b54eac25c3a1382c0cb646e7fabfad06499f3fa0b12d5f0ef9540ee337288c |