#Daniel M.-webhooks
1 messages · Page 1 of 1 (latest)
Hey, taking over here. Let me know if there's any follow-up Qs I can answer!
Actually yes there are a lot of questions I think haha
I´m confused by the docs, because there seem to be so many different "ways" of setting up the end point
and I´m really confused on how they work
and how to set them up
Ok, what is it you're actually trying to achieve?
So I want to update my payment status in the database with the webhook
so that the users can download their product, as soon as it´s paid
before it worked like so ```js
router.post("/webhookMollie", (req, res) => {
updateMolliePaymentStatus(req.body.id, res);
});
exports.updateMolliePaymentStatus = (id, res) => {
// get payment status with id
mollielient.payments
.get(id)
.then(async (response) => {
// update paymentstatus in db
const doc = await FileModel.findOne({ paymentId: id });
doc.paymentStatus = response.status;
doc.save();
})
.catch(() => res.sendStatus(404));
};
all I need to do, just with stripe
Have you seen this example? https://stripe.com/docs/webhooks/quickstart
There's a full Node example there that will help you get started
hmmm i see, it´s so much more D:
do I need to set up and endpoint secret in local development?
or is it just to be safe later on when its live?
const stripe = require('stripe')('sk_test_51Ky...) also which key is this?
You should absolutely test the endpoint locally, I'd recommend using the CLI to test it: https://stripe.com/docs/stripe-cli/overview
Your secret API key
that one
also i made this script: "stripewh": "stripe listen --forward-to localhost:4000/stripe_webhooks --skip-verify"
installed all dependencies for it, thats the cli you´re talking about right?
No, the one from here: https://dashboard.stripe.com/test/apikeys
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
im only getting 404s from my webhook
also is it common, that the webhook is called once when I first run the app?
bc I create the intent at the beginning of the app or so?
Does your stripe_webhooks POST endpoint definitely exist?
it should
can stripe reach my localhost or do I have to use something like a tunnel with ngrok?
Nope, the CLI will be able to reach your localhost (it replaces the need for ngrok or similiar)
hmm okay
Can you share the code where you define the stripe_webhooks endpoint?
nvm, it works now, forgot to rerun my stripe script after changing routes
only restarted the backend
my bad
but I´ve got another question.
I was told to put the Elements provider at the root level of my app, which means each visitor, even if he doesnt even want to buy something, creates a payment intend... isnt that kinda overkill?
it's just how we design the integration, there's no problem having lots of PaymentIntents like that, you only need to look at ones that complete