Skip to content

Commit

Permalink
🐛 Fix stripe product default price was not updated
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Nov 28, 2024
1 parent 8901824 commit 4ec1950
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/routes/likernft/book/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ router.put(['/:classId/price/:priceIndex', '/class/:classId/price/:priceIndex'],
currency: 'usd',
unit_amount: price.priceInDecimal,
});
await stripe.products.update(
oldPriceInfo.stripeProductId,
{ default_price: newStripePrice.id },
);
await stripe.prices.update(
oldPriceInfo.stripePriceId,
{ active: false },
Expand Down
16 changes: 7 additions & 9 deletions src/util/api/likernft/collection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ export async function patchNFTCollectionById(
unit_amount: newTypePayload.priceInDecimal,
currency: 'usd',
});
await stripe.products.update(
stripeProductId,
{ default_price: newStripePrice.id },
);
await stripe.prices.update(stripePriceId, {
active: false,
});
Expand Down Expand Up @@ -481,20 +485,14 @@ export async function removeNFTCollectionById(
}
const { ownerWallet, typePayload = {} } = docData;
if (ownerWallet !== wallet) { throw new ValidationError('NOT_OWNER_OF_COLLECTION', 403); }
const { stripeProductId, stripePriceId } = typePayload;
if (stripePriceId) {
await stripe.prices.update(stripePriceId, {
const { stripeProductId } = typePayload;
if (stripeProductId) {
await stripe.products.update(stripeProductId, {
active: false,
}).catch((err) => {
// eslint-disable-next-line no-console
console.error(err);
});
}
if (stripeProductId) {
await stripe.products.del(stripeProductId).catch((err) => {
// eslint-disable-next-line no-console
console.error(err);
});
}
await likeNFTCollectionCollection.doc(collectionId).delete();
}

0 comments on commit 4ec1950

Please sign in to comment.