I'm using the custom checkout flow from stripe to add online payment to my website which uses a server endpoint to create the PaymentIntent
like so:
app.post("/create-payment-intent", async (req, res) => {
const { items } = req.body;
// Create a PaymentIntent with the order amount and currency
const paymentIntent = await stripe.paymentIntents.create({
amount: 499,
currency: "usd"
});
res.send({
clientSecret: paymentIntent.client_secret
});
});
I was wondering, instead of setting the price and currency directly in the PaymentIntent
, could that come from a Product
created on Stripe? I understand that I can just fo it myself and fetch the associated Product
and Price
from the API and create my PaymentIntent
from that but then Stripe will have no way to "track" that this payment was made for this product (useful for analytics).
I know that this is possible to do with Checkout
where a product can be associated with it. But I couldn't find anything for a custom checkout flow.
Cheers!
question from:
https://stackoverflow.com/questions/65917042/link-paymentintent-to-a-product 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…