#karsh-stripe-cli

1 messages ยท Page 1 of 1 (latest)

civic nebula
#

Hey! You won't I'm afraid. We don't log Stripe CLI event responses

odd geode
#

Oh... then I think I'm a bit confused

#

My goal is to test my endpoint without pushing it to live.

Right now, I need to rebuild my application on production every time I tweak the endpoint on my server. This makes the development very very slow as I want to to be able to test what is happening quickly

#

If not, how can I test my endpoint before I put it live

civic nebula
#

Yep, that's the purpose of the CLI. But we don't log the responses in the Dashboard. You'd see them locally in your development environment

odd geode
#

Okay so the Events page in the dashboard is for debugging things happening on a production environment?

And when you say "see them locally in your dev environment" you mean whatever logging we have set up?

civic nebula
#

Yes, exactly. The CLI does not log responses to the events it forwards

odd geode
#

But wait, now I'm really getting confused haha
I am able to see a response from the CLI in the dashbaord, I just tested it again without adding a connecteda ccount

#

So the stuff in the 'response body' is what I'm looking for. That's what I want to see when I'm triggering an event from a connected account like so:
stripe trigger payment_intent.succeeded --stripe-account=acct_4X0 --add payment_intent:metadata[products]=22 --add payment_intent:metadata[checkout_id]=6 --override payment_intent:[receipt_email]=test@gmail.com

civic nebula
#

Ah, guess I was wrong

#

Confused myself

odd geode
#

Okay that brings us back to the initial question. I'm guessing that I'm not useing the stripe listen --forward-to properly...

civic nebula
#

So:
stripe trigger payment_intent.succeeded --stripe-account=acct_4X0 --add payment_intent:metadata[products]=22 --add payment_intent:metadata[checkout_id]=6 --override payment_intent:[receipt_email]=test@gmail.com
Isn't working as expected?

odd geode
#

When I do that, it triggers the event on the connected account. But the response I can see in the dashboard is from the production endpoint.
I know that for sure as I have added a line at the top of the response saying "this is from localhost".

And I haven't pushed this code to the production environment

Not sure if you can access this: https://dashboard.stripe.com/acct_1K6emr4EUUkwe4X0/test/events/evt_3KKMsh4EUUkwe4X00xRVZU2j

That's an event I just now triggered

#

Any ideas? I've been stuck on this since yesterday. I need a way to see the response my server sends

civic nebula
#

Checking on this and helping others, please be patient

odd geode
#

Thanks ๐Ÿ™‚

civic nebula
#

Ok, so acct_1K6emr4EUUkwe4X0 is the connected account and acct_1It6V3KWokmZWsWf is platform, right?

#

Add you're authenticated with acct_1It6V3KWokmZWsWf in Stripe CLI?

odd geode
#

Trying to confirm...

#

Yes the platform id is acct_1It6V3KWokmZWsWf

#

and the 4x0 is indeed the connected account

#

I'm unsure how to see if I'm authenticated with that account in stripe CLI. But that is the account I was logged into when running stripe login

civic nebula
#

And the event is hitting your webhook handler locally?

odd geode
#

how can I confirm?

civic nebula
#

Are there any logs in your handler than you can see the output of in a terminal?

#

Also, the CLI should report responses when using listen

odd geode
#

what do you mean with handler?

civic nebula
#

Well, you're using stripe listen --forward-to to send the event to a local handler. Is it hitting it?

odd geode
#

I guess I'm fundamentally not grasping what I'm doing exactly.

I've used it without the -c flag, but instead used the -f flag. I just tried the -c flag in the last hour.

When I use the stripe listen --forward to localhost:8100/webhooks/stripe I do see the response in the dashboard when I'm sending a stripe trigger without the --stripe-account flag.

So I suppose it is hitting it in that case.

You're asking me now if it's hitting my local handler, but I'm not sure how I can see if it's hitting my server other than using the dashbaord to see if Stripe received a response

#

That having said I just checked my server logs when using the 'stripe trigger' without the --stripe-account flag, and indeed I see that my logic is being triggered

#

Now if I run the stripe trigger WITH the --stripe-account flag, I do NOT see it in my logs. So I don't think it's hitting my server. Does that mean it's going wrong at the `stripe listen step?

civic nebula
#

but I'm not sure how I can see if it's hitting my server other than using the dashbaord to see if Stripe received a response
You'd add a log in there somewhere which would be printed into your local terminal which is running the server

#

The issue is with stripe listen and perhaps instead of --forward-to you should try --forward-connect-to

odd geode
#

Okay I'm trying that now, it's giving me the same. Only do I see it in my server log (and int he terminal itself) if I leave the --stripe-account tag out

civic nebula
#

Yeah, that was my understanding too (hence the recommendation)

#

Just checking something on the accounts, 2 minutes

odd geode
#

Thanks, I'm rereading the docs and double checked if I'm using the endpointsecret from the CLI - and I am

civic nebula
#

I think the issue might stem from the fact that the account is only connected in live mode and not in test

#

In those instances, both live and test mode events on the connected account will only be sent to live mode webhook endpoints

#

The CLI by default will constitute as a test mode webhook endpoint. So in those instances it won't receive the connect events

odd geode
#

Ah I see... where's this graphic from? I'd like to read more about it.
And is there a way to put the connected account in test mode (while also in live mode as there's traffic coming to the check-out page now for that account)

civic nebula
#

That's from an internal document, there's nothing really documented publicly on this as it's a bit of an edge case

odd geode
#

Ah okay thanks for sharing

civic nebula
#

You'll be able to establish a test mode connection between 2 accounts without impacting the live mode connection

odd geode
#

Oh so there is a way to set up a test mode connecting between the CLI and the connected account?

civic nebula
#

It's not the CLI. You need to establish a test mode (using the test keys) connection between the platform and your connected account

odd geode
#

Sorry a bit at a loss on how to do that, can you give me a pointer?

civic nebula
#

@bold atlas can help with that, I need to step away!

bold atlas
#

Hi there ๐Ÿ‘‹ give me a moment to get caught up on the thread

civic nebula
#

By the way, this issue is loosely referenced here:

For Connect webhooks, itโ€™s important to note that while only test webhooks will be sent to your development webhook URLs, both live and test webhooks will be sent to your production webhook URLs. This is due to the fact that you can perform both live and test transactions under a production application. For this reason, we recommend you check the livemode value when receiving an event webhook to know what action, if any, should be taken.
https://stripe.com/docs/connect/webhooks

Learn how to use webhooks with Connect to be notified of Stripe activity.

bold atlas
#

Apologies for the delay, just double checking one thing.

bold atlas