Fix: Add confirmations support and fix notification logic

Webhook Improvements:
- Added Confirmations field to PaymentWebhookDto (default: 0)
- Updated webhook controller to pass confirmations to service layer
- Fixed notification logic to match order update conditions

Payment Confirmation Logic:
- Paid (2): Confirmed immediately regardless of confirmations
- Overpaid (3): Confirmed immediately regardless of confirmations
- Completed (7): Requires 3+ blockchain confirmations
- Notifications only sent when order is actually updated

This prevents premature notifications for unconfirmed 'Completed' status
while maintaining immediate processing for 'Paid' and 'Overpaid' statuses.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-06 16:26:39 +01:00
parent 2ae44a3c56
commit 110ad5f956
2 changed files with 14 additions and 7 deletions

View File

@@ -175,10 +175,11 @@ public class OrdersController : ControllerBase
public async Task<ActionResult> PaymentWebhook([FromBody] PaymentWebhookDto webhookDto)
{
var success = await _cryptoPaymentService.ProcessPaymentWebhookAsync(
webhookDto.InvoiceId,
webhookDto.Status,
webhookDto.Amount,
webhookDto.TransactionHash);
webhookDto.InvoiceId,
webhookDto.Status,
webhookDto.Amount,
webhookDto.TransactionHash,
webhookDto.Confirmations);
if (!success)
{
@@ -205,4 +206,5 @@ public class PaymentWebhookDto
public PaymentStatus Status { get; set; }
public decimal Amount { get; set; }
public string? TransactionHash { get; set; }
public int Confirmations { get; set; } = 0;
}