I have a small question about the Stripe workflow and there is one area in particular where I would like to know your opinion and experience. My setup is: Laravel 8 and "stripe/stripe-php": "^7.97"
.
The workflow as I understand it:
- Client wants to pay with stripe
- Client sends XHR request to application server (Laravel)
- The server generates a Stripe payment intent with the Stripe Key.
- Stripe sends back a key.
- The server passes this key on to the client.
- Stripe JS is loaded (https://js.stripe.com/v3/)
- Stripe JS renders a payment form (credit card number etc).
- The client enters his credit card details.
- The client then clicks on "pay".
- Stripe receives the client's credit card information along with the Stripe Payment Intent Key.
- If the data is correct, the payment process is successfully completed at Stripe.
- Stripe sends back the payment status information to the client as a response.
- This information will then be sent from the client to the server.
- The server can mark the order as completed.
My questions:
a) Have I understood the workflow correctly?
b) Would you already store the order in the database at the payment intention (Point 3.) or only at the last point (Point 14.)?
My Answer:
a) Yes, you have understood the workflow correctly. The steps you have outlined are the typical flow of a Stripe checkout process.
b) It is a good practice to store the order in the database at the payment intention (Point 3). This way, you have a record of the order even before the payment is completed. This can be useful for tracking purposes and for handling any potential issues that may arise during the payment process. Storing the order at this point also allows you to easily retrieve the order details if needed, even if the payment is not completed successfully.
Rate this post
3 of 5 based on 5856 votesComments