Drf-stripe-subscription - An out-of-box Django REST framework solution for payment and subscription management using Stripe

Overview

drf-stripe-subscription

An out-of-box Django REST framework solution for payment and subscription management using Stripe. The goal of this package is to utilize Stripe provided UI and features as much as possible to manage subscription product models. This package helps you make use of Stripe's hosted UI for customer checkout, billing management, as well as for admin to manage product, pricing, and customer subscriptions.

  • Django data models representing Stripe data objects
  • Supports Stripe Webhook for managing changes with your products, prices, and customer subscriptions
  • Django management commands for synchronizing data with Stripe
  • Django REST API endpoints supporting Stripe Checkout Session and Customer Portal

Installation & Setup

pip install drf-stripe-subscription

Include the following drf_stripe settings in Django project settings.py:

DRF_STRIPE = {
    "STRIPE_API_SECRET": "my_stripe_api_key",
    "STRIPE_WEBHOOK_SECRET": "my_stripe_webhook_key",
    "FRONT_END_BASE_URL": "http://localhost:3000",
}

Include drf_stripe in Django INSTALLED_APPS setting:

INSTALLED_APPS = (
    ...,
    "rest_framework",
    "drf_stripe",
    ...
)

Include drf_stripe.url routing in Django project's urls.py, ie:

from django.urls import include, path

urlpatterns = [
    path("stripe/", include("drf_stripe.urls")),
    ...
]

Run migrations command:

python manage.py migrate

Pull Product and Price data from Stripe into Django database using the following command:

python manage.py update_stripe_products

Finally, start Django development server

python manage.py runserver

as well as Stripe CLI to forward Stripe webhook requests:

stripe listen --forward-to 127.0.0.1:8000/stripe/webhook/

Usage

The following REST API endpoints are provided:

List product prices to subscribe

my-site.com/stripe/subscribable-product/

This endpoint is available to both anonymous users and authenticated users. Anonymous users will see a list of all currently available products. For authenticated users, this will be a list of currently available products without any products that the user has already subscribed currently.

List user's current subscriptions

my-site.com/stripe/my-subscription/

This endpoint provides a list of active subscriptions for the current user.

List user's current subscription items

my-site.com/stripe/my-subscription-items/

This endpoint provides a list of active subscription items for the current user.

Create a checkout session using Stripe hosted Checkout page

my-site.com/stripe/checkout/

This endpoint creates Stripe Checkout Session

Make request with the follow request data:

{"price_id": "price_stripe_price_id_to_be_checked_out"}

The response will contain a session_id which can be used by Stripe:

{"session_id": "stripe_checkout_session_id"}

This session_id is a unique identifier for a Stripe Checkout Session, and can be used by redirectToCheckout in Stripe.js. You can implement this in your frontend application to redirect to a Stripe hosted Checkout page after fetching the session id.

By default, the Stripe Checkout page will redirect the user back to your application at either mysite.com/payment/session={{CHECKOUT_SESSION_ID}} if the checkout is successful, or mysite.com/manage-subscription/ if checkout is cancelled.

Stripe Customer Portal

mysite.com/stripe/customer-portal

This will create a Stripe billing portal session, and return the url to that session:

