#Mijelz-payment-intent

1 messages ยท Page 1 of 1 (latest)

pallid girder
#

๐Ÿ‘‹ Happy to help

rich yoke
#

Hi River

pallid girder
#

How do you collect payment method details currently?

rich yoke
#

Hey actually I havent started yet, I've just been watching guide and reading the docs

#

Im running firebase cloud functions for my backend so thats basically my 'server'

#

where I create the PI and stuff I assume

#

Im using elements

#

react elements

#

Maybe to make it clearer idk if this is possible but I would like it so that when the customer hits "pay" or w/e, it hits my backend that handles talking to stripe and then if stripe says "ok the card was charged its all good" then I can within that same API function write to the DB (fulfilling the order). Returns response to my frontend that I can deal with, as long as I can confirm the card was charged in my api call.

#

If it fails I can return to my frontend the error message and handle the UI

last pendant
#

We generally don't recommend synchronous fulfilment/post-payment actions like that

#

Instead, you should rely on webhooks

rich yoke
#

I can rely on webhooks, I'd just have to setup a cronjob to clear out abandoned purchases

#

Is it not possible to do synchronous with stripe though?

#

It makes it a lot easier for me to build out the frontend if I can just hit one endpoint and get a response than wait on a webhook

last pendant
rich yoke
#

I see, but I don't think I have any reason for the user to stay on session. Once the purchase is confirmed within that same function I can write to the DB fulfilling the order. Do you have a guide somewhere I can see how to do it sync?

last pendant
#

You mentioned front-end, maybe I misinterpreted what you meant

#

How do you intend to handle 3DS?

rich yoke
#

I wanna use the PaymentElement, or if I can't the CardElement

#

so I think stripe will put the modal for me and handle it

#

As far as I understand I need to create a PI on my server -> sends that to frontend to stripe elements -> user clicks pay and then ... idk im lost after that

last pendant
#

Right, so that's front-end confirmation. I'm confused how your backend is performing confirmation in this instance

rich yoke
#

Oh I dont know lol

#

I am very new to stripe

last pendant
#

At that point they've paid, but your application has no knowledge of it

rich yoke
#

Oh I see I thought it was possible to just send the entire request to my backend

last pendant
#

Instead you'd rely on payment_intent.succeeded events and action them

last pendant
rich yoke
#

So in that case I have to do webhooks and I would just write like the documentID in the dbase in the metadata field somewhere? I assume the webhook can send that to me so I know which to set "fullyPaid:true"

last pendant
#

But I don't think its necessary in your use case

#

And we still recommend webhooks for fulfilment

last pendant
rich yoke
#

That works, I'd just have to save the data to the db in an 'unpaid' state. The best idea I have to just run a cron weekly and anything older than X date gets deleted.

#

Which part do I add the metadata to, the PI right?

last pendant
last pendant
rich yoke
#

Ahh I should just explain a bit its not the PI its the thing we sell

#

We sell certificates for like continuing edu etc

#

so I have to save on that certificate that its unpaid and when the webhook returns 'paid' I flip the state and then can show it to the customer

#

thats ok tho its nbd

#

I'd make a call to save the data in the form submit handler for the Elements

last pendant
#

Got it

rich yoke
#

ty I will review this and hopefully get it integrated

last pendant
#

np!