#Naitik
1 messages · Page 1 of 1 (latest)
Hello! Can you give me more details? Are you trying to create a payment intent?
Yes I want to create a payment intent.
const generatePriceData = (product: any) => {
return {
price_data: {
currency: "usd",
unit_amount: product?.prices?.unit_amount,
product: product.id,
},
quantity: 1,
};
};
const responses = products.map(generatePriceData);
const paymentIntent = await stripeClient.paymentIntents.create({
customer: customerId,
amount: amount,
currency: 'usd',
});
const result = await stripeClient.paymentIntents.confirm(
paymentIntent.id,
{payment_method: cardId}
);
can you please check this is the correct?
It's really hard to tell whether code is correct just by spot-checking it - best way for you to confirm it's correct is really by running the code
Generally it looks correct to me, but you haven't included where you're setting amount so it's hard to tell
I am using payment intent and the payment succeeds successfully but I have stored the product item as well how can I do it?
Payment intents aren't tied to products/prices at all - it's somethign you'd need to store on your end
this is the code. it's working fine.
It's checkout session. Here I am able to attach line items.
same line items I want to add in payment intent API
Checkout Session is different than line items though - Checkout Sessions has the concept of line items but payment intents do not
If you want your payment intents to have line items it's something you need to store yourself or you need to switch to using somethign else that has line items (like invoices or checkout)
how can I store in my self?
you'd have your own database where you store it, or you could add it to metadata on the payment intent
If any user makes a payment for an item then in the admin side in stripe dashboard they should see what item they have paid for.
I am not able to store in my database do you have any other way in which I can add item intent with payment using card ?
I already mentioned other alternatives - you could move onto using Invoices (which does line items) or you could include the prices/products to metadata on the PaymentIntent