Fix invoice finalization for confirmed payments - always finalize
CRITICAL FIX: Removes broken conditional logic that could leave confirmed payments in limbo without invoice finalization. BEFORE: Only finalized invoice if products were still locked AFTER: ALWAYS finalize invoice when payment moves to confirmed status This fixes the spaghetti code logic where payment 37ae9bf3-9bcf-11f0-a140-02dfe05770ee moved to confirmed status but invoice was never finalized because products appeared to already be unlocked. Invoice finalization handles: - Product unlocking - Email sending (purchase + sales) - Proper state management Much cleaner and more reliable than conditional finalization.
This commit is contained in:
parent
307680dd7c
commit
bb322be252
1 changed files with 2 additions and 15 deletions
|
|
@ -1531,21 +1531,8 @@ def process_payment(
|
|||
>= int(crypto_payment.confirmations_required)
|
||||
and crypto_payment.status == CryptoPayment.STATUS_RECEIVED
|
||||
):
|
||||
# Check if invoice needs finalization (products not unlocked yet)
|
||||
invoice_needs_finalization = False
|
||||
if crypto_payment.invoice and crypto_payment.invoice.line_items:
|
||||
# Check if any products are still locked for this user
|
||||
for line_item in crypto_payment.invoice.line_items:
|
||||
if (
|
||||
line_item.product.get_userproduct_for_user(
|
||||
crypto_payment.invoice.user
|
||||
)
|
||||
is None
|
||||
):
|
||||
invoice_needs_finalization = True
|
||||
break
|
||||
|
||||
if invoice_needs_finalization:
|
||||
# ALWAYS finalize invoice when payment moves to confirmed
|
||||
if crypto_payment.invoice:
|
||||
logger.info(
|
||||
f"Payment {crypto_payment.id} confirmed, finalizing invoice {crypto_payment.invoice.id}"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue