Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proper way to handle customer delays in stripe payment gateway

I have a question to ask about payment strategy with Stripe Checkout API. consider following scenario

  1. A vendor published 10 products(apples) for 5$ each in a marketplace
  2. A customer wants to buy 8 of them, and he fill the details and click checkout button ( stripe checkout page comes)
  3. But customer waits idle for 1 hr without completing the payment ( just looking at the UI)
  4. Mean while someone else buy all 10 apples
  5. first customer doesn't know about that because he is already in final payment page.
  6. And he pays 40 $ for 8 apples
  7. Transaction is fault because no apples left to deliver.

I am trying to integrate Stripe payment gateway to my marketplace platform and I could not find a solution for this kind of scenario.

Is there any feature in Stripe to handle this ? Like session timeout period ? Or What is the standard way to handle this ?

Appreciate your help.

like image 782
Achira Shamal Avatar asked Oct 30 '19 15:10

Achira Shamal


People also ask

Can you delay payments on Stripe?

With Stripe, delayed payments are enabled by default. This has a few effects: it is not possible for buyers to select an end date that is more than 85 days in the future in an availability listing using one of the calendars. funds can't be held for longer than 90 days.

Why do Stripe payments take so long?

This waiting period can be up to 14 days for businesses in certain industries. This delay allows Stripe to mitigate some of the risks inherent in providing credit services. You can confirm your payout schedule and estimated payout timing in your Dashboard.

How would you improve Stripe payments?

There are three ways you can increase authorization rates with Stripe: Adaptive Acceptance, Smart Retries, and card account updater.


1 Answers

I don't know if this is still relevant!

But I had the same problem before. What I did is I start managing the sessions from the application side. So I have a stripe sessions table and I have a timeout, and status of the session. Also, I have a purchase table with a status that could be pending if the user didn't pay yet. So I can update the items counts in the real store.

This is the scenario I have implemented. It might help you or anyone who is thinking of this problem. Maybe there is a more perfect scenario but this works for me :v:

  1. User presses on pay

  2. The application makes a POST request to your application create session endpoint, with all needed information

  3. In the backend, check if this user has an active session with the same information, if yes just redirect him to that active session id. If no just create another stripe session, record its info in your database and redirect the user to the new session id

  4. Then add a purchase record with the amount/quantity the user is attempting to get (with status = pending) and the session id you have. Then update the items page and subtract this quantity...

  5. Create a webhook with that session id. So you can know if it is done or not (you have to have an endpoint that accepts session ids)

  6. You check your active sessions periodically (cronjob) if a session is too old (like one hour) you just delete it and delete the pending purchase then update the items count in your store back to the actual count.

  7. And when stripe calls your webhook with the required events, you can now set the session status and purchase status to done (Don't forget to check the call signature for more security)

I hope this will help you.

like image 67
HSLM Avatar answered Oct 05 '22 05:10

HSLM