#jjoyceiv - connect test mode webhooks

1 messages · Page 1 of 1 (latest)

left topaz
#

This is actually expected behavior. When receiving connect webhooks, we include a livemode property on the event that lets you know if the event is from test or live. Unfortunately it comes from a legacy behavior in our webhook so it can't be turned off

light crane
#

Got it. So if I'm constructing the event from the incoming webhook with:

$event = \Stripe\Webhook::constructEvent($payload, $sig_header, self::$stripe_whsec_connect);

I should be able to just do:

if($event->data->livemode === false) {

to filter out test mode events as such, right?

left topaz
#

Exactly

light crane
#

Unfortunately that doesn't seem to be working - looks like it's throwing an exception before I can parse the event.

#

I'm not decoding the raw payload before passing it to constructEvent. Should I just do that, or try to handle this exception instead?

left topaz
#

What is the exception that is being thrown? Checking after constructEvent should be the right way to do it

light crane
#

PHP Fatal error: Uncaught (Status 400) (Request req_snipped) No such payout: 'po_snipped'; a similar object exists in test mode, but a live mode key was used to make this request.
thrown in /www/snipped_387/public/assets/plugins/rpe-utilities/includes/stripe/lib/Exception/ApiErrorException.php on line 38

#

But I see now it's actually prepending "Stripe Notice: Undefined property of Stripe\StripeObject instance: livemode" to that.

left topaz
#

The other exception is likely unrelated, that is coming from your app trying to retrieve a payout

light crane
#

Yeah, it's good now. It was just $event->livemode I needed. Now those will be filtered out and will return a 200 with:

{
"status": true,
"message": "Test mode event. Ignoring."
}

Test mode webhooks do actually receive test mode Connect events, right?

#

I have one set up for our staging site, this was the prod webhook.

left topaz
#

Yes, test mode endpoints should only get test mode events. Live endpoints are the ones that receive both

light crane
#

Got it. I thought so, just sanity checking. Think I'm good now, thanks for your prompt help.