
This API provides endpoints for: - Product and inventory management - Customer management - Order processing - Payment processing with Stripe integration - User authentication generated with BackendIM... (backend.im)
Retail Management and Payment API
A FastAPI-based REST API for retail management including inventory, orders, sales, and payment processing with Stripe integration.
Features
- Product Management: Create, read, update, and delete products
- Inventory Management: Track and update product inventory
- Customer Management: Manage customer information
- Order Management: Process and track customer orders
- Payment Processing: Process payments via Stripe integration
- Authentication: JWT-based user authentication and authorization
Tech Stack
- Framework: FastAPI
- Database: SQLite (with SQLAlchemy ORM)
- Migrations: Alembic
- Authentication: JWT (JSON Web Tokens)
- Payment Processing: Stripe SDK
API Endpoints
Authentication
POST /api/v1/auth/login
- Get access tokenPOST /api/v1/auth/register
- Register a new userGET /api/v1/auth/me
- Get current user info
Products
GET /api/v1/products
- List all productsPOST /api/v1/products
- Create a new productGET /api/v1/products/{product_id}
- Get a single productPUT /api/v1/products/{product_id}
- Update a productDELETE /api/v1/products/{product_id}
- Delete a product
Inventory
GET /api/v1/inventory
- List all inventory itemsPOST /api/v1/inventory
- Create a new inventory recordGET /api/v1/inventory/{product_id}
- Get inventory for a productPUT /api/v1/inventory/{inventory_id}
- Update an inventory recordPUT /api/v1/inventory/{inventory_id}/adjust
- Adjust inventory quantity
Customers
GET /api/v1/customers
- List all customersPOST /api/v1/customers
- Create a new customerGET /api/v1/customers/{customer_id}
- Get a customerPUT /api/v1/customers/{customer_id}
- Update a customerDELETE /api/v1/customers/{customer_id}
- Delete a customer
Orders
GET /api/v1/orders
- List all ordersPOST /api/v1/orders
- Create a new orderGET /api/v1/orders/{order_id}
- Get an orderPUT /api/v1/orders/{order_id}
- Update an orderDELETE /api/v1/orders/{order_id}
- Cancel an order
Payments
POST /api/v1/payments/create-payment-intent/{order_id}
- Create a Stripe payment intentPOST /api/v1/payments/webhook
- Handle Stripe webhook events
Health Check
GET /health
- API health status check
Setup and Installation
Prerequisites
- Python 3.8+
- pip (Python package manager)
Installation Steps
- Clone the repository:
git clone [repository_url]
cd retailmanagementandpaymentapi
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables (create a
.env
file in the project root):
JWT_SECRET_KEY=your-secret-key-change-in-production
STRIPE_API_KEY=your-stripe-api-key
STRIPE_WEBHOOK_SECRET=your-stripe-webhook-secret
- Run database migrations:
alembic upgrade head
- Start the development server:
uvicorn main:app --reload
API Documentation
Once the server is running, you can access the auto-generated API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Testing the API
For testing the API endpoints, you can use the Swagger UI documentation or tools like Postman or curl.
Stripe Testing
For testing Stripe integration:
- Use Stripe's test API keys
- Use Stripe's test card numbers for payment simulation:
- Test successful payment: 4242 4242 4242 4242
- Test failed payment: 4000 0000 0000 0002
Description
Languages
Python
99.2%
Mako
0.8%