#Adi - customer portal
1 messages ยท Page 1 of 1 (latest)
Hello. One moment while I catch up with threads here
Is this because some customers will have both an INR plan and a USD plan and you want them to be separate?
yes
stripe has limitation that Indian customers cannot pay in USD (I have business registered in India)
I am able to accept payment from all the countries except India for that I am doing this
@neon tide A Stripe customer can only accept payments in a single currency (the same customer wouln't be able to have both a INR and a USD subscription). You'd need to have them as two separate customers, and so you'd have separate customer portal sessions for them
but how can I create separate portal session? On stripe dashboard I dont see any option to create new customer portal for adding INR products separately and USD products separately
sorry my bad actually even if we add INR and USD on stripe dashboard it works fine. Stripe has that intelligence to automatically separate that
Thanks for help and support
๐ glad to hear it works! I was just about to ask if you had tried this all out ๐
from stripe customer billing portal once payment is success why does it not redirect to my application page?
check this code:
router.post('/create-customer-portal-session', isAuth, async (req, res) => {
const sessionData = req.body;
// Authenticate your user.
const session = await stripe.billingPortal.sessions.create({
customer: sessionData.customerId,
return_url: 'http://localhost:3000/upgrade',
});
res.send({ url: session.url });
});
I have added return url http://localhost:3000/upgrade
That rerturn URL is specifically for when a customer clicks the "<-- Return to <account name>" link on the portal - we don't redirect to that URL when paymetn is succesful
if someone wants to switch from USD to INR then he must first cancel USD subscription and then only he can switch INR and vice versa is that correct understanding??
If a customer wants to switch from USD to INR you need to create a whole new Customer object for them - Stripe Customers are tied to a specific currency, which can't be changed
for free plan I will have to use O INR and $0 each is that correct?? for USD and INR separate payments?
correct
can I also maintain any metadata for billing portal session?
code:
router.post('/create-customer-portal-session', isAuth, async (req, res) => {
try {
const user_id = req.userId;
const sessionData = req.body;
// Authenticate your user.
const session = await stripe.billingPortal.sessions.create({
customer: sessionData.customerId,
return_url: 'http://localhost:3000/upgrade'
});
res.send({ url: session.url });
} catch (error) {
console.error("create-customer-portal-session error: ", error)
next(createError(400, "Failed to create stripe customer billing portal"));
}
});
Hello ๐
I'm stepping in for @limber radish .
I don't see any metadata being used in this code snippet. What are you trying to achieve?
I tried this:
const session = await stripe.billingPortal.sessions.create({
customer: sessionData.customerId,
return_url: 'http://localhost:3000/upgrade',
metadata: {
user_id: user_id,
price_id: priceId,
}
});
got bad request
Metadata is not a supported parameter for the Billing Portal session:
https://stripe.com/docs/api/customer_portal/sessions/create
You can see the supported parameters here
You can add metadata to the Configuration object, if you are using it.
https://stripe.com/docs/api/customer_portal/configurations/create
What is the goal of using this metadata?
why I was looking for metadata because I wanted to update my database user with new subscription_id and price_id
this I will do in customer.subscription.updated event
on updating subscription customer id will also change or not?
That makes much more sense. The customer will stay the same
ok then got it. I will query DB based on customer id and then update rest of the details
That sounds like a sensible workflow.
Thanks a lot for help and support ๐ ๐