Files
CMS/src/CMSMicroservice.Application/Common/PaymentLockScopes.cs
T
masoodafar-web d22eb1617f
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 9m58s
feat(payment): add per-user in-memory lock for gateway operations
Introduce IUserPaymentLock to serialize payment initiate and verify flows
per user, preventing concurrent duplicate gateway requests across services.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-08 01:55:00 +03:30

20 lines
798 B
C#

namespace CMSMicroservice.Application.Common;
/// <summary>
/// Canonical scope keys for <see cref="Interfaces.IUserPaymentLock"/>.
/// </summary>
public static class PaymentLockScopes
{
/// <summary>One active payment initiation per user (package, wallet charge, order, IPG deposit).</summary>
public static string Initiate(long userId) => $"payment:initiate:user:{userId}";
/// <summary>One active verify per user + authority/order (duplicate callback protection).</summary>
public static string Verify(long userId, string resourceKey)
{
if (string.IsNullOrWhiteSpace(resourceKey))
throw new ArgumentException("Payment verify resource key is required.", nameof(resourceKey));
return $"payment:verify:user:{userId}:{resourceKey.Trim()}";
}
}