Merge branch 'main' of http://10.10.1.136:3000/ismail/haikal into frontend
This commit is contained in:
commit
b30ea9aa81
@ -9368,6 +9368,7 @@ def payment_callback(request, dealer_slug):
|
|||||||
history = models.PaymentHistory.objects.filter(transaction_id=payment_id).first()
|
history = models.PaymentHistory.objects.filter(transaction_id=payment_id).first()
|
||||||
payment_status = request.GET.get("status")
|
payment_status = request.GET.get("status")
|
||||||
order = Order.objects.filter(user=dealer.user, status=1).first() # Status 1 = NEW
|
order = Order.objects.filter(user=dealer.user, status=1).first() # Status 1 = NEW
|
||||||
|
print(order)
|
||||||
if payment_status == "paid":
|
if payment_status == "paid":
|
||||||
billing_info, created = BillingInfo.objects.get_or_create(
|
billing_info, created = BillingInfo.objects.get_or_create(
|
||||||
user=dealer.user,
|
user=dealer.user,
|
||||||
@ -9380,21 +9381,27 @@ def payment_callback(request, dealer_slug):
|
|||||||
'country': dealer.entity.country or " ",
|
'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:
|
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()
|
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.status = "paid"
|
||||||
history.save()
|
history.save()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user