Meldiron / railway-webhook-proxy

Webhook proxy to trigger Appwrite Function. Hosted for free on Railway.
MIT License
7 stars 18 forks source link

Stripe not compatible #1

Open tannermeade opened 2 years ago

tannermeade commented 2 years ago

Stripe is not compatible with this proxy because it reformats the raw body in a way that breaks stripe validating the signature. The stripe SDK uses the signed signature in the header and the raw body itself in the validation process (the docs specifically say json parsing the raw body will break it).

So this web proxy needs to not take responsibility for parsing the body but leave that responsibility to the cloud function.

tannermeade commented 2 years ago

This can be fixed by replacing the data-parser on line 10 with the below:

app.use('/v1/execute', function (req, res, next) {
    var data = '';
    req.setEncoding('utf8');
    req.on('data', function (chunk) {
        data += chunk;
    });

    req.on('end', function () {
        req.body = data;
        next();
    });
}, async (req, res) => { //....
Meldiron commented 2 years ago

@tannermeade Thanks for this 🤝 Would you mind opening a pull request?

tannermeade commented 1 year ago

@tannermeade Thanks for this 🤝 Would you mind opening a pull request?

Didn't end up making a PR because I continued to run into issues using it as a proxy for stripe webhooks. Even after the changes it still didn't work for the refund events because the character count was too large among other issues. The standard fixes weren't working, so I recreated this proxy in dart and now the stripe webhook proxy is working well.

I could make a PR to overwrite the nodejs project with the dart one, but not sure if that is what you'd want.

EDIT: The char count issue is actually related to appwrite, not the proxy.