Beispiel #1
0
        protected internal override PaymentData SelectById(Guid id)
        {
            lock (LockObject)
            {
                var cacheKey = CreateCacheKey(id);

                var encryptedPaymentData = CacheManagerFactory.Instance.Get(cacheKey);

                return(PaymentDataEncryptor.Decrypt(encryptedPaymentData.ToString()));
            }
        }
Beispiel #2
0
        protected internal override void Update(PaymentData paymentData)
        {
            if (paymentData == null)
            {
                throw new ArgumentNullException(nameof(paymentData));
            }

            lock (LockObject)
            {
                var cacheKey = CreateCacheKey(paymentData.Id);

                CacheManagerFactory.Instance.AddOrUpdate(cacheKey, PaymentDataEncryptor.Encrypt(paymentData), InvoiceLifeTime);
            }
        }
Beispiel #3
0
        protected internal override PaymentData SelectByOrderNumber(long orderNumber)
        {
            lock (LockObject)
            {
                var paymentCacheItems = CacheManagerFactory.Instance.GetAll().Where(item => item.Key.StartsWith(CachePrefixKey));

                foreach (var paymentCacheItem in paymentCacheItems)
                {
                    if (!PaymentDataEncryptor.TryDecrypt(paymentCacheItem.Value?.ToString(), out var paymentData))
                    {
                        continue;
                    }

                    if (paymentData?.OrderNumber == orderNumber)
                    {
                        return(paymentData);
                    }
                }

                return(null);
            }
        }