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
Django Pickled Model

Django Pickled Model Django pickled model provides you a model with dynamic data types. a field can store any value in any type. You can store Integer

Amir 3 Sep 14, 2022
Service request portal on top of Ansible Tower

Squest - A service request portal based on Ansible Tower Squest is a Web portal that allow to expose Tower based automation as a service. If you want

Hewlett Packard Enterprise 183 Jan 04, 2023
Wagtail - Vue - Django : The initial environment of full-stack local dev web app with wagtail and vue

Wagtail - Vue - Django : The initial environment of full-stack local dev web app with wagtail and vue. A demo to show how to use .vue files inside django app.

Quang PHAM 2 Oct 20, 2022
Let AngularJS play well with Django

django-angular Let Django play well with AngularJS What does it offer? Add AngularJS directives to Django Forms. This allows to handle client side for

Jacob Rief 1.2k Dec 27, 2022
An airlines clone website with django

abc_airlines is a clone website of an airlines system the way it works is that first you add flights to the website then the users can search flights

milad 1 Nov 16, 2021
CRUD with MySQL, Django and Sass.

CRUD with MySQL, Django and Sass. To have the same data in db: insert into crud_employee (first_name, last_name, email, phone, location, university) v

Luis Quiñones Requelme 1 Nov 19, 2021
A Powerful HTML white space remover for Django

HTML Whitespace remover for Django Introduction : A powerful tool to optimize Django rendered templates Why use "django_stip_whitespace" ? Adds line b

3 Jan 01, 2022
Hello world written in Django.

Learning Django 💡 create a virtual environment create python -m venv ./venv. this virtualenv file will be excluded by .gitignore activate the virtual

Dipak giri 4 Nov 26, 2021
Awesome Django Markdown Editor, supported for Bootstrap & Semantic-UI

martor Martor is a Markdown Editor plugin for Django, supported for Bootstrap & Semantic-UI. Features Live Preview Integrated with Ace Editor Supporte

659 Jan 04, 2023
Django query profiler - one profiler to rule them all. Shows queries, detects N+1 and gives recommendations on how to resolve them

Django Query Profiler This is a query profiler for Django applications, for helping developers answer the question "My Django code/page/API is slow, H

Django Query Profiler 116 Dec 15, 2022
Django-MySQL extends Django's built-in MySQL and MariaDB support their specific features not available on other databases.

Django-MySQL The dolphin-pony - proof that cute + cute = double cute. Django-MySQL extends Django's built-in MySQL and MariaDB support their specific

Adam Johnson 504 Jan 04, 2023
Extensions for using Rich with Django.

django-rich Extensions for using Rich with Django. Requirements Python 3.6 to 3.10 supported. Django 2.2 to 4.0 supported. Are your tests slow? Check

Adam Johnson 88 Dec 26, 2022
Radically simplified static file serving for Python web apps

WhiteNoise Radically simplified static file serving for Python web apps With a couple of lines of config WhiteNoise allows your web app to serve its o

Dave Evans 2.1k Dec 15, 2022
A django integration for huey task queue that supports multi queue management

django-huey This package is an extension of huey contrib djhuey package that allows users to manage multiple queues. Installation Using pip package ma

GAIA Software 32 Nov 26, 2022
Full control of form rendering in the templates.

django-floppyforms Full control of form rendering in the templates. Authors: Gregor Müllegger and many many contributors Original creator: Bruno Renié

Jazzband 811 Dec 01, 2022
Returns unicode slugs

Python Slugify A Python slugify application that handles unicode. Overview Best attempt to create slugs from unicode strings while keeping it DRY. Not

Val Neekman (AvidCoder) 1.3k Dec 23, 2022
Example project demonstrating using Django’s test runner with Coverage.py

Example project demonstrating using Django’s test runner with Coverage.py Set up with: python -m venv --prompt . venv source venv/bin/activate python

Adam Johnson 5 Nov 29, 2021
Django-shared-app-isolated-databases-example - Django - Shared App & Isolated Databases

Django - Shared App & Isolated Databases An app that demonstrates the implementa

Ajai Danial 5 Jun 27, 2022
Packs a bunch of smaller CSS files together from 1 folder.

Packs a bunch of smaller CSS files together from 1 folder.

1 Dec 09, 2021
Inject an ID into every log message from a Django request. ASGI compatible, integrates with Sentry, and works with Celery

Django GUID Now with ASGI support! Django GUID attaches a unique correlation ID/request ID to all your log outputs for every request. In other words,

snok 300 Dec 29, 2022