Prerequisites
- A PayPal Business account
- PayPal REST API credentials
1. Create a PayPal app
- Go to developer.paypal.com
- Navigate to Apps & Credentials
- Create a new app (one for sandbox, one for live)
- Copy the Client ID and Secret
2. Configure in .env
PayPal credentials are set in the environment file:
3. Set up the webhook
- In the PayPal developer portal, go to your app → Webhooks
- Add webhook URL:
- Subscribe to these events:
PAYMENT.CAPTURE.COMPLETEDBILLING.SUBSCRIPTION.ACTIVATEDBILLING.SUBSCRIPTION.CANCELLEDBILLING.SUBSCRIPTION.SUSPENDEDPAYMENT.SALE.COMPLETED
- Copy the Webhook ID and set
PAYPAL_WEBHOOK_IDin.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
- 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. SetPAYPAL_MODE=sandbox and use sandbox credentials.