#jesse_p

1 messages · Page 1 of 1 (latest)

brave crowBOT
sinful thicket
#

Hi @sour patrol - creating a thread for us here

sour patrol
#

Great!

sinful thicket
sour patrol
#

I followed the quick start tutorial for a nextjs project that I'm working on. When the user selects the "pay" button, a new payment intent is created and the payment intent client secret is sent to the front end. Is there a way to check that an existing payment intent already exists based on certain criteria?

sinful thicket
#

Can you elaborate on the last bit of the question please? *Is there a way to check that an existing payment intent already exists based on certain criteria? *

sour patrol
#

I'm building a checkout process where a user logs into my application to view their invoices. If they select an invoice and click the "Pay" button, the checkout form gets rendered.

#

When the checkout form gets rendered, it creates a payment intent.

#

So if they leave the invoice page and select the invoice again (lets say 10 times), it creates 10 payment intents

#

So I'm wondering if that's OK, or if when a payment intent gets generated the first time, I should store the paymentintent.clientsecret in my database

#

Hopefully that makes sense

sinful thicket
#

It does, you would not want to store or log. It's ok to have these Payment Intents but it's a concern to you, you can cancel them via the API.

sour patrol
#

I'm just not sure how to cancel them if I don't have a client secret

#

For example, if that user that goes and clicks the "pay" button on one of the invoices, the client secret doesn't get created until they click "pay"

#

So I wouldn't be able to use the API to delete an old one

#

Unless I created some kind of cron job

sinful thicket
sour patrol
#

This shows a bunch of incompletes because I have been testing

sinful thicket
#

Are Payment Intent ids not created for these? They'd look something like this: pi_1abc234. These are fine but if you want to cancel them you can.

sour patrol
#

No, payment intents are being created. In the request object that gets sent to the API, I changed the description to be an invoice number instead of the payment intent id

#

When I select a payment, I can see the id in the url

sinful thicket
#

Yeah, having 'Incomplete' Payment Intents, are fine. Do you have particular concerns over them?

sour patrol
#

No concerns

#

Well, initially I did lol

#

I think it would be a rare occasion for a user to refresh the page, select the "Pay" button a bunch of times

#

But if it's OK to have incomplete intents, that is fine with me. Just wanted to make sure I wasn't doing anything wrong.

#

Thanks for the help

sinful thicket
#

Sure!