#kevinx-connect-webhooks
1 messages ยท Page 1 of 1 (latest)
Hi ๐
Debugging webhooks is a pretty complex process. We have a guide for dealing with signature verification errors here: https://support.stripe.com/questions/webhooks-what-to-do-when-the-http-status-code-starts-with-a-four-(4xx)-or-five-(5xx)
thanks, let me take a look
ok, read through it and double check, nothing seems wrong
one question here, when I use CLI to listen to localhost, it gives me a webhook signing secret which is different from the webhook secret from the dashboard, how to use this one from CLI
do I need to replace the Webhook secret with one from CLI ?
ah, that's the reason
Yup
I thought the webhook secrect from the dashboard can work with testing etc
The CLI uses a different secret because it's a separate endpoint
Got it, thanks, btw, is there anyway to copy webhook setup from Test mode to production? just like product? or do I have to redo everything in production
I didn't find a way to do so
I'm not sure what you mean there. The only difference is the URL it points to.
All the code that handles the webhook event lives on your server
no, I meant the webhook endpoint settings from the dashboard
Like what events to listen to?
one more question here, when trigger charge.dispute.created, I got below error
stripe trigger charge.dispute.created
Setting up fixture for: payment_intent
Running fixture for: payment_intent
Trigger failed: Request failed, status=400, body={
"error": {
"message": "A `return_url` must be specified because this Payment Intent is configured to automatically accept the payment methods enabled in the Dashboard, some of which may require a full page redirect to succeed. If you do not want to accept redirect-based payment methods, set `automatic_payment_methods[enabled]` to `true` and `automatic_payment_methods[allow_redirects]` to `never` when creating Setup Intents and Payment Intents.",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_mjpIndGzDSJLrN?t=1692913207",
"type": "invalid_request_error"
}
}
Yes, never mind that question, I will just redo everything in production, do you know how to solve this error about charge.dispute
Ah, yes because you are on the latest API version and automatic_payment_methods is on
Can you try updating your CLI?
Ok, here I need a little bit help to understand it
Sure
It doesn't actually involve a charge dispute
It is attempting to create a Payment Intent.
And not passing all the parameters required because you are on the latest API version
ok, so how to solve this problem lol
I just reinstalled the CLI to latest
still giving me the same error
Okay that is a bug in the CLI fixtures. You can see the fixture definition here: https://github.com/stripe/stripe-cli/blob/master/pkg/fixtures/triggers/charge.disputed.created.json
Can you try running the command with --add payment_intent:return_url=https://example.com
Thanks ,this works and looking at the evecnt.data.object, I didn't find any attribute relates to the Connect Account at all, the same thing for payment_intent.succeeded
Well, how should we link these two the connect account to handle them
Here are the returned obj
What is the command you wrote exactly?
stripe trigger charge.dispute.created --add payment_intent:return_url=https://example.com
Okay there is nothing Connect related there
Here is what was returned
What are you looking for?
I'm setting up the webhook for Connect Standard account based on the doc
and here are a few events I'm listening
charge.dispute.created
payment_intent.succeeded
Okay but the CLI doesn't know that
well, the returned object should at least including an attribute, even if the value is null
If you want to simulate Connect webhook events you will need to specify it in each command: https://stripe.com/docs/cli/trigger#trigger-stripe_account
ok, I don't see an account id or similar attribute from the link you just sent either
how should people know which account where this dispute is related
the same thing for payment_intent.succeeded
or am I missing something here
The link I sent shows you the flag you need to pass
--stripe-account acct_XXXXXX
That flag will ensure the objecst are created for the Connected Account you identify with the ID you provide
added the flag, still don't see the account id from response
it gives me 200
id: 'dp_1Nill9FK1YId5EcvSm3IkhjF',
object: 'dispute',
amount: 100,
balance_transaction: null,
balance_transactions: [],
charge: 'ch_3Nill8FK1YId5Ecv1ESnYzT0',
created: 1692915131,
currency: 'usd',
evidence: {
},
evidence_details: {
},
is_charge_refundable: true,
livemode: false,
metadata: {},
payment_intent: 'pi_3Nill8FK1YId5Ecv1l5hR7xg',
payment_method_details: { card: { brand: 'visa', network_reason_code: '10' }, type: 'card' },
reason: 'fraudulent',
status: 'warning_needs_response'
}
This was a direct charge, so you would see the application identifying the platform associated with these objects
ok, we are the platform, and need to identify connect account for the dispute and payment intent right
๐ taking over! Are you trying to do this on the Event in your webhook handler?
yes
case "charge.dispute.created":
const chargeDisputeCreated = event.data.object;
Gotcha, let me have a quick look to see what we send you. The CLI is a bit "weird" with Connect webhooks and I wonder if it's the problem
Thank you, appreciate. the help
Okay so your code right now look at event.data.object that would be the Dispute object for a charge.dispute.created Event right?
and what you are looking for right now is which connected account is the Event from right?
Yes, exactly, when the webhook gets it, we need to identify which account it is related to right, so that we can handle it properly
Gotcha so you want the account property on Event: https://stripe.com/docs/api/events/object#event_object-account
Note that it's above in the JSON
you want connectedAccountId = event.account in that code
Like if you dump the entire JSON from the Event you get something like this ```{
"id": "evt_1234",
"object": "event",
"account": "acct_ABC",
"api_version": "2023-08-16",
"created": 123456,
"data": {
"object": {
"id": "dp_EFG",
"object": "dispute",
...
and you were deep in data.object and didn't realize there's more info top-level, if that makes sense
kevinx-connect-webhooks
Got you, thanks, let me check
Yeah, you are right, it's in the event, thanks @lapis slate !
Awesome! This is easy to miss since even in the Dashboard we show the raw JSON of what's inside event.data.object instead
Yes, I was wondering where it is ๐
Again, thanks , I guess experience is more valuable
it's under the "webhook conversation" at the bottom of the page
but it's harder with the CLI to notice
especially because you're testing Connect so you have to look at the connected account's own Dashboard and it's a bit of a pain
my advice: always always dump the raw JSON of the raw Event/payload you get in your webhook handler when debugging
That's true
I have a PHP script I wrote years ago and the first thing it does is that so that no matter what I do after I always get the JSON dumped in a file I can look at
Sure thing! Let me know if you have follow up questions after playing with it
and our team is already working on fixing the CLI bug in https://github.com/stripe/stripe-cli/pull/1117
๐ thanks, will do
will take a while to review/merge/release though