9.4 KiB
9.4 KiB
Dodo Payments Testing Checklist
Pre-Testing Setup
- Ensure
DODO_PAYMENTS_API_KEYis set correctly (test mode for testing) - Verify all subscription product IDs are configured in environment variables
- Confirm webhook endpoint is accessible and configured in Dodo dashboard
- Have test payment methods available in Dodo test mode
Scenario 1: Upgrade Between Paid Plans
Test: Starter → Professional
- User starts with active Starter subscription
- Navigate to Settings page
- Change plan dropdown to "Professional"
- Click "Save Changes"
- Verify confirmation modal shows upgrade message with immediate charge explanation
- Click "Confirm"
- Expected:
- Status shows "Changing subscription plan..."
- API calls
POST /api/accountwith new plan - Server calls Dodo
POST /subscriptions/{id}/change-plan - User is charged the price difference
- Plan updates immediately to Professional
- Success message: "Subscription plan changed successfully!"
- Page shows updated plan without reload
Test: Starter → Enterprise
- Follow same steps as above but select "Enterprise"
- Verify larger price difference is charged
- Verify plan updates correctly
Scenario 2: Downgrade Between Paid Plans
Test: Professional → Starter
- User starts with active Professional subscription
- Navigate to Settings page
- Change plan dropdown to "Starter"
- Click "Save Changes"
- Verify confirmation modal shows downgrade message with credit explanation
- Click "Confirm"
- Expected:
- Status shows "Changing subscription plan..."
- API calls Change Plan API with
difference_immediatelyproration - Credit applied to subscription for future renewals
- Plan updates immediately to Starter
- Success message shown
- Subscription continues without interruption
Test: Enterprise → Professional
- Follow same steps as above
- Verify larger credit is applied
Scenario 3: Downgrade to Free Plan
Test: Any Paid Plan → Hobby
- User starts with active paid subscription (Starter/Professional/Enterprise)
- Navigate to Settings page
- Change plan dropdown to "Hobby (free)"
- Click "Save Changes"
- Verify confirmation modal warns about feature loss
- Click "Confirm"
- Expected:
- Status shows "Cancelling subscription..."
- API calls
POST /api/accountwith plan: hobby - Server calls
cancelDodoSubscription() - Dodo subscription is cancelled (DELETE or PATCH with cancel_at_next_billing_date)
- User plan set to "hobby"
- Billing status set to "active" (for free plan)
- subscriptionRenewsAt, billingCycle, subscriptionCurrency cleared
- Success message: "Downgraded to free plan successfully"
Verify in Dodo Dashboard
- Subscription shows as "cancelled" or "cancel_at_next_billing_date" set to true
- No future charges scheduled
Scenario 4: Upgrade from Free to Paid
Test: Hobby → Starter
- User starts with free Hobby plan
- Navigate to Settings page
- Change plan dropdown to "Starter"
- Click "Save Changes"
- Verify confirmation modal indicates checkout required
- Click "Confirm"
- Expected:
- Status shows "Starting checkout..."
- API calls
POST /api/subscription/checkout - Inline checkout modal opens
- User completes payment in Dodo checkout
- After payment, redirected back to app
- Plan updates to Starter
Scenario 5: Cancel Subscription Button
Test: Cancel Active Subscription
- User has active paid subscription
- Navigate to Settings page
- Click "Cancel Subscription" button
- Verify confirmation modal warns about cancellation
- Click "Confirm"
- Expected:
- Status shows "Updating subscription..."
- API calls
POST /api/subscription/cancel - Server calls
cancelDodoSubscription()with reason: 'subscription_cancel' - Dodo subscription cancelled
- billingStatus set to "cancelled"
- Success message: "Subscription cancelled. Access will continue until end of billing period."
- Cancel button changes to "Resume" or subscription status shows cancelled
Verify Access Continuation
- User retains access until current period ends
- No automatic charges after current period
Scenario 6: Billing Cycle Change
Test: Monthly → Yearly (Same Plan)
- User has monthly Professional subscription
- Navigate to Settings page
- Change billing cycle to "Yearly"
- Keep plan as "Professional"
- Click "Save Changes"
- Expected:
- This should likely redirect to checkout for the new billing cycle
- OR handle as a plan change (depending on implementation)
- Verify correct behavior based on business logic
Scenario 7: Webhook Events
After Upgrade (Starter → Professional)
subscription.plan_changedwebhook received- Webhook handler updates user.plan in database
- Email sent to user confirming plan change
After Downgrade (Professional → Starter)
subscription.plan_changedwebhook received- User plan updated
- Email notification sent
After Cancellation
subscription.canceledwebhook received- User billing status updated
- Cancellation email sent
If Payment Fails on Upgrade
subscription.on_holdwebhook received- User notified to update payment method
- Plan change doesn't complete until payment succeeds
Error Scenarios
Test: Invalid Plan Change
- User tries to change to invalid plan
- Expected: Error message shown, no changes made
Test: Network Failure During Plan Change
- Simulate network error
- Expected: Error message, user can retry
Test: Insufficient Payment on Upgrade
- Use test card with insufficient funds
- Expected:
- Payment fails
subscription.on_holdwebhook- User notified
- Plan doesn't change until payment succeeds
Test: Change Plan Without Active Subscription
- User on free plan tries paid-to-paid change
- Expected: Error requiring checkout flow
Database Verification
After each test, verify in database:
user.planupdated correctlyuser.billingCyclematches subscriptionuser.subscriptionCurrencycorrectuser.dodoSubscriptionIdmaintained (or cleared for free)user.billingStatusappropriate ("active" or "cancelled")user.subscriptionRenewsAtupdated (or null for free)
Dodo Dashboard Verification
For each plan change:
- Subscription status updated in Dodo dashboard
- Correct product_id shown
- Next billing date accurate
- Payment method attached
- Cancellation status correct if applicable
Logs Verification
Check server logs for:
- "Dodo subscription plan changed" with correct details
- "Dodo subscription cancelled" when cancelling
- No error messages in logs
- Proper userId, subscriptionId, and plan information logged
User Experience
- All confirmation modals display appropriate messages
- Status messages are clear and accurate
- No UI glitches or broken states
- Loading states shown during API calls
- Success/error states properly displayed
- Page doesn't require manual refresh to show changes
Edge Cases
- Rapid Plan Changes: User changes plan multiple times quickly
- Concurrent Updates: Two tabs open, changes made in both
- Expired Session: Session expires during plan change
- Already Changed: User tries to change to current plan
- Pending Payment: Change plan while previous payment pending
Performance
- Plan change completes within 3 seconds
- No unnecessary API calls
- Proper error handling doesn't cause delays
- Webhook processing is fast
Security
- CSRF token validated on all plan change requests
- User can only change their own plan
- Admin privileges not required for own plan changes
- Webhook signatures verified
- No sensitive data exposed in responses
Documentation
- DODO_PLAN_CHANGE_FIX.md accurately describes implementation
- Code comments explain complex logic
- Error messages are helpful
- Logging provides adequate debugging information
Post-Testing
- All test scenarios passed
- No errors in production logs
- Dodo dashboard shows correct subscription states
- Users receive appropriate email notifications
- Credits from downgrades apply correctly to future renewals
- Monitor for any user reports of issues
Rollback Plan
If issues are discovered:
- Revert server.js changes
- Revert settings.html changes
- Notify users of temporary checkout requirement for plan changes
- Fix issues in development
- Re-test thoroughly
- Re-deploy
Success Criteria
✅ All upgrade scenarios work correctly with immediate charging ✅ All downgrade scenarios apply credits properly ✅ Free plan downgrades cancel subscriptions at Dodo ✅ Webhook events update user plans automatically ✅ No service interruption during plan changes ✅ Clear user messaging throughout all flows ✅ Proper error handling and recovery ✅ Dodo dashboard reflects all changes accurately