#Elena - Payments
1 messages · Page 1 of 1 (latest)
karbi suggested to first make paymentintent uncaptured
and then capture it say after i create the document
but im not able to capture the paymentintent, when i pass the paymentintent ```js
const intent = await stripe.paymentIntents.capture('pi_ANipwO3zNfjeWODtRPIg')
Hello! Taking a step back, I'm not sure I completely understand exactly what you want to do. Can you outline the ideal steps in your payment flow without worrying about any existing constraints? Then I can help you build that or get as close as possible.
Current payment flow
1. initalize a payment intent
2. User inputs his card details. I have my own payment card, not hosted
3. I finalize the payment intent, and create a document in database
I want to change step 3. Where I uncapture the payment (so i know it could be successfully payed), then create document in database, and then capture the payment
I basically just dont want to take payment before the document in database is created
Okay, so like this?
- Create a Payment Intent
- Customer provides card info
- You use the Payment Intent to place a hold on funds
- You create the document in your database
- You capture the funds you placed on hold
yes that is what i want
I managed to make the payment intent uncaptured, and then i sent the paymentintent to frontend. when user inputs card info and click "pay", i send the paymentintent to backend and then i try to capture the paymentintent, but it doesnt capture it. When i goto dashboard its not captured
For reference, here's the guide to placing a hold on a card: https://stripe.com/docs/payments/capture-later
What you need to do is create the Payment Intent with capture_method set to manual, then confirm the Payment Intent (which places a hold on the funds), then you can actually capture the funds using this API: https://stripe.com/docs/api/payment_intents/capture
I did this ```js
-
created a paymentintent with capture_method: manual.
-
sent this paymentintent to client.
-
When user click pay, i send a request to a route to create a document in database. With this request i send the paymentintent
-
I try to use this code to capture payment intent
console.log("paymentIntent", paymentIntent)
const intent = await stripe.paymentIntents.capture(paymentintent)
@vivid portal
Can you give me the ID of that Payment Intent?
You can get it from the Dashboard.
Ah, yes, amount is required. 🙂
i thought it was not required. it would take the whole amount if not specified
The total authorized amount is captured by default—you can’t capture more than this. To capture less than the initial amount, pass the amount_to_capture option. Partially capturing automatically releases the remaining amount.
no actually docs says that u dont need to specify
by default it captures everything