{"url": "url_to_Stripe_billing_portal_session"

This is a link that you can use in your frontend application to redirect a user to Stripe Customer Portal and back to your application. By default, Stripe Customer Portal will redirect the user back to your frontend application at my-site.com/manage-subscription/

Stripe Webhook

mysite.com/stripe/webhook/

This the REST API endpoint Stripe servers can call to update your Django backend application. The following Stripe webhook events are currently supported:

product.created
product.updated
product.deleted
price.created
price.updated
price.deleted
customer.subscription.created
customer.subscription.updated
customer.subscription.deleted

With these Stripe events, you can:

  • Manage your products and pricing model from Stripe Portal, and rely on webhook to update your Django application automatically.
  • Manage your customer subscriptions from Stripe Portal, and rely on webhook to update your Django application automatically.

StripeUser

The StripeUser model comes with a few attributs that allow accessing information about the user quickly:

from drf_stripe.models import StripeUser

stripe_user = StripeUser.objects.get(user_id=django_user_id)

print(stripe_user.subscription_items)
print(stripe_user.current_subscription_items)
print(stripe_user.subscribed_products)
print(stripe_user.subscribed_features)

Product features

Stripe does not come with a way of managing features specific to your products and application. drf-stripe-subscription provides additional tables to manage features associated with each Stripe Product:

  • Feature: this table contains feature_id and a description for the feature.
  • ProductFeature: this table keeps track of the many-to-many relation between Product and Feature.

To assign features to a product, go to Stripe Dashboard -> Products -> Add Product/Edit Product: Under Product information, click on Additional options, add metadata.

Add an entry called features, the value of the entry should be a space-delimited string describing a set of features, ie: FEATURE_A FEATURE_B FEATURE_C.

If you have Stripe CLI webhook running, you should see that your Django server has automatically received product information update, and created/updated the associated ProductFeature and Feature instances. Otherwise, you can also run the python manage.py update_stripe_products command again to synchronize all of your product data. The description attribute of each Feature instance will default to the same value as feature_id, you should update the description yourself if needed.

Comments
  • Invalid field name(s) for model CustomUser: 'username'  while trying to pull new  data from stripe

    Invalid field name(s) for model CustomUser: 'username' while trying to pull new data from stripe

    Invalid field name(s) for model CustomUser: 'username'

    python manage.py update_stripe_customers

    Updated Stripe Customer cus_LSr9w7FB2J7r9U Updated Stripe Customer cus_LSN6YXRJULxYv2 Updated Stripe Customer cus_LSLsozLd7PpiAJ Updated Stripe Customer cus_LSLoxRY2x62iqT Updated Stripe Customer cus_LSBn1ocYarYb8I Updated Stripe Customer cus_LSBMjVw45wQLc9 Updated Stripe Customer cus_LS8UsIDLMRgQL9 Traceback (most recent call last): File "C:\backend\env\lib\site-packages\django\db\models\query.py", line 581, in get_or_create return self.get(**kwargs), False File "C:\backend\env\lib\site-packages\django\db\models\query.py", line 435, in get raise self.model.DoesNotExist( accounts.models.CustomUser.DoesNotExist: CustomUser matching query does not exist.

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "C:\backend\mrbackend\manage.py", line 22, in main() File "C:\backend\mrbackend\manage.py", line 18, in main execute_from_command_line(sys.argv) File "C:\backend\env\lib\site-packages\django\core\management_init_.py", line 419, in execute_from_command_line utility.execute() File "C:\backend\env\lib\site-packages\django\core\management_init_.py", line 413, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\backend\env\lib\site-packages\django\core\management\base.py", line 354, in run_from_argv self.execute(*args, **cmd_options) File "C:\backend\env\lib\site-packages\django\core\management\base.py", line 398, in execute output = self.handle(*args, **options) File "C:\backend\env\lib\site-packages\drf_stripe\management\commands\update_stripe_customers.py", line 14, in handle stripe_api_update_customers(limit=kwargs.get('limit'), starting_after=kwargs.get('starting_after')) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\contextlib.py", line 79, in inner return func(*args, **kwds) File "C:\backend\env\lib\site-packages\drf_stripe\stripe_api\customers.py", line 159, in stripe_api_update_customers user, user_created = get_user_model().objects.get_or_create( File "C:\backend\env\lib\site-packages\django\db\models\manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "C:\backend\env\lib\site-packages\django\db\models\query.py", line 583, in get_or_create params = self._extract_model_params(defaults, **kwargs) File "C:\backend\env\lib\site-packages\django\db\models\query.py", line 634, in _extract_model_params raise exceptions.FieldError( django.core.exceptions.FieldError: Invalid field name(s) for model CustomUser: 'username'.

    my customuser model:

    class CustomUser(AbstractUser): username = None email = models.EmailField(_('email address'), unique=True) bio = models.TextField() gender = models.CharField( max_length=140, null=True, choices=( ('Male', 'Male'), ('Female', 'Female'), ('Other', 'Other') ) ) birth_date = models.DateField(null=True, blank=True) id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)

    Please help me resolve the issue.ASAP

    opened by anirbanchakraborty123 6
  • Product Limit 100

    Product Limit 100

    I'm considering using your library for Stripe payments but I noticed that when you pull products, you limit them to 100:

    https://github.com/oscarychen/drf-stripe-subscription/blob/c352ec59944651a80a9ccbb7b26ea5cbc80b1e13/drf_stripe/stripe_api/products.py#L28

    What is the reason you have hard coded this limit? How do I pull more than 100 products without modifying your code?

    Thanks!

    opened by pkrumins 4
  • react native stripe element implementation?

    react native stripe element implementation?

    Hey there, I've been trying to following this guide i have also created the custom Checkout, i am getting data null in payment_intent and setup_intent is there any option i am missing?

    Custom Serializer

    class CustomCheckoutRequestSerializer(CheckoutRequestSerializer):
        """Handle creation of a custom checkout session where parameters are customized."""
    
        def validate(self, attrs):
            stripe_user = get_or_create_stripe_user(user_id=self.context['request'].user.id)
            try:
                checkout_session = stripe_api_create_checkout_session(
                    customer_id=stripe_user.customer_id,
                    price_id=attrs['price_id'],
                    trial_end='auto' if stripe_user.subscription_items.count() == 0 else None,
                    payment_method_types=["card"],
                    checkout_mode="subscription",
                )
                print(checkout_session)
                attrs['session_id'] = checkout_session['id']
                attrs['customer_id'] = checkout_session['customer']
                attrs['payment_intent'] = checkout_session['payment_intent']
                attrs['url'] = checkout_session['url']
            except StripeError as e:
                raise ValidationError(e.error)
            return attrs
    

    SETTING

    DRF_STRIPE = {
        "STRIPE_API_SECRET": env('STRIPE_API', default=''),
        "STRIPE_WEBHOOK_SECRET": "*",
        "NEW_USER_FREE_TRIAL_DAYS": 7,
    }
    
    opened by AxanIqbal 2
  • Attach coupon to customer

    Attach coupon to customer

    A callback to attach a coupon to a customer would be nice on:

    1. Input passed on first creation of customer
    2. Function on stripe_user that can be called manually

    https://stripe.com/docs/billing/subscriptions/coupons?dashboard-or-api=api https://stripe.com/docs/api/customers/update

    opened by joshuakoh1 1
  • Validation error on StripeSubscriptionEvent

    Validation error on StripeSubscriptionEvent

    1 validation error for StripeEvent event -> StripeSubscriptionEvent -> data -> object -> pending_update str type expected (type=type_error.str)

    opened by pvfarooq 1
  • IndexError: tuple index out of range with stripe_webhooks

    IndexError: tuple index out of range with stripe_webhooks

    When I create a user on the Django admin panel the following way, I get the following error

    class CustomUser(AbstractUser):
        username = None
        email = models.EmailField(_('email address'), unique=True)
        name = models.CharField(verbose_name=_("first name"), max_length=50)
        stripe_customer_id = models.CharField(max_length=120)
    
        USERNAME_FIELD = 'email'
        REQUIRED_FIELDS = ['name']
    
        objects = CustomUserManager()
    
        def __str__(self):
            return self.name
    
    
    @receiver(post_save, sender=CustomUser)
    def _on_update_user(sender, instance, created, **extra_fields):
        print(f"HERE {instance.is_superuser}")
    
        if created and not instance.is_superuser:
    
            # Create Stripe user
            customer = stripe.Customer.create(
                email=instance.email,
                name=instance.name,
            )
            
            User = get_user_model()
    
            # Create profile
            user = User.objects.get(id=instance.id)
            user.email = instance.email
            user.name=instance.name
            user.stripe_customer_id=customer.id
    
            user.save()
    

    The error occurs when the following is running

    stripe listen --forward-to 127.0.0.1:8000/stripe/webhook/

    2022-06-17 13:07:51   --> customer.created [evt_1LBd1nCiNWlPNf1Rnx6rsetb]
    2022-06-17 13:07:51  <--  [500] POST http://127.0.0.1:8000/stripe/webhook/ [evt_1LBd1nCiNWlPNf1Rnx6rsetb]
    

    Here is the error I get

    Traceback (most recent call last):
      File "/Users/magedhelmy/Desktop/VS_Code/licensingDemo4/.venv/lib/python3.10/site-packages/drf_stripe/stripe_webhooks/handler.py", line 53, in handle_webhook_event
        e = StripeEvent(event=event)
      File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
    pydantic.error_wrappers.ValidationError: 1 validation error for StripeEvent
    event
      No match for discriminator 'type' and value 'customer.created' (allowed values: <EventType.CUSTOMER_SUBSCRIPTION_DELETED: 'customer.subscription.deleted'>, <EventType.CUSTOMER_SUBSCRIPTION_UPDATED: 'customer.subscription.updated'>, <EventType.CUSTOMER_SUBSCRIPTION_CREATED: 'customer.subscription.created'>, <EventType.INVOICE_PAID: 'invoice.paid'>, <EventType.INVOICE_CREATED: 'invoice.created'>, <EventType.INVOICE_PAYMENT_FAILED: 'invoice.payment_failed'>, <EventType.PRODUCT_UPDATED: 'product.updated'>, <EventType.PRODUCT_CREATED: 'product.created'>, <EventType.PRODUCT_DELETED: 'product.deleted'>, <EventType.PRICE_CREATED: 'price.created'>, <EventType.PRICE_UPDATED: 'price.updated'>, <EventType.PRICE_DELETED: 'price.deleted'>, <class 'str'>) (type=value_error.discriminated_union.invalid_discriminator; discriminator_key=type; discriminator_value=customer.created; allowed_values=<EventType.CUSTOMER_SUBSCRIPTION_DELETED: 'customer.subscription.deleted'>, <EventType.CUSTOMER_SUBSCRIPTION_UPDATED: 'customer.subscription.updated'>, <EventType.CUSTOMER_SUBSCRIPTION_CREATED: 'customer.subscription.created'>, <EventType.INVOICE_PAID: 'invoice.paid'>, <EventType.INVOICE_CREATED: 'invoice.created'>, <EventType.INVOICE_PAYMENT_FAILED: 'invoice.payment_failed'>, <EventType.PRODUCT_UPDATED: 'product.updated'>, <EventType.PRODUCT_CREATED: 'product.created'>, <EventType.PRODUCT_DELETED: 'product.deleted'>, <EventType.PRICE_CREATED: 'price.created'>, <EventType.PRICE_UPDATED: 'price.updated'>, <EventType.PRICE_DELETED: 'price.deleted'>, <class 'str'>)
    
    
    During the handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/Users/magedhelmy/Desktop/VS_Code/licensingDemo4/.venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
        response = get_response(request)
      File "/Users/magedhelmy/Desktop/VS_Code/licensingDemo4/.venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 181, in _get_response
        response = wrapped_callback(request, *callback_args, **callback_kwargs)
      File "/Users/magedhelmy/Desktop/VS_Code/licensingDemo4/.venv/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
        return view_func(*args, **kwargs)
      File "/Users/magedhelmy/Desktop/VS_Code/licensingDemo4/.venv/lib/python3.10/site-packages/django/views/generic/base.py", line 70, in view
        return self.dispatch(request, *args, **kwargs)
      File "/Users/magedhelmy/Desktop/VS_Code/licensingDemo4/.venv/lib/python3.10/site-packages/rest_framework/views.py", line 509, in dispatch
        response = self.handle_exception(exc)
      File "/Users/magedhelmy/Desktop/VS_Code/licensingDemo4/.venv/lib/python3.10/site-packages/rest_framework/views.py", line 469, in handle_exception
        self.raise_uncaught_exception(exc)
      File "/Users/magedhelmy/Desktop/VS_Code/licensingDemo4/.venv/lib/python3.10/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
        raise exc
      File "/Users/magedhelmy/Desktop/VS_Code/licensingDemo4/.venv/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
        response = handler(request, *args, **kwargs)
      File "/Users/magedhelmy/Desktop/VS_Code/licensingDemo4/.venv/lib/python3.10/site-packages/drf_stripe/views.py", line 69, in post
        handle_stripe_webhook_request(request)
      File "/Users/magedhelmy/Desktop/VS_Code/licensingDemo4/.venv/lib/python3.10/site-packages/drf_stripe/stripe_webhooks/handler.py", line 15, in handle_stripe_webhook_request
        handle_webhook_event(event)
      File "/Users/magedhelmy/Desktop/VS_Code/licensingDemo4/.venv/lib/python3.10/site-packages/drf_stripe/stripe_webhooks/handler.py", line 55, in handle_webhook_event
        _handle_event_type_validation_error(err)
      File "/Users/magedhelmy/Desktop/VS_Code/licensingDemo4/.venv/lib/python3.10/site-packages/drf_stripe/stripe_webhooks/handler.py", line 41, in _handle_event_type_validation_error
        if error_loc[0] == 'event' and error_loc[1] == 'type':
    IndexError: tuple index out of range
    
    

    I do not understand the error and I am not sure how to proceed from here.

    opened by magedhelmy1 1
  • Redirection in Custom CheckoutRequestSerializer

    Redirection in Custom CheckoutRequestSerializer

    can we have custom redirection option in the serializer the app to work with dynamic linking for mobile apps and website at same time ? or any way to do the platform checks and redirect according to the given platform

    opened by AxanIqbal 1
  • django.db.utils.IntegrityError: insert or update on table

    django.db.utils.IntegrityError: insert or update on table "drf_stripe_subscriptionitem" violates foreign key constraint "drf_stripe_subscript_price_id_56df13e9_fk_drf_strip"

    Caused by python manage.py update_stripe_subscriptions

    $ python manage.py update_stripe_subscriptions
    message='Request to Stripe api' method=get path=https://api.stripe.com/v1/subscriptions?limit=100
    message='Stripe API response' path=https://api.stripe.com/v1/subscriptions?limit=100 response_code=200
    Updated subscription sub_JqlXq6MuRv2zKF
    Updated sub item si_JqlXL5vg7czvwV
    ...
    [more lines like this]
    ...
    Created 34 new Subscriptions.
    Traceback (most recent call last):
      File "/home/vscode/.local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 267, in _commit
        return self.connection.commit()
    psycopg2.errors.ForeignKeyViolation: insert or update on table "drf_stripe_subscriptionitem" violates foreign key constraint "drf_stripe_subscript_price_id_56df13e9_fk_drf_strip"
    DETAIL:  Key (price_id)=(both_regular_monthly_EU) is not present in table "drf_stripe_price".
    
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/workspace/manage.py", line 10, in <module>
        execute_from_command_line(sys.argv)
      File "/home/vscode/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
        utility.execute()
      File "/home/vscode/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 440, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/home/vscode/.local/lib/python3.9/site-packages/django/core/management/base.py", line 414, in run_from_argv
        self.execute(*args, **cmd_options)
      File "/home/vscode/.local/lib/python3.9/site-packages/django/core/management/base.py", line 460, in execute
        output = self.handle(*args, **options)
      File "/home/vscode/.local/lib/python3.9/site-packages/drf_stripe/management/commands/update_stripe_subscriptions.py", line 14, in handle
        stripe_api_update_subscriptions(limit=kwargs.get('limit'), starting_after=kwargs.get('starting_after'))
      File "/usr/local/lib/python3.9/contextlib.py", line 79, in inner
        return func(*args, **kwds)
      File "/home/vscode/.local/lib/python3.9/site-packages/django/db/transaction.py", line 255, in __exit__
        connection.commit()
      File "/home/vscode/.local/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
        return func(*args, **kwargs)
      File "/home/vscode/.local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 291, in commit
        self._commit()
      File "/home/vscode/.local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 267, in _commit
        return self.connection.commit()
      File "/home/vscode/.local/lib/python3.9/site-packages/django/db/utils.py", line 91, in __exit__
        raise dj_exc_value.with_traceback(traceback) from exc_value
      File "/home/vscode/.local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 267, in _commit
        return self.connection.commit()
    django.db.utils.IntegrityError: insert or update on table "drf_stripe_subscriptionitem" violates foreign key constraint "drf_stripe_subscript_price_id_56df13e9_fk_drf_strip"
    DETAIL:  Key (price_id)=(both_regular_monthly_EU) is not present in table "drf_stripe_price".
    
    opened by janbaykara 1
  • Added support for customizing Stripe Checkout parameters

    Added support for customizing Stripe Checkout parameters

    This addresses issue #2.

    Some of the checkout parameters are specified in DRF_STRIPE settings:

    CHECKOUT_SUCCESS_URL_PATH: The checkout session success redirect url path. CHECKOUT_CANCEL_URL_PATH: The checkout session cancel redirect url path. PAYMENT_METHOD_TYPES: The default default payment method types , defaults to ["card"]. DEFAULT_CHECKOUT_MODE: The default checkout mode, defaults to "subscription".

    By default, you can create a checkout session by calling the default REST endpoint my-site.com/stripe/checkout/, this REST endpoint utilizes drf_stripe.serializers.CheckoutRequestSerializer to validate checkout parameters and create a Stripe Checkout Session. Only a price_id is needed, quantity defaults to 1.

    You can extend this serializer and customize Checkout behavior, such as specifying multiple line_items , payment_method_types, and checkout_mode.

    See README for more info.

    opened by oscarychen 1
  • current_subscription_items isn't efficient on DB queries

    current_subscription_items isn't efficient on DB queries

    Probably should rework the query.

    In [57]: len(connection.queries)
    Out[57]: 31
    
    In [58]: u.stripe_user.current_subscription_items
    Out[58]: {<SubscriptionItem: SubscriptionItem object>}
    
    In [59]: len(connection.queries)
    Out[59]: 39
    
    opened by joshuakoh1 1
  • Can't seem to pull price_id or product_id in my own serializer

    Can't seem to pull price_id or product_id in my own serializer

    Extremely confused by this

    from drf_stripe.models import Price
    class PriceSerializer(serializers.ModelSerializer):
        class Meta:
            model = Price
            fields = ["price_id", "price", "freq"]
    

    Throws an error in the serializer

    Got AttributeError when attempting to get a value for field `price_id` on serializer `PriceSerializer`.
    The serializer field might be named incorrectly and not match any attribute or key on the `Price` instance.
    Original exception text was: 'Price' object has no attribute 'price_id'.
    

    But when I go into the shell it works

    In [2]: models.Price.objects.all().first().price_id
    Out[2]: 'price_xxx'
    
    opened by joshuakoh1 1
Releases(1.1.11)
  • 1.1.11(Apr 18, 2022)

    Added support for working with custom Django User Model.

    The following DRF_STRIPE settings can be used to customize how Django creates User instance using Stripe Customer attributes (default values shown):

    DRF_STRIPE = {
        "DJANGO_USER_EMAIL_FIELD": "email",
        "USER_CREATE_DEFAULTS_ATTRIBUTE_MAP": {"username": "email"},
    }
    

    The DJANGO_USER_EMAIL_FIELD specifies name of the Django User attribute to be used to store Stripe Customer email. It will be used to look up existing Django User using Stripe Customer email.

    The USER_CREATE_DEFAULTS_ATTRIBUTE_MAP maps the name of Django User attribute to name of corresponding Stripe Customer attribute, and is used during the automated Django User instance creation.

    Source code(tar.gz)
    Source code(zip)
  • 1.1.8(Feb 13, 2022)

  • 1.1.7(Feb 9, 2022)

  • 1.1.6(Feb 8, 2022)

  • 1.1.5(Jan 16, 2022)

  • 1.1.3(Jan 16, 2022)

    • Added Django management commands to pull data from Stripe. Use python manage.py pull_stripe to fetch and update Products, Prices, Customers, and Subscription data.
    • Added more attributes to SubscriptionItems API to include attributes such as product name, price nickname.
    Source code(tar.gz)
    Source code(zip)
  • 1.1.1(Jan 14, 2022)

    Bug fix: Subscription event handler was not properly updating the SubscriptionItem table when a price plan is deleted from a Subscription.

    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Jan 14, 2022)

    The Subscription model now has a foreign key pointing to the StripeUser model instead of the Django User model. This reduces the coupling across the application.

    Migrating from older version: you will need to drop all drf-stripe tables and run Django migrate command again to recreate new ones.

    Added convenience methods to the StripUser model:

        @property
        def subscription_items(self):
            """Returns a set of SubscriptionItem instances associated with the StripeUser"""
    
        @property
        def current_subscription_items(self):
            """Returns a set of SubscriptionItem instances that grants current access."""
    
        @property
        def subscribed_products(self):
            """Returns a set of Product instances the StripeUser currently has"""
            return {item.price.product for item in self.current_subscription_items}
    
        @property
        def subscribed_features(self):
            """Returns a set of Feature instances the StripeUser has access to."""
            return set(chain.from_iterable(item.price.product.linked_features.all().prefetch_related("feature") for item in
                                           self.current_subscription_items))
    
    
    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Jan 13, 2022)

  • 1.0.0(Jan 13, 2022)

