public static SomeChangeIssuedEventArgs Create(MoneyNaturalized change)
        {
            if (change == null || change.Native == 0m)
            {
                throw new ArgumentException("The change has been given must be positive");
            }

            return(new SomeChangeIssuedEventArgs {
                SomeChange = change
            });
        }
Example #2
0
        public UvsMockEcommerceService(ICurrencyConverter currencyConverter, Action <ECommerceHandleSettings> setupAction)
        {
            _currencyConverter = currencyConverter;
            _settings          = setupAction?.CreateTargetAndInvoke();

            _adapter = new MockUvsAdapter();
            _adapter.OnUvsPayment += (sender, e) =>
                                     OnReceived?.Invoke(this, new ECommerceIncomeEventArgs {
                Income = MoneyNaturalized.Create(_currencyConverter.Convert(Money.Create(e.Amount, _order.Amount.Currency), _settings.BaseCurrency),
                                                 Money.Create(e.Amount, _order.Amount.Currency))
            });
            _adapter.OnUvsOrderCancelled += (sender, e) =>
                                            OnPaymentCancelled?.Invoke(this, new ECommercePaymentCancelledEventArgs {
                Message = e.Message
            });
        }
Example #3
0
        public (Money change, Money nativeChange) GiveChange(Money change)
        {
            Thread.Sleep(100);

            var   changeNominals = SortedBillsFromTheBiggestToTheSmallest(_settings.BaseCurrency, false);
            Money theBiggestBill = changeNominals.FirstOrDefault(x => x.Value <= change.Value).Key;

            if (theBiggestBill != null)
            {
                Money nativeChange = _currencyConverter.Convert(theBiggestBill, _settings.BaseCurrency);
                OnSomeChangeIssued?.Invoke(this, CashIssueEventArgs.BillIncome(MoneyNaturalized.Create(nativeChange, theBiggestBill)));
                return(theBiggestBill, nativeChange);
            }

            return(null, null);
        }
Example #4
0
        private Money MakeFakeSingleBillIncome(Money amount)
        {
            if (_settings.BillsToReceive == null || !_settings.BillsToReceive.Any())
            {
                throw new Exception("There is no bills related to the device");
            }

            var   receiveNominals = SortedBillsFromTheBiggestToTheSmallest(amount.Currency);
            Money theBiggestBill  = receiveNominals.FirstOrDefault(x => x.Value <= amount.Value).Key;

            if (theBiggestBill == null)
            {
                theBiggestBill = receiveNominals.Last().Key;
            }

            OnMoneyReceived?.Invoke(this, CashIncomeEventArgs.BillIncome(MoneyNaturalized.Create(_currencyConverter.Convert(theBiggestBill, amount.Currency), theBiggestBill)));

            return(theBiggestBill);
        }
Example #5
0
 public static CashIncomeEventArgs BillIncome(MoneyNaturalized money) => new CashIncomeEventArgs
 {
     Money = money, IsBill = true
 };
Example #6
0
 public static CashIncomeEventArgs CoinIncome(MoneyNaturalized money) => new CashIncomeEventArgs
 {
     Money = money, IsBill = false
 };
 public static SomeMoneyIncomeEventArgs Create(PaymentSource source, MoneyNaturalized money)
 => new SomeMoneyIncomeEventArgs
 {
     SomeMoneyIncome = money, Source = source
 };