This project is a subscription-based platform built with Next.js, allowing users to log in using Discord and subscribe to various plans using the Stripe API. The platform also handles data exchange through Stripe webhooks and stores users in MongoDB.
- Features
- Technologies Used
- Architecture
- Prerequisites
- Installation
- Configuration
- Usage
- Stripe Webhook Setup
- Contributing
- License
- Discord Authentication: Users can log in using their Discord accounts.
- Subscription Plans: Users can subscribe to different plans using Stripe.
- Stripe Integration: Full integration with Stripe for payment processing.
- Webhook Handling: Receives and processes Stripe webhooks for subscription updates.
- MongoDB Integration: Stores user Stripe customer IDs in MongoDB.
- Next.js: The React framework for production.
- Discord OAuth2: For user authentication.
- Stripe API: For managing subscriptions and payment processing.
- Stripe Webhooks: For handling real-time updates from Stripe.
- MongoDB: For storing user data including Stripe customer IDs.
- Node.js
- npm or yarn
- Stripe account
- Discord Developer account
- MongoDB account
-
Clone the repository:
git clone /~https://github.com/your-username/your-repo-name.git cd your-repo-name
-
Install dependencies:
npm install # or yarn install
-
Create a
.env.local
file in the root directory and add the following environment variables:NEXT_BASE_URL=http://localhost:3000 NEXTAUTH_SECRET=ultra_secret_key DISCORD_CLIENT_ID=your-discord-client-id DISCORD_CLIENT_SECRET=your-discord-client-secret STRIPE_PUBLIC_KEY=your-stripe-public-key STRIPE_SECRET_KEY=your-stripe-secret-key STRIPE_WEBHOOK_SECRET=your-stripe-webhook-secret MONGODB_URI=your-mongodb-connect-uri
-
Update your Discord OAuth2 settings in the Discord Developer Portal:
- Redirect URI:
http://localhost:3000/api/auth/callback/discord
- Redirect URI:
-
Set up your Stripe account and add your webhook endpoint:
- Webhook endpoint URL:
http://localhost:3000/api/webhooks/stripe
- Webhook endpoint URL:
-
Start the development server:
npm run dev # or yarn dev
-
Open your browser and navigate to
http://localhost:3000
. -
Log in using your Discord account.
-
Subscribe to a plan using Stripe.
To handle real-time subscription updates from Stripe, you need to set up a webhook endpoint.
- Go to your Stripe Dashboard.
- Navigate to Developers > Webhooks.
- Click on "Add endpoint".
- Set the endpoint URL to
http://localhost:3000/api/webhooks/stripe
. - Select the events you want to listen to, such as
invoice.payment_succeeded
,customer.subscription.created
,customer.subscription.updated
, andcustomer.subscription.deleted
. - Copy the webhook signing secret and add it to your
.env.local
file asSTRIPE_WEBHOOK_SECRET
.
Contributions are welcome! Please fork the repository and submit a pull request with your changes.