Skip to content

Commit

Permalink
checks and fixed checkout, need apikey to test
Browse files Browse the repository at this point in the history
  • Loading branch information
Aifert committed Mar 11, 2024
1 parent ffc8219 commit c62b210
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/pages/api/checkout_sessions/checkout_session.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NextApiRequest, NextApiResponse } from "next";
import Stripe from "stripe";

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
const stripe = new Stripe("pk_test_L1f0e3XAzjsG7jtp4uN7L9ql", {
apiVersion: "2023-10-16"
});

Expand Down
20 changes: 12 additions & 8 deletions src/pages/donation/donation-stripe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default function DonationStripe() {

const amountInCents = Math.round(formatAmount * 100);

handleCheckout({ amountInCents, interval});
handleCheckout({ amountInCents, interval });
};

return (
Expand Down Expand Up @@ -234,22 +234,26 @@ export default function DonationStripe() {
);
}

const handleCheckout = async ({ amountInCents, interval }: { amountInCents: number, interval: string }) => {
const handleCheckout = async ({
amountInCents,
interval
}: {
amountInCents: number;
interval: string;
}) => {
// Load the Stripe library with the publishable key
const stripe = await loadStripe(
process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY!
);
const stripe = await loadStripe("pk_test_L1f0e3XAzjsG7jtp4uN7L9ql");

// Make a POST request to the '/api/checkout_sessions' endpoint
const response = await fetch("/api/checkout_sessions/checkout_session", {
method: "POST",
body: JSON.stringify({
amountInCents: amountInCents,
interval : interval
interval: interval
}),
headers: {
"Content-Type": "application/json",
},
"Content-Type": "application/json"
}
});
console.log(response);

Expand Down

0 comments on commit c62b210

Please sign in to comment.