#latwelve-balance transaction

1 messages ยท Page 1 of 1 (latest)

cerulean lagoon
#

๐Ÿ‘‹ happy to help

#

do you have any example of this happening?

river pendant
#

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

cerulean lagoon
#

oh you mean in your webhook you're not retrieving the checkout session with the expand?

river pendant
#

yep its the same code but it doesnt seem to pull in the balance transaction data in the webhook anymore

cerulean lagoon
#

that's really odd

river pendant
#

๐Ÿ˜„

#

phew!

cerulean lagoon
#

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?

river pendant
#

yep exactly

#

My guess is that its not being created or assigned to the session fast enough but then that seems super odd too

cerulean lagoon
#

it could be to be honest

#

I'll have to ask around a bit for this

river pendant
#

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

cerulean lagoon
#

just a quick question you're listening to checkout.session.complete event?

river pendant
#

Yep just sanity checked that ๐Ÿ˜„

#

'stripe-webhooks::checkout.session.completed' => [
CheckoutSessionCompleted::class,
],

cerulean lagoon
#

do you have an event id you could share?

river pendant
#

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

muted falcon
#

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)

river pendant
#

yep its on the cli at the bottom of my screen

#

so just ignore that red herring ๐Ÿ˜„

#

Glad to have mr meeseeks onboard

muted falcon
#

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.

river pendant
#

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?

muted falcon
#

Oh gotcha, apologies for my misunderstanding.

river pendant
#

all good

muted falcon
#

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.

river pendant
#

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

muted falcon
river pendant
#

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

muted falcon
#

No worries! I'm glad we were able to get to the bottom of it!

river pendant
#

Thanks for your help - enjoy the rest of your day