Maik Lowrey
Maik Lowrey

Reputation: 17556

Laravel Stripe Checkout Workflow

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.)?

Upvotes: 1

Views: 674

Answers (1)

orakaro
orakaro

Reputation: 1971

a) Your understanding is correct. But for Step 13 and 14 you would want to use Webhook to complete your order on Server instead. More intuitive guide is on Stripe's official document. enter image description here

b) On Point 3 you can create an order but need to mark its status something like uncompleted. On Point 14 you can mark it completed and start providing your service. The reason is the customer can drop off between (ie not providing Card detail and simply close the browser).

Upvotes: 1

Related Questions