#sejo
1 messages ยท Page 1 of 1 (latest)
Hi ๐ can you elaborate on the problem you're facing?
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
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?
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
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?
I only have the email address
I mean, by email, it's like filtering the subscription id to a single search faster, right?
Okay, so there are two pieces to this challenge:
- Finding the right Customer
- Finding the right Subscription for that Customer
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?
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?
Depending on how the data is structured in your request, I think you may need to parse the necessary information from this a bit more, but the general idea looks right. Are you encountering an error when trying to run that code?
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?
๐ 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
well I just had an error with the code that I planted
Can you share more details about this error?
The error message states the email value passed is not a string. Could you share the request ID for this request? https://support.stripe.com/questions/finding-the-id-for-an-api-request
I solved it, but I want to know this just...
the subscription id of this client is "id": "cus_NsLUFW2to1U0iF",?
cus_NsLUFW2to1U0iF is the ID of a customer object
This is what I need to cancel the subscription
?
Let's take a step back. I understand you have a customer's email address and, using this address, you want to find their subscription and cancel it. Now that you have their customer ID, you can make a call to retrieve the customer object and expand their subscriptions: https://stripe.com/docs/api/customers/object#customer_object-subscriptions
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
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
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
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
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?