#karsh-stripe-cli
1 messages ยท Page 1 of 1 (latest)
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
Isn't that where the Stripe CLI comes in ? https://stripe.com/docs/cli/trigger
If not, how can I test my endpoint before I put it live
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
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?
Yes, exactly. The CLI does not log responses to the events it forwards
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
Okay that brings us back to the initial question. I'm guessing that I'm not useing the stripe listen --forward-to properly...
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?
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
Checking on this and helping others, please be patient
Thanks ๐
Ok, so acct_1K6emr4EUUkwe4X0 is the connected account and acct_1It6V3KWokmZWsWf is platform, right?
Add you're authenticated with acct_1It6V3KWokmZWsWf in Stripe CLI?
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
And the event is hitting your webhook handler locally?
how can I confirm?
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
There's the -c flag but according to the docs it shouldn't be required: https://stripe.com/docs/cli/listen#listen-forward-connect-to
Well, you're using stripe listen --forward-to to send the event to a local handler. Is it hitting it?
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?
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
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
I just tried it one more time with --forward-to for good measure, see video. Same result
This is with --forward-connect-to
In the documentation that your colleague linked me yesterday (https://stripe.com/docs/connect/webhooks#connect-webhooks) it says I should be using --forward-connect-to together with --stripe-account
Yeah, that was my understanding too (hence the recommendation)
Just checking something on the accounts, 2 minutes
Thanks, I'm rereading the docs and double checked if I'm using the endpointsecret from the CLI - and I am
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
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)
That's from an internal document, there's nothing really documented publicly on this as it's a bit of an edge case
Ah okay thanks for sharing
You'll be able to establish a test mode connection between 2 accounts without impacting the live mode connection
Oh so there is a way to set up a test mode connecting between the CLI and the connected account?
It's not the CLI. You need to establish a test mode (using the test keys) connection between the platform and your connected account
Sorry a bit at a loss on how to do that, can you give me a pointer?
@bold atlas can help with that, I need to step away!
Hi there ๐ give me a moment to get caught up on the thread
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
Apologies for the delay, just double checking one thing.
Since you'll need to connect an existing account, you'll need to leverage our OAuth flow. In Step 1, where you're collecting the client_id, be sure that you're in test mode when you copy the ID out of your dashboard.
https://stripe.com/docs/connect/oauth-standard-accounts