Files
bd2/plugins/CashShop/CommercePayments.cs
T
Flechazo d8771caef2 feat(all): add hunting and events, commerce and rewards, binary calendars, GameData caching and login diagnostics
Implement hunting AP and progress, event tasks, exchanges, games, stories and actions; connect battle and reward handling.

Add CashShop plugin and installation, server purchases and entitlements, recharge rules and plugin version metadata.

Distribute binary calendars independently; cache GameData in memory and fix single-connection query deadlocks.

Improve automatic login and recovery diagnostics; document configuration and release flows.
2026-10-05 11:50:31 +08:00

28 lines
997 B
C#

using System;
using System.Collections.Generic;
using System.Globalization;
namespace Bd2CashShop;
internal static class CommercePayments
{
private static readonly HashSet<long> Applied = new HashSet<long>();
internal static string Receipt(long payment, CommerceProduct quote) =>
"bd2-local-commerce-v1:" + payment.ToString(CultureInfo.InvariantCulture) + ":" +
quote.ItemType.ToString(CultureInfo.InvariantCulture) + ":" + quote.Amount.ToString(CultureInfo.InvariantCulture);
internal static Action AcceptOnce(long payment, Func<bool> isCurrentSession, Action debit, Action continuation)
{
return delegate
{
// The transport invokes this callback only on a successful response.
// A replay must not charge the displayed client balance twice.
if (isCurrentSession() && Applied.Add(payment)) debit();
continuation?.Invoke();
};
}
internal static void Clear() => Applied.Clear();
}