John Davidson

php - Laravel Stripe Checkout Workflow

0 comments
Message:


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:



  1. Client wants to pay with stripe

  2. Client sends XHR request to application server (Laravel)

  3. The server generates a Stripe payment intent with the Stripe Key.

  4. Stripe sends back a key.

  5. The server passes this key on to the client.

  6. Stripe JS is loaded (https://js.stripe.com/v3/)

  7. Stripe JS renders a payment form (credit card number etc).

  8. The client enters his credit card details.

  9. The client then clicks on "pay".

  10. Stripe receives the client's credit card information along with the Stripe Payment Intent Key.

  11. If the data is correct, the payment process is successfully completed at Stripe.

  12. Stripe sends back the payment status information to the client as a response.

  13. This information will then be sent from the client to the server.

  14. 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 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us