Is there a need for encrypting the Stripe customer ID within the NextJS environment? I have a NextJS API route which updates the customer email address based on the Stripe Customer ID from the Firestore database (Stripe extension for Firebase):
const {
email = '',
name = '',
customerId = ''
} = req.body;
const customer = await stripe.customers.update(
customerId, {
email,
name
}
);
This looks like a thread, as others who might guess the Stripe customer ID can update the value. Should all Stripe payment-related functionality better be migrated to Firebase Functions, or is it safe to expose it? Think about the Setup Intents... how different are they?
Update:
useEffect(() => {
const { stripeId } = authUser || {};
if (stripeId) {
fetch('/api/setup_intent', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ customerId: stripeId })
})
.then((res) => res.json())
.then((data) => setClientSecret(data.clientSecret));
}
}, [authUser]);