#_kevinx

1 messages · Page 1 of 1 (latest)

cerulean sorrelBOT
fervent bridge
#

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?

worldly sequoia
#

Hi toby, I added a listener with CLI

stripe listen --forward-to localhost:3000/api/connectWebhook
fervent bridge
#

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)

worldly sequoia
#

The 500 error is from the CLI interface

#

and my webhook events were never triggered either

fervent bridge
#

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.

worldly sequoia
#

The error response is the event here is undefined

  switch (event.type) {
fervent bridge
#

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?

worldly sequoia
#

error Error [TypeError]: Cannot read properties of undefined (reading 'type')

#

Is there any doc explain how to test webhook locally? for examples, steps

fervent bridge
worldly sequoia
#

like I listed above the reason why it is crashing is because the event obj comes back as undefined

fervent bridge
#

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?

worldly sequoia
#

Yes, ```js
event = stripe.webhooks.constructEvent(buf, sig, endpointSecret);

#

so where do I get the Webhook secret for local host

#

that is the reason

fervent bridge
#

It's printed to your console after you run stripe listen

worldly sequoia
#

do I need to switch to this secret?

#

in my env

fervent bridge
#

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.

worldly sequoia
#

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

fervent bridge
#

How did you trigger the test Event(s)?

worldly sequoia
#

I have a checkout button on my local page, I didn't use the CLI stripe trigger

#
stripe.checkout.sessions.create
fervent bridge
#

Did you complete the checkout experience, or did you only create it? Can you share the ID of the Checkout Session you used/created?

cerulean sorrelBOT
worldly sequoia
#

Where can I find the ID of the checkout Session btw

#

I only see event ID

flat bay
#

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.

worldly sequoia
#

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

flat bay
#

Are you sure the Event isn't being created on another account? Sounds like multiple accounts are involved.

worldly sequoia
#

I only have one account

#

Noticed there are two pending webhooks

  livemode: false,
  pending_webhooks: 2,
#

Is this the reason?

flat bay
#

If you only have one account an application fee doesn't make sense.

#

Where are you seeing the application fee appear exactly?

worldly sequoia
#

When I log out the event obj before the switch statement in the webhook

flat bay
#

Let's back up a bit.

worldly sequoia
#
 event = stripe.webhooks.constructEvent(buf, sig, endpointSecret);
flat bay
#

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?

#

And I think the checkout.session.completed Event exists on that connected account.

#

Does that make sense?

worldly sequoia
#

so there is connected Standard account and platform account right

#

the one you listed here is the Standard account

flat bay
#

Okay, try looking on the connected account for the checkout.session.completed Event.

worldly sequoia
#

how, I thought I was looking at the connected account from the webhook

flat bay
#

You're using stripe listen for webhooks, correct? What is the full stripe listen command you used?

worldly sequoia
#

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

flat bay
#

Try that and then trigger the Event again.

worldly sequoia
#

stripe listen --forward-connect-to localhost:3000/api/connectWebhook?

#

is this the correct one?

flat bay
#

Yep.

#

Looks like it.

worldly sequoia
#

It doesn't work

flat bay
#

What do you see in the output of the command?

worldly sequoia
#

no event typies comes back at all

#

that's it

flat bay
#

Are you sure Stripe CLI is logged in as your platform account?

worldly sequoia
#

Yes, I. can see it

flat bay
worldly sequoia
#

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

flat bay
#

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.

worldly sequoia
#

Good advice, I used another connected test account and it worked

flat bay
#

Ah, good!

worldly sequoia
#

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!

flat bay
#

You can bulk delete all test data, but other than that you would need to remove things manually.

worldly sequoia
#

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

flat bay
#

I don't believe we return a 405 HTTP status.

#

That's likely coming from your own system, or a third-party.

worldly sequoia
#

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?

flat bay
#

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.

worldly sequoia
#

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?

flat bay
#

You can usually use the same backend to process both, but it depends on your specific integration and use case.

worldly sequoia
#

Is there an equivalent of Stripe checkout for mobile? we are using the Stripe checkout directly now on web

flat bay
#

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.

worldly sequoia
#

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?

flat bay
#

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.

worldly sequoia
#

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?

flat bay
#

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.

worldly sequoia
#

Got it, thanks, have a good one there!

flat bay
worldly sequoia
#

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?

flat bay
#

Usually people use universal links to handle this on mobile.

worldly sequoia
#

Nice, btw, is there any example or doc on using checkout session web view for mobile (react native) ? totally fine if not

flat bay
#

I don't think we have that, no. It would amount to opening the Checkout Session's url in your app.

worldly sequoia
#

Got you, thanks!