mirror of
https://github.com/FrostBreker/process-payments.git
synced 2026-04-26 13:45:50 +03:00
This is a Go backend service that handles payment processing using Stripe. The service provides a RESTful API built with Gin framework and uses MongoDB for data storage.
| cmd/server | ||
| internal | ||
| pkg/types | ||
| .env.example | ||
| .gitignore | ||
| go.mod | ||
| go.sum | ||
| README.md | ||
Process Payments with Stripe
This is a Go backend service that handles payment processing using Stripe. The service provides a RESTful API built with Gin framework and uses MongoDB for data storage.
This project was created as part of a YouTube tutorial series. You can follow along with the video to understand the implementation details and concepts behind the payment processing system.
🎥 Watch the Tutorial on YouTube
Prerequisites
- Go 1.23 or later
- MongoDB installed and running
- Stripe account with API keys
- Git (for version control)
Installation
- Clone the repository:
git clone https://github.com/FrostBreker/process-payments
cd process-payments
- Install dependencies:
go mod download
Environment Setup
- Copy the example environment file:
cp .env.example .env
- Fill in the environment variables in
.env:
STRIPE_WEBHOOK_SECRET_KEY: Your Stripe webhook secret keySTRIPE_SECRET_KEY: Your Stripe secret keyPORT: Server port (default: 8080)MONGO_URI: MongoDB connection string (default: "mongodb://127.0.0.1:27017/")PRODUCTION: Set to "true" in production environmentCLIENT_URL: Frontend application URL
Project Dependencies
Main dependencies used in this project:
github.com/gin-gonic/gin: Web frameworkgithub.com/stripe/stripe-go/v82: Stripe Go clientgo.mongodb.org/mongo-driver: MongoDB drivergithub.com/joho/godotenv: Environment variable managementgithub.com/gin-contrib/cors: CORS middlewaregithub.com/gin-contrib/secure: Security middleware
Running the Application
-
Make sure MongoDB is running locally or accessible via the configured URI.
-
Start the server:
go run cmd/server/main.go
The server will start on the configured port (default: 8080).
Project Structure
.
├── cmd/server/ # Application entrypoint
├── internal/ # Private application code
├── pkg/ # Public library code
├── .env # Environment variables
├── .env.example # Example environment variables
├── go.mod # Go module definition
└── go.sum # Go module checksums
API Documentation
- api/stripe/webhooks [POST]: Where the webhooks will be send from stripe.
- api/stripe/ [GET]: Call this request with a productId query params to get a checkout URL.
Development
To run the project in development mode:
- Ensure MongoDB is running locally
- Set up your Stripe account and get API keys
- Configure the
.envfile with your credentials - Run the application using
go run cmd/server/main.go
Production Deployment
For production deployment:
- Set
PRODUCTION=truein your environment - Update
CLIENT_URLto your production frontend URL - Use a secure MongoDB instance
- Configure Stripe webhook endpoints
- Use HTTPS in production