This is a NestJS-based microservice for handling payment processing, integrated with Stripe.
The Payments Microservice provides an API to create payment sessions and handle payment success/cancellation callbacks and Stripe webhooks.
- Clone the repository:
git clone <repository-url>
- Navigate to the project directory:
cd payments-ms
- Install dependencies:
pnpm install
Create a .env
file in the root of the project by copying the template:
cp .template.env .env
Then, fill in the required environment variables:
PORT
: The port the application will run on (e.g., 3003).STRIPE_SECRET
: Your Stripe secret key.BACKEND_BASE_URL
: The base URL of this microservice, used for constructing redirect URLs for Stripe.
To run the application in development mode with hot-reloading:
pnpm run start:dev
The application will be available at http://localhost:{PORT}
.
To build and run the application in production mode:
pnpm run build
pnpm run start:prod
start
: Starts the application.start:dev
: Starts the application in watch mode.build
: Builds the application for production.format
: Formats the code using Prettier.lint
: Lints the code using ESLint.test
: Runs unit tests.
POST /payments/create-payment-session
: Creates a new Stripe payment session.GET /payments/success
: The endpoint for successful payment redirection.GET /payments/cancel
: The endpoint for cancelled payment redirection.POST /payments/webhook
: Endpoint for receiving Stripe webhook events.