#hatim
1 messages · Page 1 of 1 (latest)
Hello! Can you share that Subscription ID with me?
ok, just a moment
sub_1Mo4mfB21EjZLsyuftaOv9bV
and item:
si_NZDDDrW1DJVF4P
used this code:
if user.stripe_customer_id:
product_id = settings.STRIPE_SUBSCRIPTION_PRODUCT_ID
prices = stripe.Price.list(product=product_id)
subscriptions = user.get_active_stripe_subscriptions
if not subscriptions:
raise ValueError(f"No active subscription found for user ID {user.id}")
subscription = subscriptions[0]
subscription_items = subscription.get("items")
if not subscription_items:
raise ValueError(f"No subscription items found for subscription ID {subscription.id}")
subscription_item = subscription_items.data[0]
if not subscription_item.price.id == prices.data[0].id:
raise ValueError(f"Subscription item price ID {subscription_item.price.id} does not match default price ID {prices.data[0].id}")
# send stripe usage record
usage_record = stripe.SubscriptionItem.create_usage_record(
subscription_item.id,
quantity=instance.total_tokens,
timestamp=int(timezone.now().timestamp()),
action='increment',
)
👍 give me a few minutes to take a look
So I think things got a bit confusing here - are you looking at in_1Mo4mgB21EjZLsyuImKY6OQp and wondering why that charged $0?
If you look at the upcoming invoice you can see that all that usage you've been recording will be charged correctly
so, when i click on "view usage" in the invoice. it shows a lot of usage during the current period.
So, you mean this shows that it's correct and the user will be charged at the end of the period?
so, is this correct behavior? will the user charge by the end of the period even though the total appears $0?
Yup, this is the correct behavior (just a bit misleading) - the NEXT invoice should be the one that has all the usage billed for