#latwelve-balance transaction
1 messages ยท Page 1 of 1 (latest)
The test id above is one example of it working when I manually run that code
however when it comes in on the webhook it doesn't pull in the balance transaction data so I get an accessing null error
Screenshot of the charge being dumped with null for balance transaction:
https://share.cleanshot.com/C0Y6Sm
oh you mean in your webhook you're not retrieving the checkout session with the expand?
yep its the same code but it doesnt seem to pull in the balance transaction data in the webhook anymore
if I manually run the code to stripe I get what I'd expect:
https://share.cleanshot.com/rYQqUd
that's really odd
haha
so just to confirm I got it right, if you run $session = \Stripe\Checkout\Session::retrieve([ with the expand in your webhook endpoint you're not getting the balance transaction while it works fine manually right?
yep exactly
My guess is that its not being created or assigned to the session fast enough but then that seems super odd too
All good - I'll implement handling it on a delay quickly and report back if that solves the issue too - but it'd be good to know if theres a way to handle / listen for it without a delay
just a quick question you're listening to checkout.session.complete event?
Yep just sanity checked that ๐
'stripe-webhooks::checkout.session.completed' => [
CheckoutSessionCompleted::class,
],
do you have an event id you could share?
1 mo
evt_1LRxwlIWwRG2BJaDSwuZsNql
pretty sure its this - it says webhook failed but i think thats just because its thinking its on the live url book ive got stripe listening for the local so it was handled and the output is what ive already shared with you
Hi ๐ I'm jumping in as my teammate needs to step away. Thank you for sharing that event ID.
(That webhook is showing that it failed delivery because your server returned a 500, that doesn't seem like the focus here but I wanted to clarify)
yep its on the cli at the bottom of my screen
so just ignore that red herring ๐
Glad to have mr meeseeks onboard
Can you also share the ID of a previous event where you saw the behavior that you were expecting? Based on what I'm reading from the thread, it sounds like you're saying the webhook events used to contain information about an associated Balance Transaction in an event that returned a Checkout Session object. I don't think our events have returned data nested that far down in other objects before.
Sorry for any confusion. I listen for a checkout success event and then in my Job I run this code:
$session = \Stripe\Checkout\Session::retrieve([
'id' => 'cs_test_a1HNr4q7HiiJffqvJ7rTugNkEvjbjq6q47N5MrAvEJOkDHfgMtRUGCBAn2',
'expand' => ['payment_intent.charges.data.balance_transaction'],
]);
and then further down in the code I access the balance_transaction information. It had been working as expected but recently its been pulling back null within balance_transaction
if I run the exact same code above it does indeed populate the balance_transaction data.
So I was wondering if its because Stripe hadn't had a chance to populate that data in the request yet.. but then that seems a bit weird
does that help clear up the issue?
Oh gotcha, apologies for my misunderstanding.
all good
Oh, I just noticed you created that Checkout Session and set the capture_method for the underlying Payment Intent to manual. I'm checking to see if you made the request to capture that Payment Intent before the checkout.session.completed event was sent, though I suspect it wasn't.
I'm fairly sure I didn't but worth a look
Just as a fyi, I setup a delayed job to handle the balance_transaction info and that works as expected so I do have a working solution but would prefer to have the original request / hydration handle it if possible
Here's the request where I'm seeing payment_intent_data.capture_method being set to manual:
https://dashboard.stripe.com/test/logs/req_A52G8sD0neQVJ4
And it does look like the request to capture the associated Payment Intent was made after the webhook event was triggered, so the downstream objects that you were trying to access weren't created yet.
https://dashboard.stripe.com/test/logs/req_JUNclRtIUgRFL1
oh rly
hmm ok let me look into that
oh man i'm a complete idiot
its exactly that
sorry for making that far more complex than it needed to be
No worries! I'm glad we were able to get to the bottom of it!
Thanks for your help - enjoy the rest of your day