Owner
Oscar Y Chen
Software Developer
Oscar Y Chen
A reusable Django model field for storing ad-hoc JSON data

jsonfield jsonfield is a reusable model field that allows you to store validated JSON, automatically handling serialization to and from the database.

Ryan P Kilby 1.1k Jan 03, 2023
🌟 A social media made with Django and Python and Bulma. 🎉

Vitary A simple social media made with Django Installation 🛠️ Get the source code 💻 git clone https://github.com/foxy4096/Vitary.git Go the the dir

Aditya Priyadarshi 15 Aug 30, 2022
A clone of https://virgool.io written in django

Virgool clone A clone of virgool blog written in django Installation first rename the .env.sample to .env and fill it. with docker docker-compose up -

Danial Selmipoor 7 Dec 23, 2022
xsendfile etc wrapper

Django Sendfile This is a wrapper around web-server specific methods for sending files to web clients. This is useful when Django needs to check permi

John Montgomery 476 Dec 01, 2022
Django based webapp pulling in crypto news and price data via api

Deploy Django in Production FTA project implementing containerization of Django Web Framework into Docker to be placed into Azure Container Services a

0 Sep 21, 2022
A fresh approach to autocomplete implementations, specially for Django.

A fresh approach to autocomplete implementations, specially for Django. Status: v3 stable, 2.x.x stable, 1.x.x deprecated. Please DO regularely ping us with your link at #yourlabs IRC channel

