#samip_best-practices

1 messages ยท Page 1 of 1 (latest)

dire kettleBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1397003614563733564

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

ionic prairie
#

hello! just want to acknowledge your question - i'm wrapping up another thread but will get to you asap

wet basalt
#

Thanks, sure!

dire kettleBOT
wet basalt
#

Just trying to keep the thread active ๐Ÿ™‚

open marten
#

To clarify, the customer has some subscriptions before (but now cancelled), which was discounted. Now you only have the customers and want to find the discount applied, correct?

wet basalt
#

Yes

#

I can find the customers by applying a filter , but the export does not include coupon code.

#

There are over 220 customers so rather than doing it manually, I was wondering if there is a way to find customers with discounts and also enlist their coupon code?

high bane
#

well howdy

open marten
#

@high bane hi, I will continue in your thread. Please gimme some time

high bane
#

I been waiting an hour more than this guy and your taking more people

#

tf

#

im being ignored

open marten
#

No I don't, but we will talk with multiple users in parallel. I haven't get back to them in a while too. Please come back to your thread

high bane
#

this thread started at 5:15

#

5:53

#

IM watching there are no updates

open marten
#

@wet basalt If you try List Subscription with status = cancel, then filter the Customer Id, could you somehow get the discounted coupon? Maybe by looking at the Subscription' discounts

wet basalt
#

Hi , I did try this way : https://dashboard.stripe.com/customers?coupon= <coupon_code>

This gives me the customer list which is exactly what I need but the export does not list coupon / discounts ?

So, I am wondering if there is any other way that I can use a coupon code and see what customers have an Active redemptions ? Probably via the API ?

open marten
#

Yeah let's try to figure it out via API

#

First let's try the List Customers, and look at each Customer object in the list returned by the response, and check if you see the coupon there

wet basalt
#

Sweet, give me ~15 minutes to build this one out, I might reply to the thread to just keep it active.

open marten
#

Sure!

wet basalt
#

Okay discount: null, is sent in the response but I can see a discount /

#

Maybe my test data setup is wrong, here's the request ID req_dAkp0hgsVZ7oHB

open marten
#

For "can see a discount" where do you see it?

wet basalt
open marten
#

Okie, and you saw discount: null on the Customer object?

wet basalt
#

Yes

#

I tried with some other test data as well, I still get a discount null

#

I am using NodeJS SDK 18.2.1 .

await sourceStripe.customers.retrieve('<customer_id>')

open marten
#

Just that Customer, to see if you see the discount on the Subscriptions in response

wet basalt
#

discounts: [],

#

Discounts is empty for some reason ๐Ÿค”

#

customer.data[0].items.discount is an empty array

open marten
#

Yes but I mean the Subscription

#

Take the first Customer Id,

wet basalt
#

This is for the subscription ?

open marten
#

Call List Subscription, with that Id

wet basalt
#

await sourceStripe.subscriptions.list({
customer: '<customer_id>',
});

open marten
#

Yes, with status = cancelled

wet basalt
#

Hmm, this subscription isn't cancelled

#

The list I am looking for can have both cancelled and active accounts.

open marten
#

Okie okie

wet basalt
#

It is fine if I can just get the customers and their adjacent discount codes. I can create an export of my own

#

But, I am not finding anything in the API ?

open marten
#

Yes I am afraid the data is deep under the Subscription object of each Customer.

#

So likely you would need to loop over the Customers, and list Subscriptions on each of them. That requires some logic

wet basalt
#

So, enlist the customers then list their adjacent subscription ?

open marten
#

Yes

wet basalt
#

Sorry, where in the subscription object is it ?

#

I tried pulling an individual subscription

#

but I cannot see any discounts

open marten
#

Hmm alright looking closer into this one

#

Can you call a Retrieve Subscription API (not Dashboard) and share with me the response JSON on this Sub Id?

#

Ah the promotion code was applied to the first Invoice of this Subscription, not the Subscription itself

#

Um sorry this is a bit too deep to use API. Basically you need to List the Invoice belongs to a Subscirption, then list Subscription belongs to a Customer, on a list of Customer

#

Going back to the Dashboard a bit, You can filter the customer has discounts here, then start finding out which discount, coupon from the Id with the chain above

wet basalt
#

Ah, that's going to be a lot of work unfortunately