#_kevinx
1 messages · Page 1 of 1 (latest)
Hi there 👋 when you say you added a local listener, did you do that via the Stripe CLI's listen command? Or did you try to register a webhook endpoint in your account with a localhost url?
Hi toby, I added a listener with CLI
stripe listen --forward-to localhost:3000/api/connectWebhook
Gotcha, that's right then, so now the question is where you're seeing the 500 error coming from. Is that how your webhook endpoint is responding to the Stripe CLI when it forwards the Event to the endpoint? (The Stripe CLI will automatically acknowledge that the receipt of Events, so if you look in the dashboard you should see that those Events are considered to be delivered successfully because the CLI is responding to Stripe with a 200)
The 500 error is from the CLI interface
and my webhook events were never triggered either
That indicates your sever is responding to the CLI with a status of 500. I won't be able to offer much insight offhand on what is causing that, but it likely indicates your Event handling code is crashing. I would recommend adding additional logging to that so you can determine exactly how far the code is able to progress, and where the error/exception that is causing it to crash is coming from.
The error response is the event here is undefined
switch (event.type) {
Is it event or event.type that isn't defined? What do you see if you try to log the contents of event just before that switch?
I'm assuming you have some code above that to populate the element variable, is that completing as expected?
error Error [TypeError]: Cannot read properties of undefined (reading 'type')
Is there any doc explain how to test webhook locally? for examples, steps
Yup, it's discussed here:
https://stripe.com/docs/webhooks#local-listener
but forwarding Events using the CLI is the correct way to test your endpoint locally. Right now it sounds like your Event handling code is crashing when it receives an Event, and you'll need to debug your code to determine why it's crashing.
like I listed above the reason why it is crashing is because the event obj comes back as undefined
Do you have a line that is populating the event variable? Did you try logging out the contents of event just before the switch statement as I suggested before, and if so, what output did you see get logged?
Having undefined variables happens, and now you need to debug the code to figure out why it isn't defined.
Are you using constructEvent to populate event?
Yes, ```js
event = stripe.webhooks.constructEvent(buf, sig, endpointSecret);
so where do I get the Webhook secret for local host
that is the reason
It's printed to your console after you run stripe listen
Yes, you will always need to use the signing secret that matches the webhook endpoint being used. If you're using stripe listen then it needs to be the signing secret provided by the Stripe CLI when you run that command. Otherwise you need to use the signing secret that is generated and provided when creating the Webhook Endpoint.
Great, thanks, the response now is 200, but normally there are few different event typies fired up once a transaction is successful right? I tested this webhook few weeks ago and all these event typies were fired, but right here at local host, only one type is received
event: {
id: 'evt_1NzQ1TF9VtVx6MBBVrHmeMT6',
object: 'event',
api_version: '2023-08-16',
created: 1696883151,
type: 'application_fee.created'
}
Unhandled event type Connect application_fee.created
Why charge.succeeded and checkout.session.completed did not come back
How did you trigger the test Event(s)?
I have a checkout button on my local page, I didn't use the CLI stripe trigger
stripe.checkout.sessions.create
Did you complete the checkout experience, or did you only create it? Can you share the ID of the Checkout Session you used/created?
Hello! I'm taking over and catching up...
The checkout.session.completed Event contains the Checkout Session object, which contains the id of that Checkout Session.
Ok, I never received this event type checkout.session.completed
this is the reason why I was asking why I didn't get it lol
The only event type I got back is. application_fee.created
When I did the test few weeks back, I did receive few different event typies once a charge is successful
Are you sure the Event isn't being created on another account? Sounds like multiple accounts are involved.
I only have one account
Noticed there are two pending webhooks
livemode: false,
pending_webhooks: 2,
Is this the reason?
If you only have one account an application fee doesn't make sense.
Where are you seeing the application fee appear exactly?
When I log out the event obj before the switch statement in the webhook
Let's back up a bit.
event = stripe.webhooks.constructEvent(buf, sig, endpointSecret);
An application fee is taken by a platform from another Stripe account involved in a transaction.
If there's an applicaiton fee there must be, at minimum, two Stripe accounts involved.
But you said there's only one Stripe account.
Can you clarify?
Looking at the last Event you shared, it looks like there's your platform account, and then there's a Standard account connected to your platform that you created in this request: https://dashboard.stripe.com/logs/req_fsFFZMXN3hKFlG
And I think the checkout.session.completed Event exists on that connected account.
Does that make sense?
so there is connected Standard account and platform account right
the one you listed here is the Standard account
Okay, try looking on the connected account for the checkout.session.completed Event.
how, I thought I was looking at the connected account from the webhook
You're using stripe listen for webhooks, correct? What is the full stripe listen command you used?
how to make webhook response to connect account instead of standard account
stripe listen --forward-to localhost:3000/api/connectWebhook
and this is my connectWebhook
why does it response to standard account
That won't work, that will only listen for Events from your platform. If you want to listen for Events from your connected accounts you need --forward-connect-to: https://stripe.com/docs/cli/listen#listen-forward-connect-to
Try that and then trigger the Event again.
stripe listen --forward-connect-to localhost:3000/api/connectWebhook?
is this the correct one?
It doesn't work
What do you see in the output of the command?
Are you sure Stripe CLI is logged in as your platform account?
Yes, I. can see it
So if you go to https://dashboard.stripe.com/test/connect/accounts/overview do you see the connected account listed there?
Yes, all the test accounts are listed there
I was using the same code test this few weeks back and everything worked well
Didn't make any changes
all event typies showed up
I don't know why they wouldn't be showing up now. If you click on the connected account in question, then click on the ••• button in the top right and view the Dashboard as that account you should be able to see the Events in Developer > Events.
Good advice, I used another connected test account and it worked
Ah, good!
Can I bulk remove these test accounts?
some of these accounts don't work for some reason
Thank you for your help btw, really appreciate it!
You can bulk delete all test data, but other than that you would need to remove things manually.
Got you, thanks
One more question please
This app also have a mobile version, and we plan to use the same backend api processing the payment, is it possible?
We did some test, and it didn't seem work as we always got 405 status, even though the fetch method is always POST, we keep getting 405
I don't believe we return a 405 HTTP status.
That's likely coming from your own system, or a third-party.
ok, we will further investigate it.
How long does it take for a user to establish a connected account once they submit data to Stripe? for example, if a store owner submit all his/her data required by Stripe, how fast can they start using the connect account?
That depends on several factors. Sometimes they can start using it immediately, sometimes they need to wait for some verification. That's a better question for Stripe support than here though.
I see, thanks
Does Stripe distinguish the difference between a web checkout or a mobile checkout? can we use the same backend api to process payments for both?
You can usually use the same backend to process both, but it depends on your specific integration and use case.
Is there an equivalent of Stripe checkout for mobile? we are using the Stripe checkout directly now on web
You can use Stripe Checkout directly on mobile by opening it in a web view or similar. It's responsive and designed to look and work well on any device.
If you want to use a native UI we have Mobile Elements: https://stripe.com/docs/payments/mobile
Great, thank you Rubeus, we will see if web view works first, thanks man!
IF we do use native UI mobile elements, can we still use the same backend?
Not if you're using Stripe Checkout on the web, no.
If you're using the Payment Element on the web with Payment Intents directly then possibly, yes.
Got you, in order to use the same backend for both, we would need to use web view on both as well
That's probably the reason we keep getting errors from backend
Is it possible to add this Payment Intents to existing stripe.checkout.sessions.create, so that it will workout for mobile native UI too?
No, if you're using Mobile Elements you can't use Checkout or Checkout Sessions at all.
You would need to create Payment Intents directly.
Got it, thanks, have a good one there!
The short video here might help: https://stripe.com/docs/payments/tour#payment-objects
Thanks, appreciate it
from the Stripe checkout session, there is a success_url and cancel_url, these are all pointed to the web version
if the mobile version uses the same checkout session, it needs to have different url configures though, do we need to duplicate the api just for different success and cancel urls?
Nice, btw, is there any example or doc on using checkout session web view for mobile (react native) ? totally fine if not
I don't think we have that, no. It would amount to opening the Checkout Session's url in your app.
Got you, thanks!