Dj-stripe: Drop DJSTRIPE_PLANS in docs

Created on 6 Jul 2017  路  3Comments  路  Source: dj-stripe/dj-stripe

You removed support for DJSTRIPE_DEFAULT_PLAN setting a month ago. It would be good to remove the DJSTRIPE_PLANS settings also in docs/installation.rst and README.rst in order to avoid misunderstandings.

documentation

Most helpful comment

I believe you should create the plans in the Stripe dashboard, and sync then with a management command such as:

from django.core.management.base import BaseCommand

from djstripe.models import Plan
from djstripe.stripe_objects import StripeObject, StripePlan


class Command(BaseCommand):
    help = "Creates Stripe plans in the database from Stripe dashboard"

    def handle(self, *args, **options):
        for plan in Plan.api_list():
            Plan.sync_from_stripe_data(plan)

        self.stdout.write(self.style.SUCCESS("Successfully ensured Stripe plans exist."))

This seems to work well for me. Not sure if it's the intended method though.

All 3 comments

Yep, it's in the works

What's the proper way of adding plans now?

DJSTRIPE_PLANS = {
    'monthly': {
        'striple_plan_id': 'basic-reservations-monthly',
        'name': 'Basic',
        'description': '',
        'price': 100,
        'currency': (
            ('usd', _('US Dollars'))
        ),
        'interval': 'month'
    }
}

and

DJSTRIPE_PLANS = {
    'monthly': {
        'striple_plan_id': 'basic-monthly',
        'name': 'Basic',
        'description': '',
        'price': 100,
        'currency': 'usd',
        'interval': 'month'
    }
}

both throw:

SystemCheckError: System check identified some issues:

ERRORS:
djstripe.Plan.currency: (fields.E005) 'choices' must be an iterable containing (actual value, human readable name) tuples.

Thanks in advance!

I believe you should create the plans in the Stripe dashboard, and sync then with a management command such as:

from django.core.management.base import BaseCommand

from djstripe.models import Plan
from djstripe.stripe_objects import StripeObject, StripePlan


class Command(BaseCommand):
    help = "Creates Stripe plans in the database from Stripe dashboard"

    def handle(self, *args, **options):
        for plan in Plan.api_list():
            Plan.sync_from_stripe_data(plan)

        self.stdout.write(self.style.SUCCESS("Successfully ensured Stripe plans exist."))

This seems to work well for me. Not sure if it's the intended method though.

Was this page helpful?
0 / 5 - 0 ratings