A simple Express.js API for handling payments using Stripe, designed to work with the Amazon Clone frontend. 🚀
Repository: GitHub 📂
- 💳 Payment Processing: Create payment intents using Stripe for secure transactions.
- 🌐 CORS Support: Configured to allow cross-origin requests from the frontend.
⚠️ Error Handling: Proper error responses for invalid requests.- 🔐 Environment Configuration: Uses environment variables for sensitive data like Stripe keys.
- 🟢 Node.js: JavaScript runtime for server-side development.
- 🚀 Express.js: Web framework for building the API.
- 💳 Stripe: Payment processing library.
- 🌐 CORS: Middleware for handling cross-origin requests.
- 📄 Dotenv: For loading environment variables.
-
📥 Clone the repository:
git clone <repository-url> cd amazon-api
-
📦 Install dependencies:
npm install
-
🔧 Set up environment variables: Create a
.envfile in the root directory and add your Stripe secret key:STRIPE_KEY=your_stripe_secret_key_here -
▶️ Start the server:- For development:
npm run dev - For production:
npm start
The server will run on
http://localhost:5000. 🌐 - For development:
- 📋 Description: Health check endpoint.
- 📤 Response:
{ "message": "Success!" }
- 💳 Description: Creates a Stripe payment intent.
- 🔍 Query Parameters:
total(integer): The total amount in cents (e.g., 1000 for $10.00).
- 📤 Response (Success):
{ "clientSecret": "pi_xxx_secret_xxx" } - ❌ Response (Error):
{ "message": "Total must be greater than 0" }
This API is intended to be used with the Amazon Clone frontend application. It handles payment processing for orders. 🛒
The API is deployed and available at: https://amazon-api-0az0.onrender.com 🌐
curl -X POST "https://amazon-api-0az0.onrender.com/payment/create?total=1000"For local development, use http://localhost:5000.
STRIPE_KEY: Your Stripe secret key. Obtain this from your Stripe dashboard. 🔑
- 🍴 Fork the repository.
- 🌿 Create a feature branch.
- 🔄 Make your changes.
- ✅ Test thoroughly.
- 📤 Submit a pull request.
This project is licensed under the ISC License. 📜
This project is created for educational purposes to demonstrate payment processing with Stripe in test mode. 💳
- Card Number: 4242 4242 4242 4242 (Visa)
- CVC: Any 3 digits
- Expiration Date: Any date after today (MM/YY)
- Postal Code: Any valid postal code