Skip to content

Commit

Permalink
stripe url fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Avneesh Agarwal committed Aug 30, 2021
1 parent b5bb358 commit 795c87c
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions components/InfoCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,26 @@ const InfoCard = ({
);
};
const createCheckoutSession = async () => {
const stripe = await stripePromise;
const newPrice = parseInt(price.slice(1, -1)) * 101;
const checkoutSession = await axios.post("/api/create-checkout-session", {
img: img,
title: title,
description: description,
price: newPrice,
});
const result = await stripe.redirectToCheckout({
sessionId: checkoutSession.data.id,
});
if (!session) {
alert("Please sign in");
}

if (session) {
const stripe = await stripePromise;
const newPrice = parseInt(price.slice(1, -1)) * 101;
const checkoutSession = await axios.post("/api/create-checkout-session", {
img: img,
title: title,
description: description,
price: newPrice,
});
const result = await stripe.redirectToCheckout({
sessionId: checkoutSession.data.id,
});

if (result.error) {
alert(result.error.message);
if (result.error) {
alert(result.error.message);
}
}
};

Expand Down Expand Up @@ -95,7 +101,9 @@ const InfoCard = ({
<StarIcon className="h-5 text-red-400" /> {star}
</p>
<div className="flex flex-col justify-end -mt-2">
<p className="text-right lg:text-2xl font-semibold pb-2 pr-4">{price}</p>
<p className="text-right lg:text-2xl font-semibold pb-2 pr-4">
{price}
</p>
<p className="text-right font-extralight">{total}</p>
{items.length > 0 ? (
<>
Expand Down

0 comments on commit 795c87c

Please sign in to comment.