fix: Critical payment toggle sync and 3rd party gateway settings
✅ Issue 1: Toggle Not Saving (CRITICAL FIX) Problem: Toggle appeared to work but didn't persist Root Cause: Missing query invalidation after toggle Solution: - Added queryClient.invalidateQueries after successful toggle - Now fetches real server state after optimistic update - Ensures SPA and WooCommerce stay in sync ✅ Issue 2: SearchableSelect Default Value Problem: Showing 'Select country...' when Indonesia selected Root Cause: WooCommerce stores country as 'ID:DKI_JAKARTA' Solution: - Split country:state format in backend - Extract country code only for select - Added timezone fallback to 'UTC' if empty ✅ Issue 3: 3rd Party Gateway Settings Problem: TriPay showing 'Configure in WooCommerce' link Solution: - Replaced external link with Settings button - Now opens GenericGatewayForm modal - All WC form_fields render automatically - TriPay fields (enable_icon, expired, checkout_method) work! 📋 Files Modified: - Payments.tsx: Added invalidation + settings button - StoreSettingsProvider.php: Split country format - All 3rd party gateways now configurable in SPA 🎯 Result: ✅ Toggle saves correctly to WooCommerce ✅ Country/timezone show selected values ✅ All gateways with form_fields are editable ✅ No more 'Configure in WooCommerce' for compliant gateways
This commit is contained in:
@@ -82,6 +82,8 @@ export default function PaymentsPage() {
|
||||
toast.error('Failed to update gateway');
|
||||
},
|
||||
onSuccess: () => {
|
||||
// Invalidate to fetch real state from server
|
||||
queryClient.invalidateQueries({ queryKey: ['payment-gateways'] });
|
||||
toast.success('Gateway updated successfully');
|
||||
},
|
||||
});
|
||||
@@ -303,20 +305,15 @@ export default function PaymentsPage() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
asChild
|
||||
>
|
||||
<a
|
||||
href={gateway.wc_settings_url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
{gateway.enabled && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => handleManageGateway(gateway)}
|
||||
>
|
||||
<ExternalLink className="h-4 w-4 mr-2" />
|
||||
Configure in WooCommerce
|
||||
</a>
|
||||
</Button>
|
||||
<Settings className="h-4 w-4" />
|
||||
</Button>
|
||||
)}
|
||||
<ToggleField
|
||||
id={gateway.id}
|
||||
label=""
|
||||
|
||||
Reference in New Issue
Block a user