+using Content.Server.Mind.Components;
using Content.Server.Store.Components;
+using Content.Server.UserInterface;
using Content.Shared.FixedPoint;
using Content.Shared.Interaction;
using Content.Shared.Popups;
+using Content.Shared.Stacks;
using Content.Shared.Store;
+using JetBrains.Annotations;
+using Robust.Server.GameObjects;
using Robust.Shared.Prototypes;
using System.Linq;
-using Content.Server.UserInterface;
-using Content.Shared.Stacks;
-using JetBrains.Annotations;
namespace Content.Server.Store.Systems;
if (args.Target == null || !TryComp<StoreComponent>(args.Target, out var store))
return;
+ // require the store to be open before inserting currency
+ var user = args.User;
+ if (!TryComp<ActorComponent>(user, out var actor) || !_ui.SessionHasOpenUi(uid, StoreUiKey.Key, actor.PlayerSession))
+ return;
+
args.Handled = TryAddCurrency(GetCurrencyValue(uid, component), args.Target.Value, store);
if (args.Handled)