2
0

🐛 (stripe) Update additional items when they didn't exist

This commit is contained in:
Baptiste Arnaud
2022-09-19 08:27:06 +02:00
committed by Baptiste Arnaud
parent c94a6581be
commit f83e0efea2
4 changed files with 51 additions and 45 deletions

View File

@ -138,22 +138,22 @@ const updateSubscription = async (req: NextApiRequest) => {
: process.env.STRIPE_PRO_PRICE_ID,
quantity: 1,
},
currentAdditionalChatsItemId
? {
additionalChats === 0 && !currentAdditionalChatsItemId
? undefined
: {
id: currentAdditionalChatsItemId,
price: process.env.STRIPE_ADDITIONAL_CHATS_PRICE_ID,
quantity: additionalChats,
deleted: additionalChats === 0,
}
: undefined,
currentAdditionalStorageItemId
? {
},
additionalStorage === 0 && !currentAdditionalStorageItemId
? undefined
: {
id: currentAdditionalStorageItemId,
price: process.env.STRIPE_ADDITIONAL_STORAGE_PRICE_ID,
quantity: additionalStorage,
deleted: additionalStorage === 0,
}
: undefined,
},
].filter(isDefined)
await stripe.subscriptions.update(subscription.id, {
items,