I am building an app to sell single item product (i.e, each kind of products listed on my platform only has a single item).
- (this part has been done, and won't change) I built an in-house backend having the Rest API
POST -D {"buyer_email": "[email protected]"} url/items/{itemID}
, let's call ittransaction_call
, which will make sure once a customer succeed the POST operation, his contact info is recorded into my backend as the successful buyer; and all other customers will fail to buy that item (at API level,transaction_call
return 4xx error) because my platform can only sell one item for that product; - (this is the step that my current question is about) I am trying to use Stripe as my payment system on this platform.
I really want to integrate with Stripe as simple as possible (as I understand Stripe Checkout is the most simple / out-of-box way to implement payment). However, I am not sure if Stripe Checkout can achieve the above functionality correctly. Since the problem is a two-step problem, here is the potential issue I may run into:
Let's say, two customers
A
,B
, get to my platform at 10:00am, both of them start purchasing process for a product,Item_a
If my system interact / call the Stripe Checkout first as the first step then call the
transaction_call
, here could be the problem:A
's Stripe call hits the Stripe server at 10:00:01am, and A's buying call hits my backend at 10:00:02am;B
's Stripe call hits the Stripe server at 10:00:01am, and A's buying call hits my backend at 10:00:03am;- in this way, we have already charged
B
but he really did not get the item
If my system calls the
transaction_call
first, and only iftransaction call
succeeds then it interacts / calls the Stripe Checkout, then- A's
transaction_call
succeed at 10:00:01am, but he for some reason decided not to pay (not click confirm button on the Stripe Checkout UI) - In this way, my system fails to sell the item to other buyers.
- A's
My question is whether the above reasoning process is correct, and whether I could somehow use Stripe Checkout to achieve what I am doing.
Maybe I have implement the payment functionality using Stripe Intent API to build a workflow-based payment, which I assume will be much more complex, if the Stripe Checkout way (simple wayO is really not possible.