update the plans
This commit is contained in:
parent
29e1c7d7c5
commit
9de3755034
@ -9368,6 +9368,7 @@ def payment_callback(request, dealer_slug):
|
||||
history = models.PaymentHistory.objects.filter(transaction_id=payment_id).first()
|
||||
payment_status = request.GET.get("status")
|
||||
order = Order.objects.filter(user=dealer.user, status=1).first() # Status 1 = NEW
|
||||
print(order)
|
||||
if payment_status == "paid":
|
||||
billing_info, created = BillingInfo.objects.get_or_create(
|
||||
user=dealer.user,
|
||||
@ -9380,21 +9381,27 @@ def payment_callback(request, dealer_slug):
|
||||
'country': dealer.entity.country or " ",
|
||||
}
|
||||
)
|
||||
if not hasattr(order.user, 'userplan'):
|
||||
UserPlan.objects.create(
|
||||
user=order.user,
|
||||
plan=order.plan,
|
||||
expire=datetime.now().date() + timedelta(days=order.get_plan_pricing().pricing.period)
|
||||
)
|
||||
|
||||
try:
|
||||
|
||||
# if order.user.userplan:
|
||||
# user = order.user
|
||||
# pricing = order.get_plan_pricing().pricing
|
||||
|
||||
# logger.info(f"Processing order completion for {user} - upgrading to {order.plan}")
|
||||
# user.userplan.plan = order.plan
|
||||
# user.userplan.expire = datetime.now() + timedelta(days=pricing.period)
|
||||
# user.userplan.save()
|
||||
# user.save()
|
||||
# logger.info(f"User {user} upgraded to {order.plan} plan successfully")
|
||||
|
||||
order.complete_order()
|
||||
|
||||
if not created:
|
||||
user = order.user
|
||||
pricing = order.get_plan_pricing().pricing
|
||||
|
||||
logger.info(f"Processing order completion for {user} - upgrading to {order.plan}")
|
||||
user.userplan.plan = order.plan
|
||||
user.userplan.expire = datetime.now() + timedelta(days=pricing.period)
|
||||
user.userplan.save()
|
||||
user.save()
|
||||
logger.info(f"User {user} upgraded to {order.plan} plan successfully")
|
||||
|
||||
history.status = "paid"
|
||||
history.save()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user