Skip to content

audiBookning/sample-nestjs-stripe

Repository files navigation

Just a little test to try to implement Stripe with Nestjs

Part of a personal list of random samples code

  • Code Still not complete and not presentable. 😎

  • And more importantly, there is no tests.

  • Some manual tests were done for the webhooks.

  • This is a basic Nestjs project, so to run it just use npm run start:dev.

Libs used

Notes

  • The stripe code of the different subscription strategies is in 5 different modules, each with a controller managing some "main" routes and with its own service (used at this time only for the Webhooks).

  • The StrategyModule is used just to dynamically load the different strategy modules depending on the env variable STRIPE_STRATEGY, so as to avoid well deserved instabilities when instantiating multiple times the @golevelup/nestjs-stripe module.

  • Their controllers are:

  • The Webhooks are consumed in the stripe services with the help of the @StripeWebhookHandler decorator.

  • The route for the Webhooks is stripe/webhook.

  • Rename .env.example to .env and change the stripe keys.

  • Since this is just a test (with minimal effort ...) and in with the objective of separating a little the code of the different subscription strategies without creating different repo or more complexity, much of the code or config is repeated. It will also give the easiness of latter simply copying a specific module folder to use as a quick boilerplate.

  • Each strategy has a separate config file. Many times the config is the same between them...

TODO

  • Add tests.

  • Errors are too generic and many try catch missing, although Nestjs catch them by default...

  • Integrate with a database. Maybe do it in a different repo in order to separate the basic "routing" implementation on its own?

BuyMeACoffee

Buy Me A Coffee

Disclaimer

This code is not and will never be maintained. It is just some random sample code.

Feel free to copy and make any change you like.

License ISC © 2021 AudiBookning