feat(billing): add missing payment methods and configurations

- Added migration to include global payment method configurations for Stripe and PayPal (both disabled).
- Ensured existing payment methods like bank transfer and manual payment are correctly configured.
- Added database constraints and indexes for improved data integrity in billing models.
- Introduced foreign key relationship between CreditTransaction and Payment models.
- Added webhook configuration fields to PaymentMethodConfig for future payment gateway integrations.
- Updated SignUpFormUnified component to handle payment method selection based on user country and plan.
- Implemented PaymentHistory component to display user's payment history with status indicators.
This commit is contained in:
IGNY8 VPS (Salman)
2025-12-09 06:14:44 +00:00
parent 72d0b6b0fd
commit 4d13a57068
36 changed files with 4159 additions and 253 deletions

View File

@@ -235,6 +235,9 @@ class SiteUserAccessSerializer(serializers.ModelSerializer):
read_only_fields = ['granted_at']
from igny8_core.business.billing.models import PAYMENT_METHOD_CHOICES
class UserSerializer(serializers.ModelSerializer):
account = AccountSerializer(read_only=True)
accessible_sites = serializers.SerializerMethodField()
@@ -267,7 +270,7 @@ class RegisterSerializer(serializers.Serializer):
)
plan_slug = serializers.CharField(max_length=50, required=False)
payment_method = serializers.ChoiceField(
choices=['stripe', 'paypal', 'bank_transfer', 'local_wallet'],
choices=[choice[0] for choice in PAYMENT_METHOD_CHOICES],
default='bank_transfer',
required=False
)
@@ -291,6 +294,21 @@ class RegisterSerializer(serializers.Serializer):
if 'plan_id' in attrs and attrs.get('plan_id') == '':
attrs['plan_id'] = None
# Validate billing fields for paid plans
plan_slug = attrs.get('plan_slug')
paid_plans = ['starter', 'growth', 'scale']
if plan_slug and plan_slug in paid_plans:
# Require billing_country for paid plans
if not attrs.get('billing_country'):
raise serializers.ValidationError({
"billing_country": "Billing country is required for paid plans."
})
# Require payment_method for paid plans
if not attrs.get('payment_method'):
raise serializers.ValidationError({
"payment_method": "Payment method is required for paid plans."
})
return attrs
def create(self, validated_data):