Shopping Cart: Am I ready for payment gateway?

I have a table called order_lines where each line of the order gets inserted to and references the order id. I then do a SUM server side of all of the order lines to calculate the total price which gets sent to Stripe. How do you have your DB setup?

I don’t have any DB set up for it other than my products list.

I was hoping to not have to store anything. Just send the user and myself an email with the order details.

Ok, so this is a simplified version of what I have that you could get away with:

Table: order
order_id
order_datetime
user (identity)
stripe_payment_intent
paid (boolean)

Table: order_lines
order_id
product_id
qty
price_each

Realistically you will need to store some of the information in a database to perform the server side actions easily.

Edit: You could use Stripe to store most of this using their Products feature but then you would need to pull this data back anyway from Stripe.

1 Like

OMG, I’m screwed. I fell so stupid right about now. I don’t even know where to start or what questions to ask. I only have five more days to figure out if I can do this before I have to turn down the project.

I so appreciate your help, @max_gb. Wish I could be more help to you to help me.

1 Like

I thought that when I started the ticket cart project but it’s actually not too bad once you get your head around it. Feel free to PM if you get stuck

1 Like

I’m stuck right at the beginning. What exactly am I querying? What do I include in the query? Where am I getting this query from?

@brad, I didn’t want to add to your woes, but I feel that this requires your attentionL

Yeah I’m aware of that. In our case none of our clientele is that savvy. We are a small city and I pretty much know 90% of the ticket purchasers personally. It is a valid point though that others should be aware of.

1 Like

That’s why you use the values from the local storage to only show the info to the users.
You don’t use this value in the checkout process, as for the checkout you get the info from a database query and send it to the payment API in a server action.

1 Like

This query is for the product and price. That’s why you need to do a SUM server side to avoid people from tampering with the price on the browser console.

3 Likes

This is what @ben and @max_gb are referring to:

That’s what is missing in the tutorial … maybe it should be in both tutorials. What database and what query? According to the shopping cart tutorial there is no mention of a database. Then in Max’s tutorial it starts off with saying my query may be different than his. There is nothing to query! Nothing has been added to a database. How and what does data get added to a database?

The only data table I have is the products.

If someone can just fill in that gap I could possibly move on with Max’s tutorial. I really want that to work.

Well it’s the same table Brad… Just query it before sending the data to the API.
My tutorial only shows how to build your shopping cart functionality, not the checkout.

Query it for what? What info am I trying to get on this query? Can someone supply a sample of this query, maybe that will help understand what this query is to achieve?

I know your tutorial doesn’t explain the check out and Max’s doesn’t explain the cart part. There seems to be a big chunk of information missing on how to get from yours to Max’s.

Brad,
You get the product IDs and the quantity from the local storage and send them to your server action and filter the database query (your product tables) to return the price(s). You use these results in the checkout API :slight_smile:

Ok, let me take a breathe here. Here is my data from my products and my local storage from my cart.

1: Do I have everything I need?
2: What would this query look like?

Yes.
Send your ticket id and quantity to the query - use them as filters.

1 Like

Ok, how do I include quantity in the query? There is no field for quantity?

You send the id to the query, return the id and price and then use the quantity for the calculations for your API checkout :slight_smile:

1 Like

Am I querying the data store or the products table? There is no quantity in the products table?

Sorry, that I am just not getting it. I do appreciate your help and patience.

i am sure if someone can just get me pointed in the right direction with this query the rest of the tutorial will make sense.