#Linas

1 messages ยท Page 1 of 1 (latest)

valid flameBOT
uneven pike
#

Hi there,
You set metadata at checkout level, they won't be propagated to other object, you may need to listen to checkout.session.completed instead

#

You can't pass metadata from checkout session to charges automatically

pseudo star
#

thanks. maybe i won't need metadata. We are listening "charge"succeded" webhooks.

#

What would be the best way via "charge.succeeded" to access purchase items ? we charge for multiple items.

#

items are listed via: $checkout_session = \Stripe\Checkout\Session::create([
'line_items' => [[ ]]);

uneven pike
#

You should listen to checkout.session.completed, once you get the Checkout Session Id, you make this API call, to fetch its line items

pseudo star
#

so, there is no way to achieve that via listening charge.succeeded ? I don't want to overwrite half of our system ๐Ÿ™‚

#

maybe i could get items via paymentintentid?

uneven pike
#

Nope the items are linked to the Checkout Session,

#

from the Checkout Session object you can get the PaymentIntentId and the ChargeId, but not the reverse

pseudo star
#

got it.

#

Do i have to check if "checkout.session.completed" transaction was successful ? Or if payment fails, "checkout.session.completed" is not created at all ?

uneven pike
pseudo star
#

Perfect. and my last quesiton:

#

since all other purchases are delivered via "charge.succeeded". Is there any way to identify "charge.suceeded" webhook, that it came via "checkout.session" ? I need somehow these sales ignore on "charge.succedded" and process on "checkout.session.completed"....

uneven pike
#

Nope, you need to implement complementary like logic, on both events

#

you do some treatment on charge.succeeded on complete treatment on checkout.session.completed. Not doing exclusive logics

pseudo star
#

but we have a lot of other stripe integrations which are running not by "stripe checkout".

uneven pike
#

I understand that, but. you need to adapt it

quartz wraith
#

๐Ÿ‘‹ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

pseudo star
#

hmm, maybe i could come with "dirty workaround" and look for charge API version? And if api version is older, i could process charges as we are doing now. And if API version is new, then i could know, that it came via Stripe Checkout and i could ignore that charge and process fulfilment via checkout.session.completed ? I think, that could work ?

quartz wraith
#

sorry I need to get some context here, let me read through the thread

#

ok so let's go one step back before answering your latest Q

#

are you still using the Charges API and haven't moved yet to the PaymentIntents API?

pseudo star
#

we use both.

#

we have a lot of old projects, which are using charges API.

#

and our fulfilment process is based on "charges.succeded" webhook.

graceful phoenix
#

Hi, my colleague has stepped away, I need a moment to catch up.

#

So, the last question is how to ignore charge.succeeded events that are not attached to a Checkout Session?

pseudo star
#

how to ignore charge.succeded, that are attached to Checkout session.

graceful phoenix
#

Sorry, this is in JavaScript, I don't know what lanaguage are u using. But you got the idea, right?

pseudo star
#

i use php, let me check, i think, it could work.

graceful phoenix
#
$stripe->checkout->sessions->all(['payment_intent' => charge->payment_intent]);