#gmgarrison_code

1 messages ยท Page 1 of 1 (latest)

icy pathBOT
#

๐Ÿ‘‹ 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.

primal helm
#

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

hard summit
#

๐Ÿ‘‹ happy to help

primal helm
#

You guys are always the best ๐Ÿ™‚

hard summit
#

thanks ๐Ÿ™‚

#

what event are you listening to?

primal helm
#

I'm listening to payment_intent.succeeded, charge.suceeded, payment_intent.pending, and a few others

hard summit
primal helm
#

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?

primal helm
hard summit
#

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

primal helm
#

Where would i retrieve session level data? If I had the payment_intent ID is the session accessible from taht?

hard summit
#

Where would i retrieve session level data?
checkout.session.completed event

primal helm
#

Oooh

hard summit
primal helm
#

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

hard summit
#

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)

primal helm
#

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'),
],

hard summit
#

'payment_intent_data' => [metadata' => [ ....]]

primal helm
#

Okay gotcha - lemme test that real quick

#

BINGO ๐Ÿ™‚

#

And I've learned something

#

Thanks for your help!!

hard summit
#

no worries, let me know if you need any more help

primal helm
#

Have a great Friday

hard summit
#

thanks you too