Sebastian Sanchez Bernal is Code
Welcome to "Working with Stripe in Django"! This course will guide you through the process of integrating Stripe, a powerful online payment platform, into your Django application. We will cover everything from setting up Stripe in Django, to creating checkout sessions, and handling successful and cancelled payments.
We will also delve into the advanced topic of handling Stripe webhooks. These are essential for responding to events in the Stripe system, such as successful payments or subscription changes.
One key aspect we will explore is the subscription model. This involves recurring billing, which is a crucial feature for many online businesses. To give you a better understanding, an example of a subscription model will be provided as an image after this introduction.
By the end of this course, you will have a solid understanding of how to implement Stripe in your Django projects, enabling you to handle online payments with ease and efficiency.

First, import the Stripe module into your Django project. Then, create a Django setting that will store your Stripe public and secret keys. You can retrieve these keys from your Stripe dashboard.
STRIPE_PUBLISHABLE_KEY = 'your-publishable-key'
STRIPE_SECRET_KEY = 'your-secret-key'
This code block imports necessary libraries and modules for the application. Here's a breakdown:
import stripe - Imports the Stripe library, allowing the application to use Stripe's features.
from django.conf import settings - Imports Django's settings module, allowing the application to access and use Django's settings.
from django.contrib.auth.decorators import login_required - Imports the login_required decorator from Django's authentication system. This decorator is used to ensure that only logged-in users can access certain views.
from django.contrib.auth.models import User - Imports Django's built-in User model. This model is used to manage users in the application.
from django.http.response import JsonResponse, HttpResponse - Imports Django's JsonResponse and HttpResponse. These are used to return HTTP responses from views.