#gmgarrison_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/1324741210245431410
๐ 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.
- gmgarrison_webhooks, 22 hours ago, 24 messages
This is the entire method where I'm creating the Checkout session on the server:
$checkoutSession = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card', 'amazon_pay', 'link', 'us_bank_account'],
'line_items' => [[
'price_data' => [
'currency' => 'usd',
'product_data' => [
'name' => $title,
'description' => $refundPolicy,
],
'unit_amount' => $payment->amount * 100, // Convert to cents
],
'quantity' => 1,
]],
'metadata' => [
'payment_id' => $payment->id,
'product_id' => $payment->getRawOriginal('product_id'),
],
'customer_email' => Auth::user()->email,
'mode' => 'payment',
'success_url' => route('payThankyou', ['payment' => $payment->id]),
'cancel_url' => route('home'),
]);
This is the intent that was created but without any metadata: pi_3QdBUJH1Z1K59F9K0U7kuUVK
๐ happy to help
You guys are always the best ๐
I'm listening to payment_intent.succeeded, charge.suceeded, payment_intent.pending, and a few others
if you want to have the metadata available on the PaymentIntent you need to set it indirectly https://docs.stripe.com/metadata#set-indirectly
I'm not 100% what that means
In my code, I'm creating a "session" - is that different than creating a payment intent?
Or that's just a subset of data that can be passed to a session?
yes
I was following the documentation here: https://docs.stripe.com/api/checkout/sessions/create. But that's not what I should be doing evidently?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
if you want to pass the metadata to the PaymentIntent you need to use payment_intent_data.metadata instead of metadata which stores the metdata on the checkout session level
Where would i retrieve session level data? If I had the payment_intent ID is the session accessible from taht?
Where would i retrieve session level data?
checkout.session.completedevent
Oooh
I guess I did not really understand how Checkout works. A session is not at all the same thing as a payment_intent?
I had been using Stripe Elements before and was trying to replicate the workflow I had with that
A session is not at all the same thing as a payment_intent?
no a Checkout Session is basically either a hosted or embedded Stripe Page that we generate for you
Stripe Elements can work with Checkout Sessions (but it's in a private beta now)
Alright... it's starting to clear up. So right now, I do not listen for the checkout.session.completed events and that's where my metadata is. But is it possible to put metadata into the charge or payment_intent events from the server when I create the session?
I just tried this but it did not work:
'payment_intent_data.metadata' => [
'payment_id' => $payment->id,
'product_id' => $payment->getRawOriginal('product_id'),
],
'payment_intent_data' => [metadata' => [ ....]]
Okay gotcha - lemme test that real quick
BINGO ๐
And I've learned something
Thanks for your help!!
no worries, let me know if you need any more help
Have a great Friday
thanks you too