jebin2 commited on
Commit
74c51df
·
1 Parent(s): aed0646
Files changed (1) hide show
  1. routers/payments.py +19 -0
routers/payments.py CHANGED
@@ -263,6 +263,15 @@ async def verify_payment(
263
 
264
  # Check if already processed
265
  if transaction.status == "paid":
 
 
 
 
 
 
 
 
 
266
  return VerifyPaymentResponse(
267
  success=True,
268
  message="Payment already processed",
@@ -415,6 +424,16 @@ async def razorpay_webhook(
415
  )
416
 
417
  await db.commit()
 
 
 
 
 
 
 
 
 
 
418
 
419
  # Handle payment failed event
420
  elif event == "payment.failed":
 
263
 
264
  # Check if already processed
265
  if transaction.status == "paid":
266
+ # Still update verified_by to track that client also called verify
267
+ if transaction.verified_by == "webhook":
268
+ transaction.verified_by = "both"
269
+ await db.commit()
270
+ logger.info(
271
+ f"Payment {transaction.transaction_id} was already verified by webhook, "
272
+ f"client also verified - marked as 'both'"
273
+ )
274
+
275
  return VerifyPaymentResponse(
276
  success=True,
277
  message="Payment already processed",
 
424
  )
425
 
426
  await db.commit()
427
+
428
+ elif transaction and transaction.status == "paid":
429
+ # Transaction already paid by client - update verified_by to "both"
430
+ if transaction.verified_by == "client":
431
+ transaction.verified_by = "both"
432
+ await db.commit()
433
+ logger.info(
434
+ f"Webhook: Transaction {transaction.transaction_id} was already "
435
+ f"verified by client - marked as 'both'"
436
+ )
437
 
438
  # Handle payment failed event
439
  elif event == "payment.failed":