#nakasho

1 messages · Page 1 of 1 (latest)

short vineBOT
swift girder
ocean juniper
#

acct_1LtETRLNEeSdZrBQ

swift girder
#

you're listening for these two events checkout.session.completed and payment_intent.succeeded, but you're performing any actions that trigger those events

#

for example, you created a Checkout Session, but you never completed payment on the hosted checkout page

#

I see you're also using Charges / Tokens - these APIs are considered deprecated at this point. If you want to accept payments, please make use of PaymentIntents / PaymentMethods instead.

ocean juniper
#

I see. So you are saying that the event you are catching is wrong.
I understand that Stripe.charges.create is deprecated.
Before I make the change, I want to make sure my webhooks are configured correctly.
With Stripe.charges.create, what will be the event on completion?

swift girder
#

there's two problems here :

  1. you didn't complete payment for a Checkout Session
  2. you should not use Charges / Tokens
#

why do you want to use Charges / Tokens?

ocean juniper
#

I understand that the checkout session has not been paid for and that the charge/token should not be used.
And I will change that code later.

Before I do that, I want to make sure the webhooks are working.
Because I have already implemented the code.
Which webhooks are applicable for Chages?

swift girder
#

charge.succeeded

ocean juniper
#

We are currently implementing a deprecated code.
What about the code in this screenshot?
Is this recommended code?

#

There is no big difference between Stripe CLI and ngrok, right?

swift girder
#

the code for Checkout Sessions look fine to me

#

Stripe CLI just makes testing easier for you

#

you don't have to manually create a Charge to trigger a charge.succeeded event for example

#

you can just run stripe trigger charge.succeeded

ocean juniper
#

Hmmm why. tried charge.succeeded but no log output. It seems it is not caught.

swift girder
#

can you share the charge id?

ocean juniper
swift girder
#

it'll start with ch_

ocean juniper
#

oh ch_

#

"id": "ch_3MPLNhLNEeSdZrBQ0Re3ZBir",

swift girder
#

right now it's only listening for two events : checkout.session.completed, payment_intent.succeeded

ocean juniper
#

Thanks, I added charge.succeeded.
But still it does not work.

swift girder
ocean juniper
#

The dashboard has been successful.
However, on the server side terminal, there is no log output, and it seems that webhooks events are not being caught.

#

So things are going well until the payment and ngrok and hooks response.
But for some reason, the server side fails to catch the webhooks event.

#

I don't think there is anything in the req.body to begin with.
How does webhooks catch the logs?
The way to do this is from an old Youtube video on how to implement Stripe.

swift girder
#

the only reason that i can possibly think of is that you're possibly running a different implementation than the code you're currently showing

#

i'd suggest running our sample code, and seeing if that works for you instead

ocean juniper
#

The current project is a simple code with only two payment endpoints and a webhooks endpoint.
ok. I'll take a look at that documentation.

#

What is this?
endpointSecret = 'whsec_...' ;

swift girder
#

webhook secret

#

if you click on that, that's the webhook secret

ocean juniper
#

I tried using the sample code in the documentation but still no log output.
Moreover, there is nothing in "request".

swift girder
#

did you set your ngrok to listen on the correct localhost port / correct project?

#

if i look at the latest event, it still looks like your ngrok is listening to the old project/implementation

ocean juniper
#

Yes, I think ngrok is correct, because when I turn off the ngrok server, I don't see webhooks in the dashboard.

#

The project remains intact.
Only the code has been replaced with the sample code from the documentation.

swift girder
#

can you share the latest charge id that you just tried with our sample code?

ocean juniper
#

"id": "ch_3MPMmFLNEeSdZrBQ1Q6ZIlJm",

dusk orbit
#

what did you see on your end?

ocean juniper
#

I'm sorry, what do you mean by "saw what in the end"?

dusk orbit
#

on Stripe's side, our logs show we successfully delivered that event to your ngrok URL. What do your logs, from your server and your ngrok instance, say and what did you see happen?

ocean juniper
#

Deployment is on the server side? Or do you mean deployed on the Stripe dashboard?

dusk orbit
#

I mean wherever your code is running

#

also if you look at the page I linked, you can see that when we contacted ngrok, we got back this
<noscript>Before you can serve HTML content, you must sign up for an ngrok account and install your authtoken. (ERR_NGROK_6022)</noscript>

