Skip to main content

Prerequisites

1. Create a PayPal app

  1. Go to developer.paypal.com
  2. Navigate to Apps & Credentials
  3. Create a new app (one for sandbox, one for live)
  4. Copy the Client ID and Secret

2. Configure in .env

PayPal credentials are set in the environment file:
PAYPAL_MODE=live               # sandbox | live
PAYPAL_LIVE_CLIENT_ID=your_client_id
PAYPAL_LIVE_CLIENT_SECRET=your_client_secret
PAYPAL_CURRENCY=USD
PAYPAL_WEBHOOK_ID=             # Set after step 3
For sandbox/testing:
PAYPAL_MODE=sandbox
PAYPAL_SANDBOX_CLIENT_ID=your_sandbox_client_id
PAYPAL_SANDBOX_CLIENT_SECRET=your_sandbox_secret

3. Set up the webhook

  1. In the PayPal developer portal, go to your app → Webhooks
  2. Add webhook URL:
    https://yourdomain.com/paypal/webhook
    
  3. Subscribe to these events:
    • PAYMENT.CAPTURE.COMPLETED
    • BILLING.SUBSCRIPTION.ACTIVATED
    • BILLING.SUBSCRIPTION.CANCELLED
    • BILLING.SUBSCRIPTION.SUSPENDED
    • PAYMENT.SALE.COMPLETED
  4. Copy the Webhook ID and set PAYPAL_WEBHOOK_ID in .env

4. Payment flow

StartMyVPN supports two PayPal payment modes: Checkout (one-time):
  • Customer is redirected to PayPal to approve payment
  • On return, StartMyVPN captures the payment and activates the service
Subscriptions (recurring):
  • A PayPal subscription plan is created automatically
  • Customer approves a recurring billing agreement
  • PayPal charges automatically at each renewal; webhook triggers service renewal

Testing

Use PayPal sandbox accounts to simulate buyer and seller. Set PAYPAL_MODE=sandbox and use sandbox credentials.