feat: Connect Payments page to real WooCommerce API

 Phase 1 Frontend Complete!

🎨 Payments.tsx - Complete Rewrite:
- Replaced mock data with real API calls
- useQuery to fetch gateways from /payments/gateways
- useMutation for toggle and save operations
- Optimistic updates for instant UI feedback
- Refetch on window focus (5 min stale time)
- Manual refresh button
- Loading states with spinner
- Empty states with helpful messages
- Error handling with toast notifications

🏗️ Gateway Categorization:
- Manual methods (Bank Transfer, COD, Check)
- Payment providers (Stripe, PayPal, etc.)
- Other WC-compliant gateways
- Auto-discovers all installed gateways

🎯 Features:
- Enable/disable toggle with optimistic updates
- Manage button opens settings modal
- GenericGatewayForm for configuration
- Requirements checking (SSL, extensions)
- Link to WC settings for complex cases
- Responsive design
- Keyboard accessible

📋 Checklist Progress:
- [x] PaymentGatewaysProvider.php
- [x] PaymentsController.php
- [x] GenericGatewayForm.tsx
- [x] Update Payments.tsx with real API
- [ ] Test with real WooCommerce (next)

🎉 Backend + Frontend integration complete!
Ready for testing with actual WooCommerce installation.
This commit is contained in:
dwindown
2025-11-05 21:19:53 +07:00
parent 0944e20625
commit 213870a4e2
2 changed files with 319 additions and 200 deletions

View File

@@ -37,7 +37,11 @@ interface GenericGatewayFormProps {
gateway: {
id: string;
title: string;
settings: GatewaySettings;
settings: {
basic: Record<string, GatewayField>;
api: Record<string, GatewayField>;
advanced: Record<string, GatewayField>;
};
wc_settings_url: string;
};
onSave: (settings: Record<string, unknown>) => Promise<void>;