so does that mean your ngrok is not properly configured?

ocean juniper
#

Nothing is logged on my server side. That is the problem.

dusk orbit
#

as I said above, looks like your ngrok is not properly configured? seems like you should look into that.

ocean juniper
#

Oh, I have a NotFound on ngrok instance.
So why are the webhooks succeeding?

dusk orbit
#

because we send it to ngrok and they accept it, they just don't forward it to your URL

ocean juniper
#

Thanks. I'll take a look at the settings.

#

I logged into ngrok and registered my Authtoken, but it did not matter.
Still, I cannot catch the webhooks on the server side.

dusk orbit
#

any more details or recent examples?

#

I use ngrok every day, it just works really. You run ngrok http , copy the URL it gives, and enter that URL into the Stripe dashboard. If you're using the free version of ngrok, it is a different URL everytime you run it, so you need to keep changing the URL in Stripe to the latest one it gives you

ocean juniper
#

I put in Stripe CLI instead of ngrok.
However, this also gives me an error.
The pairing code is correct, but I get an error.
What does this error mean?
I'm getting an error ⡿ Waiting for confirmation.... .unexpected http status code: 400 {"error":{"message": "The livemode of the authorization key you provided does not match that of the key provided in the Stripe-Account header.", "message_code": "stripe_account_livemode_mismatch"}}

#

Can I just put the ngrok http URL directly into the dashboard?
I am adding /webhooks to the end of the URL though.

dusk orbit
#

not sure, haven't seen that one before

dusk orbit
dusk orbit
ocean juniper
#

same url

dusk orbit
#

seems good

#

and your node server is running in a different terminal window right now too?

ocean juniper
#

yes.

dusk orbit
#

cool, then what happens now when you trigger an event to happen?

ocean juniper
#

I am trying to use Stripe.charges.create, which seems to be deprecated.
And I am trying to catch charge.succeeded in webhooks.

dusk orbit
#

it is deprecated, but if you're just using it to test out the webhook that's ok

#

so what happens when you create a charge and generate an event now?

ocean juniper
dusk orbit
#

so what happens when you create a charge and generate an event now?

ocean juniper
#

The Pay function charge succeeds.
switch (event.type) {} to determine the event.
What I want to output is " case "charge.succeeded":"

#

event is generated but not caught.
I'm trying the code in the sample code to begin with.
I'm trying the code in the sample code, but there doesn't seem to be anything in the "request" field.

dusk orbit
#

do you have an example ch_xxx ID from the most recent attempt?

ocean juniper
#

What do you mean by "try exactly"?
The console logs will also confirm that the payment was made successfully using the Pay function.

dusk orbit
#

you said you tried the code and there doesn't seem to be anything in the "request" field.

#

how did you try the code, what action did you take to try it?

#

since it's a webhook, the only way to try it is to e.g. call the API to create a charge object, and then shortly afterwards we will call your webhook URL with an event. I'm trying to determine if that's what you did/what happened, or if you did something else like try to visit /webhook directly in your Chrome browser etc(which wouldn't work).

#

ah

ocean juniper
#

For some reason, the most recent Charge is giving me a 404 error. I will check that as well.

dusk orbit
#

but your server returns <pre>Cannot POST /webhooks</pre>

#

it's because the correct URL is ...ngrok.io/webhook, not ..ngrok.io/webhooks

ocean juniper
#

Which object on the dashboard shows that it is reaching my server through ngrok?

dusk orbit
#

the fact that it is returning a HTML page from your server

#

and not a HTML error page from ngrok

#

there's some other things that I can see from our internal logs that I don't think the dashboard shows, like the HTTP headers, but bascially, trust me

#

so it's all working now when you update the URL right @ocean juniper ?

ocean juniper
#

Hmmm, I changed the URL but it still gives me a 404 Not Found.
I am looking into it a bit.

dusk orbit
#

are you sure you changed it? the endpoint in Stripe is still /webhooks. It should be /webhook. (or I guess you could change the Node code to use app.post('/webhooks') instead)

#

if you changed the code, make sure you saved the file and restarted the Node server

ocean juniper
#

Yes, I originally used app.post('/webhooks'), so I changed the Node one.
Then I restarted the server side. Still does not work. Something is wrong.

#

