Stripe Subscription Creation Notifier API Webhook

import os
from fastapi import FastAPI
from starlette.responses import JSONResponse

app = FastAPI()'/webhook')
async def respond_to_webhook(request):
    data = await request.json()
    #stripe subscription created event
    if data['type'] == 'customer.subscription.created':
        print("The secret is wrong")
    return JSONResponse(status_code=200)

if __name__ == "__main__":
    import uvicorn, host="", port=8080)

About this template

This app will react to a Stripe API webhook and print the received data. It's a good starting point to hook up additional functionality to then create some event in a database or create a notification or for example enable access for a customer. Stripe Subscription Creation Notifier API Webhook template will also print a message if the secret is wrong.

Introduction to the Stripe Subscription Creation Notifier API Webhook Template

Welcome to the Stripe Subscription Creation Notifier API Webhook Template! This template is designed to help you quickly set up a webhook listener for Stripe subscription creation events. When a new subscription is created in Stripe, this app will capture the event data and print it out, providing a solid foundation for you to add additional functionality, such as updating a database, sending notifications, or granting customer access.

Getting Started with the Template

To begin using this template, simply click on the "Start with this Template" button. This will initialize the template in the Lazy Builder interface, where you can customize it according to your needs.

Initial Setup

Before you can test the webhook, you'll need to set up your Stripe account to send webhook events to your Lazy app. Here's how to do it:

  • Log in to your Stripe dashboard.
  • Navigate to the Developers section and click on Webhooks.
  • Click on "Add endpoint" and enter the URL provided by Lazy for your app. This URL will be available after you deploy the app using the Test button.
  • Select the "customer.subscription.created" event from the list of events.
  • Click "Add endpoint" to save your new webhook.

Stripe will now send a webhook event to your Lazy app whenever a new subscription is created.

Test: Pressing the Test Button

Once you have set up the webhook in Stripe, return to the Lazy Builder interface and press the "Test" button. This will deploy your app and start the webhook listener. Lazy will provide you with a server link that you can use to interact with the API.

Using the App

With the app deployed and the webhook configured, Stripe will send subscription creation events to your app's endpoint. The app will print the event data, allowing you to verify that everything is working correctly. You can view the printed data in the Lazy CLI output.

Integrating the App

After confirming that the webhook is functioning as expected, you may want to integrate the app with other systems or services. Depending on your requirements, you might:

  • Update a customer database with the new subscription information.
  • Send a notification to an administrator or the customer.
  • Trigger access permissions for the new subscriber.

To achieve these integrations, you will need to modify the app's code to include the necessary logic and possibly interact with other APIs or databases. This will require additional coding and setup based on the specific services you are using.

Remember, the Lazy platform handles the deployment and environment configuration, so you can focus on building and integrating your app without worrying about the underlying infrastructure.

If you need further guidance on integrating with specific services or databases, refer to the documentation provided by those services or seek assistance from a developer with the appropriate expertise.

Good luck with your Stripe Subscription Creation Notifier API Webhook, and happy building on Lazy!

Last published
June 15, 2024

More templates like this

Stripe API Testing

This application utilizes Flask for the backend and JavaScript with Stripe API for the frontend. It allows users to test various Stripe functionalities such as adding a card to a customer, creating a charge, and retrieving customer details. The backend interacts with the Stripe API using the stripe library, while the frontend provides a simple form for users to input their Stripe API secret and an optional customer ID. Upon submitting the form, the frontend sends a POST request to the backend, which then executes the specified tests and returns the results to be displayed on the page. Made by BaranDev[]


Connect Payout with Stripe API

This app uses the Stripe API to create payouts for Connect Stripe Accouts and allows users to modify the payout schedule. It includes a Flask web service with an endpoint for this purpose. The backend makes API calls to create a transfer of funds and update the payout schedule using the Stripe API and the submitted form data.


Create Product using Stripe API

This app uses the Stripe API to create a product with it's price. It includes a Flask web service with an endpoint for this purpose. The backend makes API calls to create a product and its price object using the Stripe API and the submitted form data.

Stripe Subscription Creation Notifier API Webhook