private async Task <IMerchantWallet> GetExchangeWalletAsync(ExchangeCommand cmd, PaymentDirection paymentDirection) { string merchantWalletId = cmd.GetWalletId(paymentDirection); string assetId = cmd.GetAssetId(paymentDirection); return(string.IsNullOrEmpty(merchantWalletId) ? await _merchantWalletService.GetDefaultAsync(cmd.MerchantId, assetId, paymentDirection) : await _merchantWalletService.GetByIdAsync(merchantWalletId)); }
public Transfer(PaymentDirection direction, string systemName, Currency currency, decimal amount, decimal amountN, decimal comissionN = 40) { PaymentDirection = direction; PaymentStatus = PaymentStatus.Created; TransferPaymentSystemName = systemName; Currency = currency; TransferDate = DateTime.Now; Amount = amount; AmountN = amountN; ComissionN = PaymentDirection.Output == direction ? comissionN : 0; }
public static IList <string> GetDefaultAssets(this IMerchantWallet src, PaymentDirection paymentDirection) { IList <string> assets; switch (paymentDirection) { case PaymentDirection.Incoming: assets = src.IncomingPaymentDefaults; break; case PaymentDirection.Outgoing: assets = src.OutgoingPaymentDefaults; break; default: throw new Exception($"Unexpected payment direction [{paymentDirection.ToString()}]"); } return(assets); }
public static string GetWalletId(this ExchangeCommand src, PaymentDirection paymentDirection) { string walletId; switch (paymentDirection) { case PaymentDirection.Outgoing: walletId = src.SourceMerchantWalletId; break; case PaymentDirection.Incoming: walletId = src.DestMerchantWalletId; break; default: throw new Exception("Unexpected payment direction value"); } return(walletId); }
public async Task <IMerchantWallet> GetDefaultAsync(string merchantId, string assetId, PaymentDirection paymentDirection) { BlockchainType network = await _assetSettingsService.GetNetworkAsync(assetId); IReadOnlyList <IMerchantWallet> merchantWallets = (await _merchantWalletRespository.GetByMerchantAsync(merchantId)).Where(x => x.Network == network) .ToList(); string assetDisplayId = assetId.IsGuid() ? (await _assetsLocalCache.GetAssetByIdAsync(assetId)).DisplayId : assetId; IReadOnlyList <IMerchantWallet> assetDefaultWallets = merchantWallets .Where(w => w.GetDefaultAssets(paymentDirection).Contains(assetDisplayId)) .ToList(); if (assetDefaultWallets.MoreThanOne()) { throw new MultipleDefaultMerchantWalletsException(merchantId, assetId, paymentDirection); } if (assetDefaultWallets.Any()) { return(assetDefaultWallets.Single()); } IReadOnlyList <IMerchantWallet> anyAssetDefaultWallets = merchantWallets .Where(w => !w.GetDefaultAssets(paymentDirection).Any()) .ToList(); if (anyAssetDefaultWallets.MoreThanOne()) { throw new MultipleDefaultMerchantWalletsException(merchantId, assetId, paymentDirection); } if (anyAssetDefaultWallets.Any()) { return(anyAssetDefaultWallets.Single()); } throw new DefaultMerchantWalletNotFoundException(merchantId, assetId, paymentDirection); }
protected void Page_Load(object sender, EventArgs e) { _externalPaymentBatchID = int.Parse(Request.QueryString["ID"]); bankStatementDetails.ExternalPaymentBatchID = _externalPaymentBatchID; string subViewType = Request.QueryString["Direction"]; _direction = PaymentDirection.Unspecified; if (!String.IsNullOrEmpty(subViewType)) { if (subViewType == "Credit") { _direction = PaymentDirection.Deposit; } else if (subViewType == "Debit") { _direction = PaymentDirection.Withdrawal; } else { _direction = PaymentDirection.Unspecified; } } }
public MultipleDefaultMerchantWalletsException(string merchantId, string assetId, PaymentDirection paymentDirection) : base("Found multiple default wallets for asset") { MerchantId = merchantId; AssetId = assetId; PaymentDirection = paymentDirection; }
public Task <MerchantWalletResponse> GetDefaultMerchantWalletAsync(string merchantId, string assetId, PaymentDirection paymentDirection) { return(_runner.RunWithDefaultErrorHandlingAsync(() => _merchantWalletsApi.GetDefaultAsync(merchantId, assetId, paymentDirection))); }
public DefaultMerchantWalletNotFoundException(string merchantId, string assetId, PaymentDirection paymentDirection) : base("Default merchant wallet not found") { MerchantId = merchantId; AssetId = assetId; PaymentDirection = paymentDirection; }