YourLabs 1.6k Dec 22, 2022
A Django backed for PostgreSQL using Psycopg 3

A Django backend for PostgreSQL using Psycopg 2 The backend passes the entire Django test suite, but it needs a few modifications to Django and to i

Daniele Varrazzo 42 Dec 16, 2022
A quick way to add React components to your Django templates.

Django-React-Templatetags This django library allows you to add React (16+) components into your django templates. Features Include react components u

Fröjd Agency 408 Jan 08, 2023
Актуальный сборник шаблонов для создания проектов и приложений на Django

О чем этот проект Этот репозиторий с шаблонами для быстрого создания Django проекта. В шаблоне проекта настроены следующий технологий: Django gunicorn

Denis Kustov 16 Oct 20, 2022
Modular search for Django

Haystack Author: Daniel Lindsley Date: 2013/07/28 Haystack provides modular search for Django. It features a unified, familiar API that allows you to

Haystack Search 3.4k Jan 08, 2023
pdm-django: Django command shortcuts for PDM

pdm-django: Django command shortcuts for PDM A plugin that gives you command shortcuts for developing with PDM. pdm run python manage.py runserver -

Neutron Sync 2 Aug 11, 2022
Tutorial para o projeto negros.dev - A Essência do Django

Negros Dev Tutorial para o site negros.dev Este projeto foi feito com: Python 3.8.9 Django 3.1.8 Bootstrap 4.0 Como rodar o projeto? Clone esse reposi

