C
C#15mo ago
linqisnice

❔ Need some help with payment processing and stripe

So... to my understanding, it's quite important to reserve/create the purchase before charging the customer since it's trivial to undo a purchase but not so to refund the customer. How is this usually done, though? Let's say I have a CreateReservation endpoint (think airbnb)... 1. Do I do all the payment processing inside this endpoint?
I don't like this because teh endpoint is already big, and there are multiple different payment options and methods so there's a lot of code and potentially "different" responses
2. Do I create a separate endpoint for PaymentProcessing and make a chain call to a separate PaymentProcessing endpoint in react after CreateReservation is successful and return the reservation Id?.
This seems unsafe, I'm not sure how to guarantee that the id isnt manipulated. Or maybe i should pass a secure token here?
3. Do I create a mediatr handler to process payment and call it from witihn the CreateReservation endpoint after creating hte reservation? There are some issues here that make it rather unintuitive for me... not the least klarna integrated with stripe, since the confirmation is actually done on teh frontend and then there is no guarantee that the user will go trhrough with the paymentintent. My solution for this is to delete all reservations and related intents if the payment status is not status "succeeded" (or with bank transfer and klarna pay later either "processing" or "requires_capture") within 10 minutes. Byt this seems like way too much work for one endpoint, but also a public facing payment endpoint with a reservationid passed in doesn't seem that great from a security perspective so the last option seems to me the safest and most logical. or none of the above and i should approach this differently Bonus question: Do i separate the endpoints/handlers for the different payment options (klarna, bank transfer, card)?
1 Reply
Accord
Accord15mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.