This is my first time testing with Stripe and I can't wrap my head around this issue that I'm having. I copied the code for Node/Express from this link (I just changed the port to 3000 and removed the bodyParser since I had already set it up with app.use(bodyParser.json())) and I successfully logged in to my account typing
stripe login
in the CLI. After that, I set up my endpoint for webhook listening with
stripe listen --forward-to http://localhost:3000/webhook
After everything seemed to be set up, I started testing, but I noticed somewhat of a random behaviour in the Stripe CLI: every time I tried triggering a payment intent success with
stripe trigger payment_intent.succeeded
I got a different result, as shown below:
2020-07-04 14:25:32 --> charge.succeeded [evt_1H1AQxH9PqQvGDtCJ7ShdAQE]
2020-07-04 14:25:32 <-- [400] POST http://localhost:3000/webhook [evt_1H1AQxH9PqQvGDtCJ7ShdAQE]
2020-07-04 14:25:34 --> payment_intent.succeeded [evt_1H1AQzH9PqQvGDtCl8ajm7po]
2020-07-04 14:25:34 <-- [200] POST http://localhost:3000/webhook [evt_1H1AQzH9PqQvGDtCl8ajm7po]
2020-07-04 14:25:34 --> payment_intent.created [evt_1H1AR0H9PqQvGDtC1xty9l6R]
2020-07-04 14:25:34 <-- [400] POST http://localhost:3000/webhook [evt_1H1AR0H9PqQvGDtC1xty9l6R]
2020-07-04 14:28:46 --> charge.succeeded [evt_1H1AU5H9PqQvGDtCHJ95Jb7H]
2020-07-04 14:28:46 <-- [400] POST http://localhost:3000/webhook [evt_1H1AU5H9PqQvGDtCHJ95Jb7H]
I never triggered charge.succeeded nor payment_intent.created, but despite this they showed up in the CLI (as 400 errors) instead of the normal 200 payment_intent.succeeded. I tried console logging the event.type used by the switch statement in the Stripe Docs example above and it indeed showed that the events were charge.succeeded and payment_intent.created.
Now my question is: is this some sort of bug which hasn't been already fixed or am I doing something wrong? And maybe could anyone help me out with this?
Thanks in advance for your time :)