Regis Santos 6 Aug 12, 2022
Pipeline is an asset packaging library for Django.

Pipeline Pipeline is an asset packaging library for Django, providing both CSS and JavaScript concatenation and compression, built-in JavaScript templ

Jazzband 1.4k Jan 03, 2023
A collection of models, views, middlewares, and forms to help secure a Django project.

Django-Security This package offers a number of models, views, middlewares and forms to facilitate security hardening of Django applications. Full doc

SD Elements 258 Jan 03, 2023
Django Persistent Filters is a Python package which provide a django middleware that take care to persist the querystring in the browser cookies.

Django Persistent Filters Django Persistent Filters is a Python package which provide a django middleware that take care to persist the querystring in

Lorenzo Prodon 2 Aug 05, 2022
A simple polling app made in Django and Bootstrap

DjangoPolls A Simple Polling app made with Django Instructions Make sure you have Python installed Step 1. Open a terminal Step 2. Paste the given cod

Aditya Priyadarshi 1 Nov 10, 2021
APIs for a Chat app. Written with Django Rest framework and Django channels.

ChatAPI APIs for a Chat app. Written with Django Rest framework and Django channels. The documentation for the http end points can be found here This

Victor Aderibigbe 18 Sep 09, 2022
A modern looking portfolio build with Django.

Django Portfolio A portfolio template using html/css/js in the frontend and Django as the backend framework. Cool features: smooth scrolling responsiv

1 Jan 19, 2022
Exploit Discord's cache system to remote upload payloads on Discord users machines

Exploit Discord's cache system to hide payloads PoC Remote upload embedded payload from image using EOF to Discord users machines through cache. Depen

cs 169 Dec 20, 2022
Automatic class scheduler for Texas A&M written with Python+Django and React+Typescript

Rev Registration Description Rev Registration is an automatic class scheduler for Texas A&M, aimed at easing the process of course registration by gen

Aggie Coding Club 21 Nov 15, 2022