Pass Order ID to Stripe Checkout

I have an orders table and an orders detail table. I am using Stripe as the payment processor and using the Wappler App Connect Stripe Checkout.

I had initially had one server action that handled the insert into the orders table and order details table based on the datastore then completed the Stripe Checkout, then update the orders table with the payment intent. After payment was completed, I use the Webhooks to retrieve the order based on the payment intent and then update the orders table to show the order was completed.

An issue arose when doing it in this manner as discussed here.

So, I went back to the drawing board and re-thought the logic. I separated the insertion of the orders into the orders table into a separate server action. So, when the form containing the basic information is submitted, it submits to the orders table. Upon success, the form then fires off the Stripe Checkout using a different server action. The Stripe Checkout server action needs to update the order details with various data, but to do so, it needs the order id.

So, how do I pass the order id to the Stripe Checkout?

What I tried doing was setting a value on the orders sever action and passing it back to the page. The output works as intended. I then set a variable on the page to capture that output. I then added an order_id to the datastore since Stripe Checkout seems to only accept entries via Line Items.

The issue is that I am not sure how to properly connect the variable to the datastore. This is what it looks like when I try through an upsert.

However, this is not working correctly because it is not properly adding the order id to the existing prd id.

If this is the proper way of passing an order id to Stripe Checkout, what do I need to change to make it work?

If this is not the proper way of doing it, what is the best route to go?

I reviewed several topics, including this topic, but it does not seem to be quite on point because it appears to be using a form method and not the Stripe Checkout component.

Thanks.

pass the id to local storage? easy peazy!

Not for me, unless I am missing something.

As I mentioned above, the form returns the order id and appears in the Network tab.

Screenshot 2024-03-04 at 11.09.36 AM

I then set a variable on the page to hold the value of the returned order id.

Screenshot 2024-03-04 at 11.12.22 AM

I set the upset in the datastore with the variable containing the order id.

The result is the datastore shows a NULL value.

In addition parts of the page become invalid by doing this and an empty row is inserted into the table containing the datastore information.

Ok, I have made progress. However, the order # is only showing for the first product.

How can I get the order # to update for all products in the cart?

After that, I will need assistance on how to get the order # in the server action.

do you need to do a repeat region and repeat all the items in the cart and update them each?