last fix form master imp part 6

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-31 20:50:47 +00:00
parent 6953343026
commit b61bd6e64d
2 changed files with 38 additions and 17 deletions

View File

@@ -192,23 +192,19 @@ class BillingViewSet(viewsets.GenericViewSet):
@action(detail=False, methods=['get'], url_path='payment-methods', permission_classes=[AllowAny])
def list_payment_methods(self, request):
"""
Get available payment methods for a specific country.
Get available payment methods (global only).
Public endpoint - only returns enabled payment methods.
Does not expose sensitive configuration details.
Query params:
country: ISO 2-letter country code (optional, defaults to global '*')
Returns payment methods - prioritizes global methods (country_code='*').
Note: Country-specific filtering has been removed per Phase 1.1.2.
The country_code field is retained for future use but currently ignored.
All enabled payment methods are returned regardless of country_code value.
"""
country = request.GET.get('country', '*').upper()
# Get global methods first (country_code='*'), then country-specific as fallback
# Return all enabled payment methods (global approach - no country filtering)
# Country-specific filtering removed per Task 1.1.2 of Master Implementation Plan
methods = PaymentMethodConfig.objects.filter(
is_enabled=True
).filter(
Q(country_code='*') | Q(country_code=country)
).order_by('sort_order').distinct()
).order_by('sort_order')
# Serialize using the proper serializer
serializer = PaymentMethodConfigSerializer(methods, many=True)