#Sq-subs
1 messages · Page 1 of 1 (latest)
hello @tropic crescent ! You can list subscriptions on a Customer using these API calls :
https://stripe.com/docs/api/subscriptions/list
https://stripe.com/docs/api/subscriptions/retrieve
Is there a particular parameter or piece of information which you're having trouble retrieving?
I am using nodejs as backend to get the details. can i share my code with you and can you help me take a look at the process?
app.get("/customers", async (req, res) => {
const email = req.body.email;
const customers = await stripe.customers.list({
limit: 3,
email: email
})
const subscriptions = await stripe.subscriptions.list({
customer: customers.data[0].id
})
res.send(customers, subscriptions);
});
my goal is to get the customer id then the customer's subscription
is there a better way to do it?
onesecond, let me put something together for you
thank you
https://stripe.com/docs/api/expanding_objects
const customers = await stripe.customers.list({
limit: 3,
email : email,
expand: ['data.subscriptions']
});
you don't have to make a separate call to retrieve the subscriptions, you can expand that parameter : https://stripe.com/docs/api/customers/object?lang=node#customer_object-subscriptions
ohh thank you so much! i will take a look at these
Sorry just another question on Stripe. Is it possible for a customer to change between their subscribed plan?
you mean like upgrade or downgrade to a different plan?
yes
like i have a basic plan and pro plan, would be possible for the same customer to remove the basic and add the pro plan using the same customer id
yep, that's totally possible, this may be helpful to you : https://stripe.com/docs/billing/subscriptions/upgrade-downgrade
oh i did see this! thank you so much!!
is it not possible to put it within the customer portal?
it's possible to upgrade/downgrade on the customer portal as well. https://stripe.com/docs/billing/subscriptions/customer-portal
On that page above you will see a Preview the customer portal button, if you click on that, you'll be able to play around with a demo customer portal and you can also update the plans for the customer