feat: add cart, checkout, payment processing, and order history views and models
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 35s
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 35s
This commit is contained in:
parent
c652de3780
commit
15cce9a2f7
2 changed files with 10 additions and 3 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
|
|
|
|||
Loading…
Reference in a new issue