Scheduled Postgres backup, restore check, backup warnings in health, payment result logging
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -212,6 +212,14 @@ def apply_order_payment_result(*, order: Order, gateway: str, gateway_ref_id: st
|
||||
event=event, user_id=order.user_id,
|
||||
)
|
||||
|
||||
# یک خطِ لاگِ فنی برای هر نتیجه، تکراریها هم: در دیتابیس فقط نتیجهی پذیرفتهشده ردیف دارد
|
||||
# (Transaction/StatusChangeLog)، پس کالبکِ تکراری یا جعلی بیاین خط هیچ ردی نداشت.
|
||||
logger.log(
|
||||
logging.WARNING if is_duplicate and new_status == 'paid' and not already_paid else logging.INFO,
|
||||
'payment result: order=%s user=%s gateway=%s event=%s status=%s->%s ref=%s ignored=%s',
|
||||
order.id, order.user_id, gateway, event, old_status, new_status,
|
||||
gateway_ref_id or '-', is_duplicate,
|
||||
)
|
||||
newly_paid = new_status == 'paid' and not already_paid and not is_duplicate
|
||||
if newly_paid:
|
||||
if order.subscription_id:
|
||||
|
||||
@@ -223,8 +223,11 @@ class ZarinpalCallbackView(APIView):
|
||||
# یک NOKِ ناشناس آن را «ناموفق» میکرد و با دو سفارش ۵۰۰ میداد.
|
||||
if not authority:
|
||||
raise ValidationError({'Authority': 'لازم است.'})
|
||||
order = get_object_or_404(Order, gateway_authority=authority, provider='gateway')
|
||||
|
||||
order = Order.objects.filter(gateway_authority=authority, provider='gateway').first()
|
||||
if order is None:
|
||||
# کالبکِ بیسفارش: یا Authorityِ جعلی یا سفارشی که از دیتابیس رفته؛ در دیتابیس ردی ندارد.
|
||||
logger.warning('zarinpal callback: no order for authority=%s status=%s', authority[:64], status_param[:10])
|
||||
raise Http404
|
||||
if status_param != 'OK':
|
||||
new_status, gateway_ref_id = 'failed', ''
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user