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 music recommendation REST API which makes a machine learning algorithm work with the Django REST Framework

music-recommender-rest-api A music recommendation REST API which makes a machine learning algorithm work with the Django REST Framework How it works T

The Reaper 1 Sep 28, 2021
A starter template for building a backend with Django and django-rest-framework using docker with PostgreSQL as the primary DB.

Django-Rest-Template! This is a basic starter template for a backend project with Django as the server and PostgreSQL as the database. About the templ

Akshat Sharma 11 Dec 6, 2022
A simple page with paypal payment and confiramtion in django

django-paypal a simple page with paypal payment and confiramtion in django Youtube Video : Paypal Smart Button : https://developer.paypal.com/demo/che

Mahmoud Ahmed 5 Feb 19, 2022
DRF_commands is a Django package that helps you to create django rest framework endpoints faster using manage.py.

DRF_commands is a Django package that helps you to create django rest framework endpoints faster using manage.py.

Mokrani Yacine 2 Sep 28, 2022
A Django app to accept payments from various payment processors via Pluggable backends.

Django-Merchant Django-Merchant is a django application that enables you to use multiple payment processors from a single API. Gateways Following gate

Agiliq 997 Dec 24, 2022
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 9, 2022
Bringing together django, django rest framework, and htmx

This is Just an Idea There is no code, this README just represents an idea for a minimal library that, as of now, does not exist. django-htmx-rest A l

Jack DeVries 5 Nov 24, 2022
RestApi With Django 3.2 And Django Rest Framework

RestApi-With-Django-3.2-And-Django-Rest-Framework Description This repository is a Software of Development with Python. Virtual Using pipenv, virtuale

Daniel Arturo Alejo Alvarez 6 Aug 2, 2022
Django API without Django REST framework.

Django API without DRF This is a API project made with Django, and without Django REST framework. This project was done with: Python 3.9.8 Django 3.2.

Regis Santos 3 Jan 19, 2022
Atualizando o projeto APIs REST Django REST 2.0

APIs REST Django REST 3.0-KevinSoffa Atualização do projeto APIs REST Django REST 2.0-Kevin Soffa Melhorando e adicionando funcionalidades O que já fo

Kevin Soffa 2 Dec 13, 2022
This is a basic Todo Application API using Django Rest Framework

Todo Application This is a basic Todo Application API using Django Rest Framework. Todo Section - User can View his previously added todo items, creat

Atharva Parkhe 1 Aug 9, 2022
Django project starter on steroids: quickly create a Django app AND generate source code for data models + REST/GraphQL APIs (the generated code is auto-linted and has 100% test coverage).

Create Django App ?? We're a Django project starter on steroids! One-line command to create a Django app with all the dependencies auto-installed AND

imagine.ai 68 Oct 19, 2022
Django-Audiofield is a simple app that allows Audio files upload, management and conversion to different audio format (mp3, wav & ogg), which also makes it easy to play audio files into your Django application.

Django-Audiofield Description: Django Audio Management Tools Maintainer: Areski Contributors: list of contributors Django-Audiofield is a simple app t

Areski Belaid 167 Nov 10, 2022
django Filer is a file management application for django that makes handling of files and images a breeze.

django Filer is a file management application for django that makes handling of files and images a breeze.

django CMS Association 1.6k Jan 6, 2023
📊📈 Serves up Pandas dataframes via the Django REST Framework for use in client-side (i.e. d3.js) visualizations and offline analysis (e.g. Excel)

Django REST Pandas Django REST Framework + pandas = A Model-driven Visualization API Django REST Pandas (DRP) provides a simple way to generate and se

wq framework 1.2k Jan 1, 2023
django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project. Inspired in the dashboard framework Dashing

django-dashing django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project.

talPor Solutions 703 Dec 22, 2022
PEP-484 stubs for django-rest-framework

pep484 stubs for Django REST framework Mypy stubs for DRF 3.12.x. Supports Python 3.6, 3.7, 3.8 and 3.9. Installation pip install djangorestframework-

TypedDjango 303 Dec 27, 2022
Forgot password functionality build in Python / Django Rest Framework

Password Recover Recover password functionality with e-mail sender usign Django Email Backend How to start project. Create a folder in your machine Cr

alexandre Lopes 1 Nov 3, 2021
Django Rest Framework + React application.

Django Rest Framework + React application.

null 2 Dec 19, 2022