fix: optionally add name to customer creation (#43486)

This commit is contained in:
Ahmad Abdolsaheb
2021-09-20 10:56:42 +03:00
committed by GitHub
parent 3a4889942b
commit cf309b5349

View File

@ -184,7 +184,7 @@ export async function createStripeCardDonation(req, res, stripe) {
user user
} = req; } = req;
if (!tokenId || !amount || !duration || !name || !userId || !email) { if (!tokenId || !amount || !duration || !userId || !email) {
throw { throw {
message: 'Request is not valid', message: 'Request is not valid',
type: 'InvalidRequest' type: 'InvalidRequest'
@ -203,7 +203,7 @@ export async function createStripeCardDonation(req, res, stripe) {
const customer = await stripe.customers.create({ const customer = await stripe.customers.create({
email, email,
card: tokenId, card: tokenId,
name ...(name && { name })
}); });
customerId = customer?.id; customerId = customer?.id;
} catch { } catch {