.env
file
payment_bp.py
and take a look at the “/stripe/webhook” route:
.env
. This ensures, that only Stripe can send to this endpoint
Go to the webhook section, add a new webhook with the events payment_intent.payment_failed
, payment_intent.succeeded
, and checkout.session.completed
.
Then copy the webhook key as “STRIPE_ENDPOINT_SECRET” to .env
.
set_user_package
function (or refunding if it fails)stripe_packages
array and map the items to their “package_ids”. Create two (or how many you need)
of those products and add them to the .env
file.
bash local.sh
and not while inside Docker (see structure).
Later once we have deployed to a domain, you can provide the URL to your webhook inside
the Stripe interface.
When an event occurs, Stripe will automatically send a request there, without you needing to use the Stripe CLI.
There you will have the option to receive only the events you need, these are:
checkout.session.completed
to see when the user filled out the checkout frompayment_intent.succeeded
to see when the payment has actually gone throughpayment_intent.failed
if the payment failedsend_email
functions to notify the user about his payments going through or being
cancelled. Read the next chapter on emails to see how we accomplish this