"""Billing routes including bank transfer confirmation and credit endpoints.""" from django.urls import path, include from rest_framework.routers import DefaultRouter from .billing_views import ( BillingViewSet, InvoiceViewSet, PaymentViewSet, CreditPackageViewSet, AccountPaymentMethodViewSet, get_usage_summary, ) from igny8_core.modules.billing.views import ( CreditBalanceViewSet, CreditUsageViewSet, CreditTransactionViewSet, AIModelConfigViewSet, ) # Payment gateway views from .views.stripe_views import ( StripeConfigView, StripeCheckoutView, StripeCreditCheckoutView, StripeBillingPortalView, StripeReturnVerificationView, stripe_webhook, ) from .views.paypal_views import ( PayPalConfigView, PayPalCreateOrderView, PayPalCreateSubscriptionOrderView, PayPalCaptureOrderView, PayPalCreateSubscriptionView, PayPalReturnVerificationView, paypal_webhook, ) router = DefaultRouter() router.register(r'admin', BillingViewSet, basename='billing-admin') # Canonical credits endpoints (unified billing) router.register(r'credits/balance', CreditBalanceViewSet, basename='credit-balance') router.register(r'credits/usage', CreditUsageViewSet, basename='credit-usage') router.register(r'credits/transactions', CreditTransactionViewSet, basename='credit-transactions') # AI Models endpoint router.register(r'ai/models', AIModelConfigViewSet, basename='ai-models') # User-facing billing endpoints router.register(r'invoices', InvoiceViewSet, basename='invoices') router.register(r'payments', PaymentViewSet, basename='payments') router.register(r'credit-packages', CreditPackageViewSet, basename='credit-packages') router.register(r'payment-methods', AccountPaymentMethodViewSet, basename='payment-methods') router.register(r'payment-configs', BillingViewSet, basename='payment-configs') urlpatterns = [ path('', include(router.urls)), # User-facing usage summary endpoint for plan limits path('usage-summary/', get_usage_summary, name='usage-summary'), # Stripe endpoints path('stripe/config/', StripeConfigView.as_view(), name='stripe-config'), path('stripe/checkout/', StripeCheckoutView.as_view(), name='stripe-checkout'), path('stripe/credit-checkout/', StripeCreditCheckoutView.as_view(), name='stripe-credit-checkout'), path('stripe/billing-portal/', StripeBillingPortalView.as_view(), name='stripe-billing-portal'), path('stripe/verify-return/', StripeReturnVerificationView.as_view(), name='stripe-verify-return'), path('webhooks/stripe/', stripe_webhook, name='stripe-webhook'), # PayPal endpoints path('paypal/config/', PayPalConfigView.as_view(), name='paypal-config'), path('paypal/create-order/', PayPalCreateOrderView.as_view(), name='paypal-create-order'), path('paypal/create-subscription-order/', PayPalCreateSubscriptionOrderView.as_view(), name='paypal-create-subscription-order'), path('paypal/capture-order/', PayPalCaptureOrderView.as_view(), name='paypal-capture-order'), path('paypal/create-subscription/', PayPalCreateSubscriptionView.as_view(), name='paypal-create-subscription'), path('paypal/verify-return/', PayPalReturnVerificationView.as_view(), name='paypal-verify-return'), path('webhooks/paypal/', paypal_webhook, name='paypal-webhook'), ]