#one-love_code
1 messages ¡ Page 1 of 1 (latest)
đ 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.
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.
- one-love_best-practices, 2 days ago, 5 messages
- one-love_unexpected, 2 days ago, 24 messages
- one-love_api, 3 days ago, 16 messages
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
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.
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
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.
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
can you show me how line_items accepts the array?
What do you mean
It would be one line of code, think. Can you type an example. session::create(line_item = array) etc.
Typo I think
$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
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?
I wouldn't rely on the return url being reached to store data. Network issues happen, browser crashes happen, customer might exit page accidentally, etc. That's why we recommend webhooks: https://docs.stripe.com/payments/checkout/fulfill-orders
Okay, thanks. Have a great day.