public IReceiptObjectBuilder BuildPaymentMethod(string text)
        {
            var paymentMethods = _paymentMethodService.GetPaymentMethodsAsync().Result;

            var paymentMethodId = paymentMethods.FirstOrDefault(pm => !string.IsNullOrWhiteSpace(pm.MatchPattern) && Regex.IsMatch(text, pm.MatchPattern, RegexOptions.IgnoreCase))?.Id;

            _receipt.PaymentMethodId = paymentMethodId;

            return(this);
        }
Exemple #2
0
        public async Task <IActionResult> GetPaymentMethodsAsync()
        {
            var paymentMethods = await _paymentService.GetPaymentMethodsAsync();

            if (paymentMethods == null)
            {
                return(NoContent());
            }

            return(Ok(paymentMethods));
        }
        private async Task <IReadOnlyCollection <PaymentMethod> > GetAllPaymentMethodsViaCacheAsync()
        {
            if (_cachedPaymentMethods == null)
            {
                bool retryWithRefreshedUser = false;
                try
                {
                    _cachedPaymentMethods = await _paymentMethodService.GetPaymentMethodsAsync();
                }
                catch (Exception)
                {
                    retryWithRefreshedUser = true;
                }
                if (retryWithRefreshedUser)
                {
                    await _accountService.VerifyUserAuthenticationAsync();

                    _cachedPaymentMethods = await _paymentMethodService.GetPaymentMethodsAsync();
                }
            }
            return(_cachedPaymentMethods);
        }
 public async Task <IEnumerable <PaymentMethod> > GetActive()
 {
     return(await _service.GetPaymentMethodsAsync());
 }