I have hardcoded a price into my Next.js using Stripe test project but would like the amount paid to change upon submission from an input. I am specifically wondering how I pass along that data in the paymentIntent function I wrote:
//In Checkout.js
try {
const {
error,
paymentIntent: { status },
} = await stripe.confirmCardPayment(paymentIntent.client_secret, {
payment_method: {
card: elements.getElement(CardElement),
amount: myAmountVariable //trying to pass
},
});
//In payment.js:
paymentIntent = await stripe.paymentIntents.create({
amount,
currency: "usd"
});
return {
props: {
paymentIntent,
},
};
};
const CheckoutPage = ({ paymentIntent }) => (
<Elements stripe={stripePromise}>
<CheckoutForm paymentIntent={paymentIntent} />
</Elements>
);
The above code, where I am attempting to pass in 'amount' gives me the error "Amount is not defined"