コード例 #1
0
        public async Task <PurchaseToken> GetTokenAsync(string userName, string password, string certificationId, int transactionAmount, string purchaserInfo, string transactionInfo)
        {
            PurchaseToken token;
            var           key = (transactionAmount, purchaserInfo, transactionInfo).GetHashCode();

            if (_cache.ContainsKey(key) == false || _cache[key].IssuedDate.AddMinutes(tokenLifetimeDurationInMinutes) < DateTime.Now)
            {
                token = new PurchaseToken
                {
                    Value           = await _repo.AcquirePurchaseTokenAsync(userName, password, certificationId, transactionAmount, purchaserInfo, transactionInfo),
                    IssuedDate      = DateTime.Now,
                    PurchaserInfo   = purchaserInfo,
                    TransactionInfo = transactionInfo
                };

                if (!string.IsNullOrEmpty(token.Value))
                {
                    _cache.Add(key, token);
                }
            }
            else
            {
                token = _cache[key];
            }

            return(token);
        }
コード例 #2
0
 internal SubscriptionProxy(Subscription that)
 {
     this.CopyPropertiesFrom(that);
     PurchaseTokenHash = PurchaseToken?.ToSimplifiedSHA1Hash();
 }