diff --git a/orders/models.py b/orders/models.py index 6a1df7d..1cab77c 100644 --- a/orders/models.py +++ b/orders/models.py @@ -124,6 +124,7 @@ class SellerOrder(models.Model): status = models.CharField(max_length=50, default='Pending Acceptance') carrier = models.CharField(max_length=100, default='Pending') tracking = models.CharField(max_length=100, default='Pending') + payment_mode = models.CharField(max_length=20, default='Prepaid') eta = models.CharField(max_length=50, default='N/A') class Meta: diff --git a/orders/views.py b/orders/views.py index 46ac0d3..1ade50e 100644 --- a/orders/views.py +++ b/orders/views.py @@ -131,6 +131,9 @@ class CheckoutView(APIView): ) audit_logger.info(f"AUDIT - Checkout: User '{user.username}' created order ID {order.id} for amount ${total_amount:.2f}.") + raw_pm = str(request.data.get('payment_method') or request.data.get('payment_mode') or '').upper() + payment_mode = 'COD' if ('COD' in raw_pm or 'CASH' in raw_pm) else 'Prepaid' + # Write to shared SellerOrder (api_order) table created_seller_orders = False if cart_items: @@ -147,7 +150,8 @@ class CheckoutView(APIView): total=item.quantity * item.price_at_add, status='Pending Acceptance', carrier='Pending', - tracking='Pending' + tracking='Pending', + payment_mode=payment_mode ) created_seller_orders = True CartItem.objects.filter(cart__user=user).delete() @@ -178,7 +182,8 @@ class CheckoutView(APIView): total=prod_price * prod_qty, status='Pending Acceptance', carrier='Pending', - tracking='Pending' + tracking='Pending', + payment_mode=payment_mode ) created_seller_orders = True @@ -196,7 +201,8 @@ class CheckoutView(APIView): total=total_amount or 999.0, status='Pending Acceptance', carrier='Pending', - tracking='Pending' + tracking='Pending', + payment_mode=payment_mode ) return Response({