Shopping cart with checkout in angular JS

359 views
Skip to first unread message

R tget

unread,
Aug 19, 2014, 3:21:54 PM8/19/14
to ang...@googlegroups.com
Hi im building a shopping cart now on checkout im using external payment modules. so its get redirected to another site for example paypal and then come back for a thank you page.

but if a user selects a payment method and goes back, al the angular data is gone, cart is empty etc. what is the best way to handle this?

Eric Eslinger

unread,
Aug 19, 2014, 6:35:39 PM8/19/14
to ang...@googlegroups.com
You'll probably need to handle this in the typical fashion - store user session data in a session variable, either a session cookie, or stashed in a session store on your backend.

e


On Tue, Aug 19, 2014 at 12:21 PM, R tget <r2g...@gmail.com> wrote:
Hi im building a shopping cart now on checkout im using external payment modules. so its get redirected to another site for example paypal and then come back for a thank you page.

but if a user selects a payment method and goes back, al the angular data is gone, cart is empty etc. what is the best way to handle this?

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

R tget

unread,
Aug 20, 2014, 7:05:39 AM8/20/14
to ang...@googlegroups.com
Yes, but in angular is there a way to get a unique session variable for a user? so that i can store this in the DB and if this user comes back he automaticly gets this ID ?

Because im working with API... but everytime i call for a session id (php) it gives a new id...

Op woensdag 20 augustus 2014 00:35:39 UTC+2 schreef Eric Eslinger:

Eric Eslinger

unread,
Aug 20, 2014, 11:32:20 AM8/20/14
to ang...@googlegroups.com
This isn't really an angular issue as much as it is a general web-application design issue. But you can do something like set a cookie on the browser with session information, which will persist between connections. Then when the angular app starts up, have it check to see if there's a session cookie and get your state from there.

Of course, cookies (and sessions in general) have all sorts of security considerations, so if you're actually designing a real ecommerce site (and not working through a tutorial), I'll *strongly* recommend you hire someone who has done this before and get them to help. There's a lot of gotchas that can lead to losing client data, bleeding personal information to attackers, or just having plain old corrupted payment records so you can't tell who actually paid for their products and who faked a PayPal callback. 

e

R tget

unread,
Aug 20, 2014, 6:41:58 PM8/20/14
to ang...@googlegroups.com
Well,, the checkout page will post to my api (PHP) from there I will handle all the data... check the payments etc so that will not be a problem... I only need a variable in angular that will stay the same for a session of a user. session_id() in php creates a session id that will stay if its not unset so if the user leaves the page and come back it will be the same.

I just need such a var in angular.. that i can post trough my api and store it.. if the user closes the page and opens it again it must generate this same id in angular.. so I can match it with my DB.... i dont know what methods are availible in angular for this

Op woensdag 20 augustus 2014 17:32:20 UTC+2 schreef Eric Eslinger:
Reply all
Reply to author
Forward
0 new messages