#Thomas C
1 messages ยท Page 1 of 1 (latest)
Hi, here it is : sub_1M8kpDDeg55eSBYjSaUIWhWf
By the way, I have this issue on several subs
Thanks! Give me a few minutes to look into this.
Can you clarify which coupon you were expecting to see on this subscription? And how are you retrieving the subscription with the API?
It is the "BLACKFRIDAY2022" coupon
here is how I call the API :
def stripe_get_data(resource, start_date=None, end_date=None, **kwargs):
if start_date:
# convert to unix timestamp
start_date = int(start_date.timestamp())
if end_date:
# convert to unix timestamp
end_date = int(end_date.timestamp())
resource_list = getattr(stripe, resource).list(limit=100, created={"gte": start_date,"lt": end_date}, **kwargs)
lst = []
for i in resource_list.auto_paging_iter():
lst.extend([i])
df = pd.DataFrame(lst)
if len(df) > 0:
df['created'] = pd.to_datetime(df['created'], unit='s')
return df
df_sub_stripe = stripe_get_data('Subscription', status='all')
temp=df_sub_stripe[df_sub_stripe["id"]=="sub_1M8kpDDeg55eSBYjSaUIWhWf"]
I'll look in one more detail but a common thing is, you have to realise discount on the Subscription is only set if there's an ongoing recurring discount currently active; if your coupon is just like "50% off, once" and applied to the first invoice, there is no ongoing discount
ok in this case it is a recurring coupon at least, so it' not that issue.
What exact response are you getting from the API? how do you determine that "'discount' is None", can you show me that code, can you show me the contents of logging/printing the Subscription object?
Thanks for your help, here is the print :
df_sub_stripe[df_sub_stripe["id"]=="sub_1M8kpDDeg55eSBYjSaUIWhWf"]['discount']
Out[8]:
296 None
Name: discount, dtype: object
can you just do like
sub = stripe.Subscription.retrieve(
"sub_1M8kpDDeg55eSBYjSaUIWhWf",
)
print(sub.discount)
print(sub.discounts)
print(sub)
and see what returns?
sub = stripe.Subscription.retrieve(
"sub_1M8kpDDeg55eSBYjSaUIWhWf",
)
print(sub.discount)
None
i get an error with print(sub.discounts)
if you remove that line, and just do print(sub), what does it look like?
hmm, strange
I really have no idea, I thought maybe we stop returning the discount field if the subscription is cancelled, but I tested and that doesn't seem to be the case.
Arf, is there anything I can do to solve this problem another way ?
Hi there ๐ jumping in as my teammates need to step away, please bear with me a moment while I catch up on the context here.
Hi !
Alright, so if I'm understanding right, when you retrieve a Subscription that has an associated discount, no ID is being returned.
Well, the discount field is None. I don't know if it is what you meant
๐ we are still looking into this, give us a bit
For when you get back @misty plinth, the reason here is that you used a coupon with duration: 3 on this Sub and the Sub has a monthly Price. That means the discount would have applied for 3 months (if the Sub wasn't canceled). Since we are outside that 3 month window at this point, the discount returns null.