Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ NEXT_PUBLIC_DYNAMIC_ENVIRONMENT_ID=your_dynamic_environment_id_here
# Get your API key from: https://www.alchemy.com/
ALCHEMY_API_KEY=your_alchemy_api_key

# Enable testnet chains (Sepolia) for development/testing
# Set to 'true' to enable Sepolia testnet support
# IMPORTANT: Set this in your .env.local for development!
NEXT_PUBLIC_ENABLE_TESTNET_CHAINS=false

# EVM payment wallet address (same address used across all EVM chains)
# This is where users send their stablecoin payments on Ethereum, Base, Arbitrum, Optimism, Polygon
# NEXT_PUBLIC_ prefix is required because it's displayed in the browser UI
Expand Down Expand Up @@ -76,6 +81,16 @@ NEXT_PUBLIC_DAI_CONTRACT_ARBITRUM=0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1
NEXT_PUBLIC_DAI_CONTRACT_OPTIMISM=0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1
NEXT_PUBLIC_DAI_CONTRACT_POLYGON=0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063

# Sepolia Testnet (DEV MODE ONLY - NODE_ENV=development)
# Get testnet tokens from Sepolia faucets (see STABLECOIN_PAYMENTS.md)
USDC_CONTRACT_SEPOLIA=0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238
USDT_CONTRACT_SEPOLIA=0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0
DAI_CONTRACT_SEPOLIA=0xFF34B3d4Aee8ddCd6F9AFFFB6Fe49bD371b8a357

NEXT_PUBLIC_USDC_CONTRACT_SEPOLIA=0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238
NEXT_PUBLIC_USDT_CONTRACT_SEPOLIA=0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0
NEXT_PUBLIC_DAI_CONTRACT_SEPOLIA=0xFF34B3d4Aee8ddCd6F9AFFFB6Fe49bD371b8a357

# =============================================================================
# STRIPE PAYMENTS - Credit/Debit Card Payments
# =============================================================================
Expand Down
42 changes: 37 additions & 5 deletions STABLECOIN_PAYMENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,16 @@ NEXT_PUBLIC_DYNAMIC_ENVIRONMENT_ID=your_dynamic_environment_id

### 2. Supported Chains

The system supports 5 EVM chains:
The system supports 5 EVM chains (production):
- **Ethereum**
- **Base**
- **Arbitrum**
- **Optimism**
- **Polygon**

The system also supports **Sepolia testnet** when explicitly enabled:
- **Sepolia** (Ethereum testnet) - Enable by setting `NEXT_PUBLIC_ENABLE_TESTNET_CHAINS=true` in `.env.local`

**USDC**, **USDT**, and **DAI** are accepted on all chains.

### 3. Pricing Model
Expand Down Expand Up @@ -212,10 +215,39 @@ Response:

### Testnet Testing (Recommended)

1. Get testnet stablecoins from faucets (Sepolia, Base Sepolia, etc.)
2. Configure testnet payment wallet in `.env.local`
3. Send test transaction
4. Verify subscription activates
**Enable Sepolia testnet by adding this to your `.env.local` file:**
```bash
NEXT_PUBLIC_ENABLE_TESTNET_CHAINS=true
```

Then restart your development server (`npm run dev`).

1. **Get testnet ETH for gas fees:**
- [Alchemy Sepolia Faucet](https://sepoliafaucet.com/)
- [Infura Sepolia Faucet](https://www.infura.io/faucet/sepolia)

2. **Get testnet stablecoins:**
- **USDC (Sepolia)**: [Circle Testnet Faucet](https://faucet.circle.com/) - Use address `0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238`
- **USDT (Sepolia)**: Deploy your own or use testnet faucet at `0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0`
- **DAI (Sepolia)**: [MakerDAO Testnet Faucet](https://app.spark.fi/faucet/) - Use address `0xFF34B3d4Aee8ddCd6F9AFFFB6Fe49bD371b8a357`

3. **Configure payment wallet:**
- Set `NEXT_PUBLIC_EVM_PAYMENT_WALLET_ADDRESS` in `.env.local` to your test wallet address
- This is where testnet payments will be sent

4. **Switch wallet to Sepolia network:**
- Connect wallet via Dynamic.xyz
- Switch to Sepolia network in your wallet
- The UI will show "🧪 TESTNET" indicator when connected to Sepolia

5. **Send test transaction:**
- Choose amount (e.g., $1 USD = 1 USDC)
- Select stablecoin (USDC, USDT, or DAI)
- Confirm transaction in wallet

6. **Verify subscription activates:**
- Wait ~30 seconds for transaction confirmation
- Refresh page to check subscription status

### Mainnet Testing (Small Amount)

Expand Down
3 changes: 3 additions & 0 deletions app/api/check-subscription/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// CRITICAL: Apply fetch polyfill BEFORE any other imports
import '@/lib/fetch-polyfill';

import { NextRequest, NextResponse } from 'next/server';
import { checkCombinedSubscription } from '@/lib/subscription-manager';

Expand Down
Loading
Loading