#Thomas C

1 messages ยท Page 1 of 1 (latest)

noble mossBOT
drifting nova
#

Hi there!

#

Can you share the subscription ID (sub_xxx)?

misty plinth
#

Hi, here it is : sub_1M8kpDDeg55eSBYjSaUIWhWf

#

By the way, I have this issue on several subs

drifting nova
#

Thanks! Give me a few minutes to look into this.

drifting nova
#

Can you clarify which coupon you were expecting to see on this subscription? And how are you retrieving the subscription with the API?

misty plinth
#

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"]

lyric kestrel
#

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?

misty plinth
#

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

lyric kestrel
#

can you just do like

sub = stripe.Subscription.retrieve(
  "sub_1M8kpDDeg55eSBYjSaUIWhWf",
)
print(sub.discount)
print(sub.discounts)
print(sub)

and see what returns?

misty plinth
#

sub = stripe.Subscription.retrieve(
"sub_1M8kpDDeg55eSBYjSaUIWhWf",
)
print(sub.discount)
None

#

i get an error with print(sub.discounts)

lyric kestrel
#

if you remove that line, and just do print(sub), what does it look like?

misty plinth
lyric kestrel
#

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.

misty plinth
#

Arf, is there anything I can do to solve this problem another way ?

green thistle
#

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.

misty plinth
#

Hi !

green thistle
#

Alright, so if I'm understanding right, when you retrieve a Subscription that has an associated discount, no ID is being returned.

misty plinth
#

Well, the discount field is None. I don't know if it is what you meant

abstract veldt
#

๐Ÿ‘‹ we are still looking into this, give us a bit

misty plinth
#

no problems

#

I'm going afk for 45min, see ya

abstract veldt
#

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.