#Naitik

1 messages · Page 1 of 1 (latest)

sick dawnBOT
molten flame
#

Hello! Can you give me more details? Are you trying to create a payment intent?

river mulch
#

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?

molten flame
#

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

river mulch
#

I am using payment intent and the payment succeeds successfully but I have stored the product item as well how can I do it?

molten flame
#

Payment intents aren't tied to products/prices at all - it's somethign you'd need to store on your end

river mulch
#

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

molten flame
#

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)

river mulch
#

how can I store in my self?

molten flame
#

you'd have your own database where you store it, or you could add it to metadata on the payment intent

river mulch
#

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 ?

molten flame
#

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

river mulch
#

I can't store in meta data as well.

#

can you please guide me with details of invoice?

#

what is the steps and API i need to use?