Skip to content

devUnixx/afripay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

AfriPay πŸ’Έ

Instant international payments for Nigerian freelancers β€” powered by Stellar and stablecoins.

CI License: Apache 2.0 Built on Stellar

AfriPay enables freelancers to receive payments from global clients in minutes, not days, with fees under 1%. Blockchain complexity is completely abstracted β€” users see invoices, balances, and bank withdrawals, nothing else.


🎯 The Problem

  • Traditional payment methods (PayPal, Wise) charge 5–10% fees and take 3–7 days to settle
  • Nigerian freelancers lose significant portions of their earnings to fees and exchange rate markups
  • Crypto solutions are too complex for non-technical users

βœ… Our Solution

  1. Create invoice β†’ Get a shareable payment link
  2. Client pays β†’ Card payment converts to USDC on Stellar
  3. Instant settlement β†’ Funds arrive in 3–5 seconds
  4. Withdraw to bank β†’ Convert to NGN via Yellow Card, instant bank transfer
  5. Keep 99%+ β†’ Fees under 1%, zero crypto knowledge required

πŸ› οΈ Tech Stack

Layer Technology
Frontend Next.js 15 (App Router), React 19, Tailwind CSS v4
Backend Next.js API Routes, Prisma ORM, PostgreSQL (Neon)
Auth Privy β€” OAuth + embedded Stellar wallets
Blockchain Stellar Network β€” USDC stablecoin
On-ramp MoonPay β€” card β†’ USDC
Off-ramp Yellow Card β€” USDC β†’ NGN bank transfer
Email Resend
Deployment Vercel

🌟 Why Stellar?

  • ⚑ 3–5 second settlement with fees < $0.01
  • 🏦 Yellow Card integration β€” direct off-ramp to Nigerian banks in 20+ African countries
  • 🌍 475,000+ on/off-ramp access points worldwide
  • πŸ”’ Battle-tested β€” used by MoneyGram, Onafriq, and major African payment providers
  • πŸ’° Low cost β€” ~$0.75 per wallet (XLM reserves) vs building custom infrastructure

πŸ”„ How It Works

Client Card Payment
    ↓
MoonPay (Fiat β†’ USDC on Stellar)
    ↓
Freelancer's Stellar Wallet (Privy embedded)
    ↓
Yellow Card API (USDC β†’ NGN)
    ↓
Nigerian Bank Account

πŸ“ Project Structure

afripay/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ (auth)/              # Login, register, onboarding
β”‚   β”œβ”€β”€ (dashboard)/         # Authenticated app pages
β”‚   β”‚   β”œβ”€β”€ dashboard/       # Overview with stats
β”‚   β”‚   β”œβ”€β”€ invoices/        # Invoice list + create + detail
β”‚   β”‚   β”œβ”€β”€ withdrawals/     # Withdrawal history + initiate
β”‚   β”‚   └── settings/        # Profile & wallet settings
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ invoices/        # CRUD
β”‚   β”‚   β”œβ”€β”€ moonpay/sign/    # Signed widget URL
β”‚   β”‚   β”œβ”€β”€ webhooks/        # MoonPay + Yellow Card
β”‚   β”‚   β”œβ”€β”€ withdrawals/     # Initiate + list
β”‚   β”‚   β”œβ”€β”€ wallet/balance/  # USDC balance
β”‚   β”‚   β”œβ”€β”€ users/onboard/   # Onboarding
β”‚   β”‚   └── cron/            # Scheduled jobs
β”‚   β”œβ”€β”€ pay/[token]/         # Public payment page (no auth)
β”‚   └── page.tsx             # Landing page
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ ui/                  # Badge, CopyButton, Toaster
β”‚   β”œβ”€β”€ dashboard/           # Stats, RecentInvoices
β”‚   β”œβ”€β”€ sidebar.tsx
β”‚   β”œβ”€β”€ navbar.tsx
β”‚   β”œβ”€β”€ payment-widget.tsx
β”‚   └── providers.tsx
β”œβ”€β”€ hooks/
β”‚   β”œβ”€β”€ use-invoices.ts
β”‚   β”œβ”€β”€ use-wallet.ts
β”‚   └── use-withdrawals.ts
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ stellar.ts           # Stellar SDK helpers
β”‚   β”œβ”€β”€ moonpay.ts           # MoonPay URL signing + webhook verify
β”‚   β”œβ”€β”€ yellowcard.ts        # Yellow Card API client
β”‚   β”œβ”€β”€ resend.ts            # Email templates
β”‚   β”œβ”€β”€ auth.ts              # Privy server-side auth
β”‚   β”œβ”€β”€ prisma.ts            # Prisma singleton
β”‚   └── utils.ts             # cn(), formatDate(), formatCurrency()
β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ schema.prisma        # Database schema
β”‚   └── seed.ts              # Demo data
└── docs/
    β”œβ”€β”€ architecture.md      # System design
    └── api.md               # API reference

πŸš€ Getting Started

Prerequisites

Installation

# Clone the repo
git clone https://github.com/devUnixx/afripay.git
cd afripay

# Install dependencies
npm install

# Set up environment variables
cp .env.example .env.local
# Edit .env.local with your credentials

# Push database schema
npx prisma db push

# (Optional) Seed demo data
npm run db:seed

# Start development server
npm run dev

Open http://localhost:3000.

Environment Variables

See .env.example for all required variables. Key ones:

Variable Description
DATABASE_URL PostgreSQL connection string
NEXT_PUBLIC_PRIVY_APP_ID Privy app ID
PRIVY_APP_SECRET Privy app secret
NEXT_PUBLIC_MOONPAY_API_KEY MoonPay publishable key
MOONPAY_SECRET_KEY MoonPay secret key
MOONPAY_WEBHOOK_SECRET MoonPay webhook signing secret
YELLOW_CARD_API_KEY Yellow Card API key
YELLOW_CARD_API_SECRET Yellow Card API secret
RESEND_API_KEY Resend API key
CRON_SECRET Secret for cron job authorization

πŸ§ͺ Testing

npm test           # Run all tests
npm run test:ci    # CI mode with coverage
npm run type-check # TypeScript check
npm run lint       # ESLint

πŸ•°οΈ Cron Jobs

Configured in vercel.json and protected by CRON_SECRET.

Job Schedule Description
cancel-overdue-invoices 0 2 * * * (daily 2AM UTC) Cancels PENDING invoices with dueDate > 90 days ago. Skips invoices with active escrow, active dispute, or doNotAutoCancel: true.

Test locally:

curl -H "Authorization: Bearer YOUR_CRON_SECRET" \
  http://localhost:3000/api/cron/cancel-overdue-invoices

🚒 Deployment

Vercel (recommended)

  1. Push to GitHub
  2. Import project in Vercel
  3. Add all environment variables from .env.example
  4. Deploy β€” cron jobs are configured automatically via vercel.json

Webhooks Setup

After deploying, configure these webhook URLs in your provider dashboards:

Provider Webhook URL
MoonPay https://afripay.io/api/webhooks/moonpay
Yellow Card https://afripay.io/api/webhooks/yellowcard

🀝 Contributing

Contributions are welcome! Please read CONTRIBUTING.md first.

  1. Fork the repo
  2. Create a branch: git checkout -b feat/your-feature
  3. Commit with conventional commits: feat: add invoice PDF export
  4. Open a pull request

πŸ“– Documentation


πŸ“„ License

Licensed under the Apache License 2.0.


Built with ❀️ for Nigerian freelancers. Powered by Stellar.

About

stellar, payments, nigeria, africa, usdc, fintech, nextjs, open-source, freelance, moonpay, yellowcard.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages