#nakasho
1 messages · Page 1 of 1 (latest)
Can you share your account id? You can find your account id by logging in to https://dashboard.stripe.com/settings/account. It'll be in the upper right hand corner and looks like acct_123
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.
I'd suggest referring to https://stripe.com/docs/payments/quickstart to implement
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?
there's two problems here :
- you didn't complete payment for a Checkout Session
- you should not use Charges / Tokens
why do you want to use Charges / Tokens?
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?
charge.succeeded
you can see the full list of event types here : https://stripe.com/docs/api/events/types
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
also, you can trigger webhook events using the Stripe CLI instead : https://stripe.com/docs/webhooks/test#supported-events
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?
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
Hmmm why. tried charge.succeeded but no log output. It seems it is not caught.
can you share the charge id?
it'll start with ch_
the Charge id : https://stripe.com/docs/api/charges/object#charge_object-id
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
token.id tok_1MPLNdLNEeSdZrBQapKBMreI
oh ch_
"id": "ch_3MPLNhLNEeSdZrBQ0Re3ZBir",
you need to update your webhook configured in the dashboard to listen for the charge.succeeded event also : https://dashboard.stripe.com/test/webhooks/we_1MPJVFLNEeSdZrBQTgd1RBY5
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
right now it's only listening for two events : checkout.session.completed, payment_intent.succeeded
Thanks, I added charge.succeeded.
But still it does not work.
where isn't it working? based off the Dashboard : https://dashboard.stripe.com/test/events/evt_3MPLc8LNEeSdZrBQ1advejIa - it's successfully delivered, and your server returned 200
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.
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
you can read about how webhooks work here : https://stripe.com/docs/webhooks
and the sample code on how to implement webhooks here : https://stripe.com/docs/webhooks/quickstart
i'd suggest running our sample code, and seeing if that works for you instead
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_...' ;
webhook secret
if you look at https://dashboard.stripe.com/test/webhooks/we_1MPJVFLNEeSdZrBQTgd1RBY5 - there should be a field that says Reveal secret
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
if you click on that, that's the webhook secret
I tried using the sample code in the documentation but still no log output.
Moreover, there is nothing in "request".
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
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.
can you share the latest charge id that you just tried with our sample code?
"id": "ch_3MPMmFLNEeSdZrBQ1Q6ZIlJm",
https://dashboard.stripe.com/test/events/evt_3MPMmFLNEeSdZrBQ1Df5BA5U is the event related to that charge and you can see there it was delivered to your server and expand the logs for that delivery
what did you see on your end?
I'm sorry, what do you mean by "saw what in the end"?
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?
Deployment is on the server side? Or do you mean deployed on the Stripe dashboard?
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?
Nothing is logged on my server side. That is the problem.
as I said above, looks like your ngrok is not properly configured? seems like you should look into that.
Oh, I have a NotFound on ngrok instance.
So why are the webhooks succeeding?
because we send it to ngrok and they accept it, they just don't forward it to your URL
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.
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
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.
not sure, haven't seen that one before
putting /webhooks is correct yes
try doing stripe login again and see if that helps
seems good
and your node server is running in a different terminal window right now too?
cool, then what happens now when you trigger an event to happen?
I am trying to use Stripe.charges.create, which seems to be deprecated.
And I am trying to catch charge.succeeded in webhooks.
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?
so what happens when you create a charge and generate an event now?
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.
how do you "try" it exactly?
do you have an example ch_xxx ID from the most recent attempt?
What do you mean by "try exactly"?
The console logs will also confirm that the payment was made successfully using the Pay function.
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
if you look at https://dashboard.stripe.com/test/events/evt_3MPO5rLNEeSdZrBQ05vqoIWD you can see it made it through ngrok and got to your server
For some reason, the most recent Charge is giving me a 404 error. I will check that as well.
but your server returns <pre>Cannot POST /webhooks</pre>
it's because the correct URL is ...ngrok.io/webhook, not ..ngrok.io/webhooks
Which object on the dashboard shows that it is reaching my server through ngrok?
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 ?
Hmmm, I changed the URL but it still gives me a 404 Not Found.
I am looking into it a bit.
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
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?
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
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
are there any outstanding issues?
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"}}
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.
👋 taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
Thank you for your help.
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?
I think you're running your server on port 5000 and you're asking the Stripe CLI to send the events to port 3000
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?
on which port this code is running?
Node.js code such as endpoints is 5000 ports.
then you need to forward to port 5000
React is your front-end code
the webhook endpoint is on the backend instead
I get this error when I allow Stripe CLI access to my account information in my browser.
would you mind doing a stripe login first and then retry
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.
would you mind sharing your account id?
acct_1LtETRLNEeSdZrBQ
Hey! Taking over for my colleague. Let me catch up.
Please, man.
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
What should I do after that?
Is that all there is to the setup?
Try to run the stripe listen command now
Oh my gosh! It looks like the CLI is now available.
Thanks.
Great!
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?
by pressing ctr+c on the terminal window
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.
This error is related to signature verification error
I invite you to follow/run this complete example https://github.com/stripe/stripe-node/blob/master/examples/webhook-signing/node-express/express.js for running webhook signature verification
I set up the signature secret by looking at the sample in the document.
But I get an error.
what is the error ?
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.
Feel free to come back if you have any follow up questions when you come back