laracolada's avatar

Checkout Steps - Laravel Ecommerce APP

i am currently making an ecommerce application using laravel. I want to know the best way to tackle the following problem: I have a 3 Step Process for Checkout: Login- Select Address - Select Payment

How would you configure your routes for this process? Currently i am using a checkout controller with three routes named as such: get - step1 , post -step2 , post-step 3.

for some reason i think this is not the perfect way to handle this problem. It would be great if you share some of your ideas!

0 likes
4 replies
thepsion5's avatar

There would presumably be six different routes - a get and post request for each step. I'd probably name them something like this:

URL                | Method | Action
/login             | GET    | SessionController@create() //displays login form
/login             | POST   | SessionController@store() //processes login
/checkout/shipping | GET    | CheckoutController@getShippingInfo()  //display shipping form
/checkout/shipping | POST   | CheckoutController@processShippingInfo() //validates shipping address
/checkout/payment  | GET    | CheckoutController@getPaymentInfo //displays payment form
/checkout/payment  | POST   | CheckoutController@processPaymentInfo //validates and processes payment
/checkout/receipt  | GET    | CheckoutController@showReceipt //display a confirmation for the purchase

Route #2 will redirect to Route #3 if the login as successful. Route #4 will redirect to Route #5 if the shipping information is validated. And #6 will redirect to #7 if the payment was processed successfully.

1 like
RayRutjes's avatar

@thepsion5 why name it 'processShippingInfo' when you actually 'validateShippingInfo' ? Why 'getPaymentInfo' when you 'showPaymentInfo' ? You should pick a naming convention and stick with it.

thepsion5's avatar

getPaymentInfo makes more sense to me since we're not displaying info the system already has, we're asking the customer to give it to us. With shipping, i don't know if anything other than validation has to happen (for example, I worked with an e-commerce system that would work with an external API to get the "final" shipping price) so I just went with process. You're right though, that could be named better - maybe something like displayPaymentForm and processPayment or something.

Please or to participate in this conversation.