#sejo

1 messages ยท Page 1 of 1 (latest)

hasty summitBOT
short quarry
#

Hi ๐Ÿ‘‹ can you elaborate on the problem you're facing?

deep wagon
#

hello! If I am trying to create a get so that it returns the user's subscription id with his mail, but I would not understand how to send this because the documentation says that it has to be a get and not a post

#

How would I pass the user's email through a get? to receive the subscription id and thus send it to cancel subscriptions

#

This is the documentation I'm reading

short quarry
#

To make sure I understand, you're trying to make a request to list Subscriptions based on the email address of the associated Customer?

#

Oh, you're trying to list Customer objects?

deep wagon
#

none of the 2 ... I just want your subscription id to be able to send and cancel it .. to cancel the subscription it asks me to send the subscription id as data

short quarry
#

Okay, if you don't have the ID of the Subscription, then you will need to make a request to list Subscriptions, find the one you're looking for, and use its ID.

Do you have the ID of the Customer object already? Or do you only have the email address?

deep wagon
#

I only have the email address

#

I mean, by email, it's like filtering the subscription id to a single search faster, right?

short quarry
#

Okay, so there are two pieces to this challenge:

  • Finding the right Customer
  • Finding the right Subscription for that Customer
hasty summitBOT
short quarry
#

We can likely retrieve all of the objects in a single step, and then you can build code to step through the results and find the correct objects.

For listing Customers based on an email address, you will want to use the approach shown in the screenshot that you provided, but also include an email field in the request (similar to how limit is shown in the sample code) where you pass a string with the email address you're looking for.

It is important to note that our email filtering when listing Customer objects is case sensitive, so if you are storing email addresses in a different case than they were provided to us the filtering will not find results.

#

Is it including the email address in the filter criteria that is giving you troubles, and if so are you using our Node library (assumed based on the screenshot) or a different approach to make requests to our API?

deep wagon
#

I am using node.js but if I make the route for example /av1/customers/:email I would pass the email as a parameter and I could use it in the get request

#

const customers = await stripe.customers.list({
email: req.body.params,
});

#

How do I pass this code to you? Is it okay to consult as I just told you?

short quarry
deep wagon
#

I'm going to try it now, if you told me it could work I'll try anything I'll be back

#

Do you have to close this conversation?

astral pagoda
#

๐Ÿ‘‹ I'm taking over for my teammate! We usually close threads after ~20-25 mins of inactivity so I'll keep yours open for a bit

#

If you anticipate having more questions much later, feel free to reach out to us again in the main #dev-help channel

deep wagon
#

well I just had an error with the code that I planted

astral pagoda
#

Can you share more details about this error?

deep wagon
#

this is my code

astral pagoda
deep wagon
#

I solved it, but I want to know this just...

#

the subscription id of this client is "id": "cus_NsLUFW2to1U0iF",?

astral pagoda
#

cus_NsLUFW2to1U0iF is the ID of a customer object

deep wagon
#

This is what I need to cancel the subscription
?

astral pagoda
#

This call will return a list of this specific customer's subscriptions, including the subscription IDs. Once you've determined which subscription to cancel, you'll need the subscription ID to cancel it

deep wagon
#

But that's what I'm looking for. The subscription id is unique, isn't it? that's why it's an ID I don't understand why I have to do another step

#

I mean, the only thing I'm looking for is the user's subscription id to be able to cancel the subscription. I don't understand why so many rounds to get something that is unique

astral pagoda
#

Yes, subscription IDs are unique. However, each customer can have many/multiple subscriptions

#

Another way you can do this is, now that you have a customer ID, you can list all subscriptions and filter by customer to get a list of all the subscriptions associated with that customer: https://stripe.com/docs/api/subscriptions/list

deep wagon
#

As you can see that you are not reading or seeing the images, but hey, send me something that I have just done and I just asked you something simple and you send me to do something that I have already implemented

#

I'll go in later to check that you're doing well

astral pagoda
#

I don't think I'm understanding your question. I think you're trying to start with a customer email address and want to arrive at their subscription in order to cancel that subscription, correct?