Fix Razorpay Payment Integration E2E Tests and API Authentication

Resolved 💬 2 comments Opened Aug 22, 2025 by sunderfitwithpari Closed Nov 29, 2025

Issue Summary

The Razorpay payment integration E2E tests are failing due to authentication issues, preventing validation of real API integration. The test infrastructure is properly set up but cannot authenticate with production credentials to test actual payment flows.

Current Status

✅ Working Components

  • Test environment setup and database seeding
  • Payment gateway sandbox configuration
  • Test data fixtures (6 Razorpay cards, test plans, users)
  • Static page validation for subscription flows
  • Gateway selection logic tests

❌ Failing Components

  • Authentication with real production credentials (smagar@fitwithpari.com)
  • Real API endpoint testing (/functions/v1/subscription-checkout-session)
  • Razorpay checkout session creation validation
  • Payment failure scenario testing
  • Cross-browser payment integration tests

Technical Details

Authentication Issues

Error: locator.click: Error: strict mode violation: 
locator('[data-testid="login-submit"]') resolved to 2 elements:
1) <button>Login</button>
2) <button type="submit">Login with Supabase</button>

Test Files Affected

  • e2e/tests/api-integration/payment-gateway-integration.spec.ts
  • e2e/tests/payment-razorpay.spec.ts
  • e2e/tests/payment-razorpay-fixed.spec.ts

API Endpoints

  • ${VITE_SUPABASE_URL}/functions/v1/subscription-checkout-session
  • Razorpay order creation and validation
  • Payment confirmation and webhook handling

Required Fixes

1. Authentication Resolution

  • [ ] Fix login button selector ambiguity in e2e/page-objects/auth.page.ts:96
  • [ ] Validate production credentials or create dedicated test credentials
  • [ ] Ensure Supabase session management works in test environment

2. Razorpay API Integration

  • [ ] Validate Razorpay checkout session creation for INR currency
  • [ ] Test Razorpay order configuration and metadata
  • [ ] Verify GST calculation and Indian pricing structure
  • [ ] Test payment failure scenarios and retry mechanisms

3. E2E Test Improvements

  • [ ] Fix resource loading 404 errors during test execution
  • [ ] Improve test isolation and cleanup
  • [ ] Add mobile payment interface testing
  • [ ] Validate Strong Customer Authentication flows

4. Payment Flow Validation

  • [ ] Test complete payment journey: plan selection → checkout → payment → confirmation
  • [ ] Validate currency detection and gateway selection (INR → Razorpay)
  • [ ] Test payment abandonment and recovery scenarios
  • [ ] Verify webhook event handling and subscription activation

Test Coverage Goals

Critical Path (P0)

  • [x] Plan selection page loads correctly
  • [ ] Razorpay gateway selection for Indian users
  • [ ] Checkout session creation with real API
  • [ ] Payment form rendering and validation
  • [ ] Successful payment completion flow

Error Handling (P1)

  • [ ] Payment decline scenarios
  • [ ] Network failure recovery
  • [ ] Invalid payment data handling
  • [ ] Session timeout management

Security & Compliance (P1)

  • [ ] Payment data security validation
  • [ ] PCI compliance verification
  • [ ] Sensitive data redaction in logs
  • [ ] GST calculation accuracy

Environment Details

  • Node Version: 20
  • Test Framework: Playwright with 5 workers
  • Payment Gateway: Razorpay (India) + Stripe (International)
  • Authentication: Supabase
  • Deployment: Netlify with static subscription pages

Success Criteria

  1. All Razorpay E2E tests pass with real API integration
  2. Authentication works consistently across test environments
  3. Payment flows complete successfully for Indian market (INR)
  4. Error scenarios are properly handled and tested
  5. Test execution time under 2 minutes for payment suite

Related Files

e2e/
├── tests/
│   ├── api-integration/payment-gateway-integration.spec.ts
│   ├── payment-razorpay.spec.ts
│   └── payment-razorpay-fixed.spec.ts
├── page-objects/auth.page.ts
├── fixtures/
│   ├── payments.fixture.ts
│   └── auth-credentials.ts
└── config/test-config.ts

src/modules/subscription/
├── infrastructure/gateways/
├── application/services/PaymentOrchestrator.ts
└── presentation/hooks/usePayment.ts

Priority

High - Blocks production deployment validation for Indian market payment processing.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