feat(payment): add per-user in-memory lock for gateway operations
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 9m58s
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 9m58s
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>
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
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()}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user