#one-love_code

1 messages ¡ Page 1 of 1 (latest)

odd heartBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1215762186484453387

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

fresh lilyBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

strange umbra
#

That depends how you store the data. You could loop over the items you get back from your database to build a list of line_items and store it to a variable, for example. Then pass that in to the line_items param when creating a checkout session

rustic cliff
#

So I'm clear, you are saying add them to an array, and pass the list/array once? Is there a an example ot this on the website? I was unable to locate an example.

strange umbra
#

No example

#

But building an array is a basic operation. You can google how to do it in your language of choice if you don't know how

#

line_items accepts an array. so just pass one in

rustic cliff
#

Can you give me a one line example of how a the list would be passed to session::create() lineitems instead to the individual insertion in the example.

strange umbra
#

instead of ```[
[
"quantity" => 1,
"price_data" => [
"currency" => "usd",
"unit_amount" => 2000,
"product_data" => [
"name" => "T-shirt"
]
]
],

you'd just pass the variable name of the array
rustic cliff
#

can you show me how line_items accepts the array?

strange umbra
#

What do you mean

rustic cliff
#

It would be one line of code, think. Can you type an example. session::create(line_item = array) etc.

#

Typo I think

strange umbra
#

$stripe->checkout->sessions->create([
'success_url' => 'https://example.com/success',
'line_items' => $line_items,
'mode' => 'payment',
]);

#

where $line_items is the array you build

#

follows the same format as the array you pasted in the question

rustic cliff
#

Thank you so much. I'm a newby with working with payment gateways. I appreciate your help.

#

One more question. Is it possible to obtain the customers input, after the customer is sent back to my success page. For database storage, with info in the return url?

strange umbra
rustic cliff
#

Okay, thanks. Have a great day.