Files
igny8/backend/seed_payment_configs.py
2025-12-04 23:56:38 +00:00

126 lines
4.4 KiB
Python

"""
Seed payment method configurations
"""
import os
import django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'igny8_core.settings')
django.setup()
from igny8_core.business.billing.models import PaymentMethodConfig
def seed_payment_configs():
"""Create payment method configurations for various countries"""
configs = [
# United States - Stripe and PayPal only
{
'country_code': 'US',
'payment_method': 'stripe',
'is_enabled': True,
'display_name': 'Credit/Debit Card',
'instructions': 'Pay securely with your credit or debit card via Stripe',
'sort_order': 1
},
{
'country_code': 'US',
'payment_method': 'paypal',
'is_enabled': True,
'display_name': 'PayPal',
'instructions': 'Pay with your PayPal account',
'sort_order': 2
},
# India - All methods including manual
{
'country_code': 'IN',
'payment_method': 'stripe',
'is_enabled': True,
'display_name': 'Credit/Debit Card',
'instructions': 'Pay securely with your credit or debit card',
'sort_order': 1
},
{
'country_code': 'IN',
'payment_method': 'paypal',
'is_enabled': True,
'display_name': 'PayPal',
'instructions': 'Pay with your PayPal account',
'sort_order': 2
},
{
'country_code': 'IN',
'payment_method': 'bank_transfer',
'is_enabled': True,
'display_name': 'Bank Transfer (NEFT/IMPS/RTGS)',
'instructions': 'Transfer funds to our bank account. Payment will be verified within 1-2 business days.',
'bank_name': 'HDFC Bank',
'account_number': 'XXXXXXXXXXXXX',
'routing_number': 'HDFC0000XXX',
'swift_code': 'HDFCINBB',
'sort_order': 3
},
{
'country_code': 'IN',
'payment_method': 'local_wallet',
'is_enabled': True,
'display_name': 'UPI / Digital Wallet',
'instructions': 'Pay via Paytm, PhonePe, Google Pay, or other UPI apps. Upload payment screenshot for verification.',
'wallet_type': 'UPI',
'wallet_id': 'igny8@paytm',
'sort_order': 4
},
# United Kingdom - Stripe, PayPal, Bank Transfer
{
'country_code': 'GB',
'payment_method': 'stripe',
'is_enabled': True,
'display_name': 'Credit/Debit Card',
'instructions': 'Pay securely with your credit or debit card',
'sort_order': 1
},
{
'country_code': 'GB',
'payment_method': 'paypal',
'is_enabled': True,
'display_name': 'PayPal',
'instructions': 'Pay with your PayPal account',
'sort_order': 2
},
{
'country_code': 'GB',
'payment_method': 'bank_transfer',
'is_enabled': True,
'display_name': 'Bank Transfer (BACS/Faster Payments)',
'instructions': 'Transfer funds to our UK bank account.',
'bank_name': 'Barclays Bank',
'account_number': 'XXXXXXXX',
'routing_number': 'XX-XX-XX',
'swift_code': 'BARCGB22',
'sort_order': 3
},
]
created_count = 0
updated_count = 0
for config_data in configs:
config, created = PaymentMethodConfig.objects.update_or_create(
country_code=config_data['country_code'],
payment_method=config_data['payment_method'],
defaults={k: v for k, v in config_data.items() if k not in ['country_code', 'payment_method']}
)
if created:
created_count += 1
print(f"✅ Created: {config.country_code} - {config.get_payment_method_display()}")
else:
updated_count += 1
print(f"🔄 Updated: {config.country_code} - {config.get_payment_method_display()}")
print(f"\n✅ Created {created_count} configurations")
print(f"🔄 Updated {updated_count} configurations")
print(f"📊 Total active: {PaymentMethodConfig.objects.filter(is_enabled=True).count()}")
if __name__ == '__main__':
seed_payment_configs()