Skip to content

Support for Prices and attaching Price items to subscriptions #160

@NomanGul

Description

@NomanGul

I set up the localstripe package in my python backend but It's throwing Bad Request error here:

                trial_end = (date.today() + relativedelta(months=+1)).strftime('%s')
                subscription_items = [{
                    "price": "price_xxxxxxxxxxxxxxx"
                }]
                subscription = stripe.Subscription.create(
                    customer=customer.id,
                    trial_end=trial_end,
                    items=subscription_items,
                )

I searched into the GitHub issues but found nothing related. after that, I dig into the source code of localstripe and found out localstripe did not support price items yet and localstripe only supports plan items.

for item in items:
assert type(item.get('plan', None)) is str
if item.get('quantity', None) is not None:
item['quantity'] = try_convert_to_int(item['quantity'])
assert type(item['quantity']) is int
assert item['quantity'] > 0
else:
item['quantity'] = 1
item['tax_rates'] = item.get('tax_rates', None)
if item['tax_rates'] is not None:
assert type(item['tax_rates']) is list
assert all(type(tr) is str for tr in item['tax_rates'])
assert type(enable_incomplete_payments) is bool
assert payment_behavior in ('allow_incomplete',
'error_if_incomplete')
except AssertionError:
raise UserError(400, 'Bad request')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions