Skip to content

wilsonwang0713/demopay

Repository files navigation

DemoPay - Android Payment Demo

A proof-of-concept Android application demonstrating Stripe and Phantom wallet (Solana) payment integrations.

Features

  • Stripe Integration: Credit card payments using Stripe SDK with test mode
  • Phantom Wallet Integration: Solana Devnet payments via Mobile Wallet Adapter
  • Backend API: Node.js server handling payment processing

Prerequisites

  1. Android Development:

    • Android Studio
    • Android SDK (API 23+)
    • Java/Kotlin development environment
  2. Backend Setup:

    • Node.js (v16 or higher)
    • npm or yarn
  3. Accounts & Keys:

    • Stripe Test Account (for publishable and secret keys)
    • Phantom Wallet installed on Android device/emulator

Setup Instructions

1. Backend Setup

cd backend
npm install
cp .env.example .env

Edit .env file:

STRIPE_SECRET_KEY=sk_test_your_actual_stripe_secret_key
SOLANA_PRIVATE_KEY=[your_private_key_array_or_leave_empty_for_auto_generation]
SOLANA_RPC_URL=https://api.devnet.solana.com
PORT=3000

Start the backend server:

npm run dev

The server will run on http://localhost:3000

2. Android Setup

  1. Open Android Studio

  2. Open the android folder as a project

  3. Edit MainActivity.kt and update:

    • STRIPE_PUBLISHABLE_KEY with your actual Stripe publishable key
    • BASE_URL if your backend runs on a different address
  4. Sync project with Gradle files

  5. Build and run the app

3. Testing

Stripe Payments

  • Use test card: 4242 4242 4242 4242
  • Any future expiry date
  • Any 3-digit CVC

Phantom Wallet

  • Install Phantom wallet on your device
  • Switch to Devnet/Testnet in Phantom settings
  • Connect wallet in the app
  • Send test transactions (0.001 SOL)

Project Structure

demopay/
├── android/                 # Android application
│   ├── app/
│   │   ├── src/main/
│   │   │   ├── java/com/demopay/
│   │   │   │   ├── MainActivity.kt
│   │   │   │   └── ApiService.kt
│   │   │   └── res/         # Resources (layouts, strings, etc.)
│   │   └── build.gradle
│   └── build.gradle
├── backend/                 # Node.js server
│   ├── src/
│   │   └── server.js
│   ├── package.json
│   └── .env.example
└── README.md

API Endpoints

Backend Endpoints

  • GET /health - Health check and server info
  • POST /stripe/create-intent - Create Stripe PaymentIntent
  • POST /solana/pay - Send Solana payment
  • POST /solana/airdrop - Request SOL airdrop (Devnet only)
  • GET /solana/balance/:publicKey - Get wallet balance

Building APK

Debug APK

cd android
./gradlew assembleDebug

APK location: android/app/build/outputs/apk/debug/app-debug.apk

Release APK (for distribution)

cd android
./gradlew assembleRelease

APK location: android/app/build/outputs/apk/release/app-release.apk

Troubleshooting

Common Issues

  1. "No wallet found":

    • Install Phantom wallet
    • Ensure it's updated to latest version
  2. Network connection failed:

    • Check backend server is running
    • Update BASE_URL in MainActivity.kt
    • For emulator, use http://10.0.2.2:3000
    • For physical device, use your computer's LAN IP
  3. Stripe payment fails:

    • Verify Stripe keys are correct
    • Check backend logs for Stripe API errors
  4. Solana transaction fails:

    • Ensure wallet is on Devnet
    • Check server has sufficient SOL balance
    • Verify RPC endpoint is accessible

Testing Tips

  • Use Android Logcat for debugging: adb logcat | grep DemoPay
  • Monitor backend logs for API request details
  • Test on both emulator and physical device
  • Verify network connectivity between app and backend

Security Notes

⚠️ This is a demo application for testing only:

  • Uses Stripe test mode
  • Uses Solana Devnet (test network)
  • Not production-ready
  • Private keys are for development only

Future Enhancements

  • Move to Stripe Live mode and Solana Mainnet
  • Add transaction signing for arbitrary messages
  • Implement proper error handling and retry logic
  • Add support for multiple wallet providers
  • Improve UI/UX design

About

Android payment demo app with Stripe and Solana integration

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors