Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the FirstDataExtractProcessor class.
 /// </summary>
 /// <param name="enableRedemptionRewards">
 /// Specifies whether redemption rewards should be enabled.
 /// </param>
 public FirstDataExtractProcessor(bool enableRedemptionRewards)
 {
     Context = new CommerceContext(string.Empty, CommerceWorkerConfig.Instance);
     RedeemedDealOperations  = CommerceOperationsFactory.RedeemedDealOperations(Context);
     RewardOperations        = CommerceOperationsFactory.RewardOperations(Context);
     EnableRedemptionRewards = enableRedemptionRewards;
 }
Beispiel #2
0
 public RewardNetworkReportProcessor(CommerceContext commerceContext)
 {
     Context = commerceContext;
     RedeemedDealOperations = CommerceOperationsFactory.RedeemedDealOperations(Context);
     FtpUserName            = CloudConfigurationManager.GetSetting(RewardsNetworkConstants.FtpUserName);
     FtpPassword            = CloudConfigurationManager.GetSetting(RewardsNetworkConstants.FtpPassword);
     FtpUri    = CloudConfigurationManager.GetSetting(RewardsNetworkConstants.FtpAddress);
     FtpFolder = CloudConfigurationManager.GetSetting(RewardsNetworkConstants.FtpTransactionReportDirectory);
 }
 /// <summary>
 /// Initializes a new instance of the TransactionLogFileProcessor class.
 /// </summary>
 /// <param name="enableRedemptionRewards">
 /// Specifies whether redemption rewards should be enabled.
 /// </param>
 public TransactionLogFileProcessor(bool enableRedemptionRewards)
 {
     Context = new CommerceContext(string.Empty, CommerceWorkerConfig.Instance);
     RedeemedDealOperations  = CommerceOperationsFactory.RedeemedDealOperations(Context);
     RewardOperations        = CommerceOperationsFactory.RewardOperations(Context);
     EnableRedemptionRewards = enableRedemptionRewards;
     Context[Key.Partner]    = Partner.Amex;
     TransactionIdSet        = new HashSet <string>();
 }
        /// <summary>
        /// Updates the data store to reflect the reversal of the redeemed deal.
        /// </summary>
        /// <returns>
        /// The ResultCode corresponding to the result of the operation.
        /// </returns>
        public ResultCode ProcessRedemptionTimeout()
        {
            ResultCode result;

            Context.Log.Verbose("Attempting to update the data store to reflect the reversal of the timed out redemption.");
            IRedeemedDealOperations redeemedDealOperations = CommerceOperationsFactory.RedeemedDealOperations(Context);

            result = redeemedDealOperations.ProcessRedemptionTimeout();
            Context.Log.Verbose("ResultCode after reversing the timed out redemption in the data store: {0}", result);

            return(result);
        }
        /// <summary>
        /// Updates the data store to reflect the reversal of the redeemed deal.
        /// </summary>
        /// <returns>
        /// The ResultCode corresponding to the result of the operation.
        /// </returns>
        public ResultCode ReverseRedeemedDeal()
        {
            ResultCode result;

            Context.Log.Verbose("Attempting to update the data store to reflect the reversal of the redeemed deal.");
            IRedeemedDealOperations redeemedDealOperations = CommerceOperationsFactory.RedeemedDealOperations(Context);

            result = redeemedDealOperations.ReverseRedeemedDeal();
            Context.Log.Verbose("ResultCode after reversing the redeemed deal in the data store: {0}", result);

            return(result);
        }
        /// <summary>
        /// Adds the redeemed deal to the data store and logs accordingly.
        /// </summary>
        /// <returns>
        /// The ResultCode corresponding to the result of the operation.
        /// </returns>
        private ResultCode AddRedeemedDeal()
        {
            ResultCode result = ResultCode.Success;

            // Add the redemption event info to the data store.
            Context.Log.Verbose("Attempting to add the redeemed deal to the data store.");
            IRedeemedDealOperations redeemedDealOperations = CommerceOperationsFactory.RedeemedDealOperations(Context);

            result = redeemedDealOperations.AddRedeemedDeal();
            Context.Log.Verbose("ResultCode after adding the redeemed deal to the data store: {0}", result);

            return(result);
        }
        /// <summary>
        /// Executes the distribute MSSV API invocation.
        /// </summary>
        public void Execute()
        {
            ResultSummary resultSummary = (ResultSummary)Context[Key.ResultSummary];

            // Make sure the user exists.
            SharedUserLogic sharedUserLogic = new SharedUserLogic(Context, CommerceOperationsFactory.UserOperations(Context));

            if (sharedUserLogic.RetrieveUser() != null)
            {
                // Validate the distribution amount.
                decimal distributionAmount = (decimal)Context[Key.DistributionAmount];
                if (distributionAmount >= 0 && distributionAmount % 10 == 0)
                {
                    // Validate the voucher expiration date.
                    DateTime voucherExpiration = (DateTime)Context[Key.VoucherExpirationUtc];
                    DateTime utcNow            = DateTime.UtcNow;
                    if (voucherExpiration > utcNow && voucherExpiration <= utcNow + TimeSpan.FromDays(366))
                    {
                        // HTML encode user-submitted text to prevent script injection and then truncate to maximum length. (SQL injection is prevented through use of a
                        //  paramterized stored procedure.)
                        string notes = Context[Key.Notes] as string;
                        if (String.IsNullOrWhiteSpace(notes) == false)
                        {
                            notes = HttpUtility.HtmlEncode(notes);
                            if (notes.Length > MaxNotesLength)
                            {
                                notes = notes.Substring(0, MaxNotesLength);
                            }
                        }

                        // Submit the distribution request to the database.
                        ResultCode             result   = CommerceOperationsFactory.RedeemedDealOperations(Context).DistributeMssv();
                        DistributeMssvResponse response = (DistributeMssvResponse)Context[Key.Response];
                        response.RemainingFunds = (decimal)Context[Key.RemainingFunds];
                        resultSummary.SetResultCode(result);
                    }
                    else
                    {
                        resultSummary.SetResultCode(ResultCode.InvalidExpirationDate);
                    }
                }
                else
                {
                    resultSummary.SetResultCode(ResultCode.InvalidDistributionAmount);
                }
            }
            else
            {
                resultSummary.SetResultCode(ResultCode.UnexpectedUnregisteredUser);
            }
        }
        /// <summary>
        /// Executes the distribute MSSV API invocation.
        /// </summary>
        public void Execute()
        {
            ResultSummary resultSummary = (ResultSummary)Context[Key.ResultSummary];

            // Make sure the user exists.
            SharedUserLogic sharedUserLogic = new SharedUserLogic(Context, CommerceOperationsFactory.UserOperations(Context));

            if (sharedUserLogic.RetrieveUser() != null)
            {
                ResultCode result = CommerceOperationsFactory.RedeemedDealOperations(Context).MssVoucherDistributionHistory();
                MssVoucherDistributionHistory history = (MssVoucherDistributionHistory)Context[Key.MssVoucherDistributionHistory];

                GetMssVoucherDistributionHistoryResponse response = (GetMssVoucherDistributionHistoryResponse)Context[Key.Response];
                response.AmountRemaining = (decimal)history.AmountRemaining / 100;

                List <DistributionHistoryDataContract> distributionHistoryList = new List <DistributionHistoryDataContract>();
                response.DistributionHistory = distributionHistoryList;
                foreach (DistributionHistory distributionHistoryItem in history.DistributionHistory)
                {
                    DistributionHistoryDataContract distributionHistoryItemDataContract = new DistributionHistoryDataContract
                    {
                        DistributionDate = distributionHistoryItem.DistributionDate,
                        Amount           = (decimal)distributionHistoryItem.Amount / 100,
                        Currency         = distributionHistoryItem.Currency,
                        ExpirationDate   = distributionHistoryItem.ExpirationDate
                    };
                    distributionHistoryList.Add(distributionHistoryItemDataContract);
                }

                List <TransactionHistoryDataContract> transactionHistoryList = new List <TransactionHistoryDataContract>();
                response.TransactionHistory = transactionHistoryList;
                foreach (TransactionHistory transactionHistoryItem in history.TransactionHistory)
                {
                    TransactionHistoryDataContract transactionHistoryItemDataContract = new TransactionHistoryDataContract
                    {
                        Business       = transactionHistoryItem.Business,
                        CreditStatus   = transactionHistoryItem.CreditStatus.ToString(),
                        PurchaseDate   = transactionHistoryItem.PurchaseDate,
                        DiscountAmount = (decimal)transactionHistoryItem.DiscountAmount / 100
                    };
                    transactionHistoryList.Add(transactionHistoryItemDataContract);
                }

                resultSummary.SetResultCode(result);
            }
            else
            {
                resultSummary.SetResultCode(ResultCode.UnexpectedUnregisteredUser);
            }
        }
Beispiel #9
0
        /// <summary>
        ///     Executes processing of the request.
        /// </summary>
        public ResultCode Execute()
        {
            const string statusFail = "0";

            var request = (EndPointMessageRequest)Context[Key.Request];
            var messageElementCollectionDictionary = request.MessageElementsCollection.ToDictionary(c => c.Key, c => c.Value, StringComparer.OrdinalIgnoreCase);
            var transactionId = messageElementCollectionDictionary[VisaEPMConstants.TransactionTransactionID];
            var status        = messageElementCollectionDictionary[VisaEPMConstants.FulfillmentStatus];

            var creditStatus = CreditStatus.CreditGranted;

            if (status == statusFail)
            {
                creditStatus = CreditStatus.RejectedByPartner;
                if (messageElementCollectionDictionary.ContainsKey(VisaEPMConstants.FulfillmentStatusMessage))
                {
                    var errorMessage = messageElementCollectionDictionary[VisaEPMConstants.FulfillmentStatusMessage];
                    if (errorMessage.IndexOf(ErrorStatementCreditAlreadyIssuedForTransaction, StringComparison.OrdinalIgnoreCase) >= 0)
                    {
                        creditStatus = CreditStatus.CreditGranted;
                        Context.Log.Verbose("Received statementCredit EPM message from Visa for partnerRedeemedDealScopeId={0} informing that credit for this transaction is already issued. Setting credit status to {1}.", transactionId, creditStatus);
                    }
                    else
                    {
                        Context.Log.Verbose("StatementCredit for Visa for partnerRedeemedDealScopeId={0} failed with error {1}", transactionId, errorMessage);
                    }
                }
            }

            DateTime processedDateTime = DateTime.UtcNow;

            if (messageElementCollectionDictionary.ContainsKey(VisaEPMConstants.FulfillmentProcessedDateTime))
            {
                var processedDateTimeString = messageElementCollectionDictionary[VisaEPMConstants.FulfillmentProcessedDateTime];
                // UTC Time: 2014-08-19T23:17:03.000Z
                processedDateTime = DateTime.Parse(processedDateTimeString);
                processedDateTime = DateTime.SpecifyKind(processedDateTime, DateTimeKind.Utc);
            }

            Context[Key.CreditStatus] = creditStatus;
            Context[Key.Transaction]  = transactionId;
            Context[Key.TransactionCreditApprovedDate] = processedDateTime;

            Context.Log.Verbose("Updating redeemed deal having partnerRedeemedDealScopeId={0} to credit status {1}.", transactionId, creditStatus);
            var redeemedDealOperations = CommerceOperationsFactory.RedeemedDealOperations(Context);

            redeemedDealOperations.UpdateRedeemedDealsByVisa();
            Context.Log.Verbose("Updated redeemed deal having partnerRedeemedDealScopeId={0} to credit status {1}.", transactionId, creditStatus);
            return(ResultCode.Success);
        }
 /// <summary>
 /// Initializes a new instance of the MasterCardRebateProcessor class.
 /// </summary>
 public MasterCardRebateProcessor()
 {
     Context = new CommerceContext(string.Empty, CommerceWorkerConfig.Instance);
     RedeemedDealOperations = CommerceOperationsFactory.RedeemedDealOperations(Context);
 }
 /// <summary>
 /// Initializes a new instance of the GetMerchantReportExecutor class.
 /// </summary>
 /// <param name="context">
 /// The context to use while processing the request.
 /// </param>
 public GetMerchantReportExecutor(CommerceContext context)
 {
     Context = context;
     RedeemedDealOperations = CommerceOperationsFactory.RedeemedDealOperations(Context);
 }
 /// <summary>
 /// Initializes a new instance of the FirstDataPtsProcessor class.
 /// </summary>
 public FirstDataPtsProcessor()
 {
     Context = new CommerceContext(string.Empty, CommerceWorkerConfig.Instance);
     RedeemedDealOperations = CommerceOperationsFactory.RedeemedDealOperations(Context);
 }
Beispiel #13
0
 /// <summary>
 /// Initializes a new instance of the StatementCreditFileBuilder class.
 /// </summary>
 public StatementCreditFileBuilder()
 {
     Context = new CommerceContext(string.Empty, CommerceWorkerConfig.Instance);
     RedeemedDealOperations = CommerceOperationsFactory.RedeemedDealOperations(Context);
 }