It is ok to test the payment with Node.js and React's local server URL, not Forwarding's URL, right?

dusk orbit
#

I'm not sure what you mean unfortunately

#

but you can visit your localhost pages in the browser yes and test payments that way, that's fine, you don't have to visit the ngrok URLs, I think that's what you mean

ocean juniper
#

There is a URL issued by ngrok.
There is also a React URL.
I have tested successfully with the React URL (localhost: 3000) so far.
I will use the React URL, so there is no problem, right?
I don't know why it doesn't work anymore.

#

OK

dusk orbit
#

are there any outstanding issues?

ocean juniper
#

I think logging into the Stripe CLI may have made it worse.

#

There are so many unresolved issues.

#

I would like to try a different approach.
First I want to be able to use StripeCLI, but I get this error. Do you know why?

#

⣷ Waiting for confirmation...unexpected http status code: 400 {"error":{"message":"The livemode of the authorization key you provided does not match that of the key provided in the Stripe-Account header.","message_code":"stripe_account_livemode_mismatch"}}

dusk orbit
#

I don't know why no, that's not an error message I've seen before

#

what did you do when running stripe login? did you visit the Stripe dashboard and enter the code?

#

I have to run sorry! some of my colleagues will take over.

I would suggest focussing on using ngrok. It seems like it almost works. You probably forgot something small like saving the file in your code or restarting the server.

shrewd niche
#

👋 taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

ocean juniper
#

Hello, I'm looking for a new site.
I was told to use ngrok. But still this does not work. Maybe I started touching StripeCLI and then it started to go wrong.
So I want to try Stripe CLI for once.
But as you can see in the screenshot, I got an error with StripeCLI.
After trying Stripe Login, I did "stripe listen --forward-to localhost:3000/webhook".
Then I checked the pairing code.
Then I got the above error.
How do I get the StripeCLI to work?
Or how can I solve this error?

shrewd niche
#

I think you're running your server on port 5000 and you're asking the Stripe CLI to send the events to port 3000

ocean juniper
#

I have tried 5000 with stripe listen --forward-to localhost:5000/webhook, but still get the same error.
React is running on a 3000 server, is 5000 enough?

shrewd niche
ocean juniper
#

Node.js code such as endpoints is 5000 ports.

shrewd niche
#

then you need to forward to port 5000

#

React is your front-end code

#

the webhook endpoint is on the backend instead

ocean juniper
#

I get this error when I allow Stripe CLI access to my account information in my browser.

shrewd niche
#

would you mind doing a stripe login first and then retry

ocean juniper
#

I tried to log in. Then I was sent to the browser. So I checked the pairing code. If I allow it, I get this error.

shrewd niche
#

would you mind sharing your account id?

ocean juniper
#

acct_1LtETRLNEeSdZrBQ

urban harbor
#

Hey! Taking over for my colleague. Let me catch up.

ocean juniper
#

Please, man.

urban harbor
#

It looks like you are having an issue with authenticating your Stripe Cli

#

First you need to get your secret API Key that you are using in your Nodejs backend

#

Run stripe login --interactive

#

and copy past your test API secret Key

#

Something like this

ocean juniper
#

What should I do after that?
Is that all there is to the setup?

urban harbor
#

Try to run the stripe listen command now

ocean juniper
#

Oh my gosh! It looks like the CLI is now available.
Thanks.

urban harbor
#

Great!

ocean juniper
#

By the way, what does it mean to be on the CLI? It seems like it's failing.

#

Sorry, can you tell me how to exit CLI Listen?

urban harbor
#

by pressing ctr+c on the terminal window

ocean juniper
#

ctr+c on the terminal window, pressed.
However, on the dashboard, the local listener is still the target to listen to.

#

Oh, it has just been released.

#

Oh, the output was also output on the server side. Error output, though.
I guess ngrok was bad after all.

urban harbor
#

This error is related to signature verification error

ocean juniper
#

I set up the signature secret by looking at the sample in the document.
But I get an error.

urban harbor
#

what is the error ?

ocean juniper
#

No signatures found matching the expected signature for payload.
Are you passing the raw request body you received from Stripe?

#

There are a lot of unsolved problems, but I've been working on them since yesterday and I'm a little tired, so I'm taking a break.
Thanks for helping me out.

urban harbor
#

Feel free to come back if you have any follow up questions when you come back