Skip to main content

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:

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.

Metadata

Release files for stripe-hooks 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stripe-hooks 0.1
File Size Uploaded
stripe-hooks-0.1.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stripe-hooks 0.1
File Interpreter ABI Platform
stripe_hooks-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.1 kB

Release files / stripe-hooks-0.1.tar.gz

Download URL stripe-hooks-0.1.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f6a2d1b99f6c460d478bfa2e043ca5a9b8c4058f446135ea514878fe454bfafe
BLAKE2b-256 checksum
How to use checksums
51f7b579b7ed15a5c23cb0ce847de3af74ccc551e92d015c95177b3feca0c6b1
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / stripe_hooks-0.1-py3-none-any.whl

Download URL stripe_hooks-0.1-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b25404a3fce26c2ba3f6e08a95de825718529cc5ca48f1068cc132a26af97293
BLAKE2b-256 checksum
How to use checksums
b1b54eac25c3a1382c0cb646e7fabfad06499f3fa0b12d5f0ef9540ee337288c
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page