#fedoraus

1 messages · Page 1 of 1 (latest)

marble nestBOT
urban hull
#

Hello 👋
Can you provide more information?

#

What issue are you seeing?

proven hinge
#

Hi look at my function

#

exports.getCustomerPortalLink = functions.https.onRequest(async (req, res) => {
try {
const uid = req.query.uid;

// Проверяем, что пользователь аутентифицирован
if (!uid) {
  res.status(401).send('User must be authenticated.');
  return;
}

// Получаем данные пользователя из Firestore
const userSnapshot = await firestore.doc(uid).get();
const userData = userSnapshot.data();

if (!userData || !userData.customer_id) {
  res.status(404).send('Customer ID not found.');
  return;
}

const customerId = userData.customer_id;

// Генерируем ссылку на портал покупателя
const session = await stripeTest.billingPortal.sessions.create({
  customer: customerId,
  returnUrl: 'https://www.google.com/',
});

res.send({
  portalLink: session.url,
});

} catch (error) {
console.error(error);
res.status(500).send('Server error occurred.');
}
});

#

im using firebase cloud fuctions to create custom portal session for user

#

firebase returns me a link, and i put uid of user like query param, i check my logs and stripe send me error w code unknown param

#

but i put param in my firebase function, like in request link, it doesnt matter

urban hull
proven hinge
#

my bad

#

i wrote returnUrl

#

but not return_url

#

ty, logs page helped me

#

they wrote like: may be you mean return_url? XD

urban hull
#

ah nice 😄 glad you figured it out

proven hinge
#

return url is required param?

urban hull
proven hinge
#

yeah, i saw, it means that my problem is not resolver

#

let me check logs again

urban hull
#

👍

proven hinge
#

how i can save my customer portal settings??

urban hull
#

Try going to the link above

proven hinge
#

tyty

#

but when ill switch to real mode, I will also need to save my customer portal settings?

#

hello?