예제 #1
0
        public void TestGetTransactions()
        {
            //int customerId = 1;
            var reqInfo = new PayPalRequestInfo {
                SecurityInfo = new PayPalSecurityData()
                {
                    PermissionsGranted = new PayPalPermissionsGranted {
                        RequestToken     = "AAAAAAvoMRxkeqwRbNet",
                        VerificationCode = "BUZDemaiLtrC-008xfzUug",

                        AccessToken = "i0JEalB9y89Uq9VA.fjjsrdWnlPsVe8rwkIbPgvvP1clFnyEbHt29A",
                        TokenSecret = "kw1bQNNMe0bJj-81OAVfFXJh9ZY",
                    },
                    UserId = "*****@*****.**"
                },
                StartDate            = DateTime.Today.AddDays(-30),
                EndDate              = DateTime.Today,
                ErrorRetryingInfo    = new ErrorRetryingInfo(false),
                OpenTimeOutInMinutes = 1,
                SendTimeoutInMinutes = 1,
                DaysPerRequest       = 30
            };

            PayPalServiceHelper.GetTransactionData(reqInfo, data => {
                Console.WriteLine("data {0}", data.Capacity);
                return(true);
            });
        }
예제 #2
0
        private UpdateActionResultInfo UpdateTransactionInfo(IDatabaseCustomerMarketPlace databaseCustomerMarketPlace, PayPalSecurityData securityInfo, MP_CustomerMarketplaceUpdatingHistory historyRecord)
        {
            var endDate         = DateTime.UtcNow;
            var elapsedTimeInfo = new ElapsedTimeInfo();

            DateTime?startDate = ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds(
                elapsedTimeInfo,
                databaseCustomerMarketPlace.Id,
                ElapsedDataMemberType.RetrieveDataFromDatabase,
                () => Helper.GetLastPayPalTransactionDate(databaseCustomerMarketPlace)
                );

            if (!startDate.HasValue)
            {
                startDate = endDate.AddMonths(-CurrentValues.Instance.PayPalTransactionSearchMonthsBack);
            }

            var errorRetryingInfo = new ErrorRetryingInfo((bool)CurrentValues.Instance.PayPalEnableRetrying, CurrentValues.Instance.PayPalMinorTimeoutInSeconds, CurrentValues.Instance.PayPalUseLastTimeOut);

            errorRetryingInfo.Info    = new ErrorRetryingItemInfo[3];
            errorRetryingInfo.Info[0] = new ErrorRetryingItemInfo(CurrentValues.Instance.PayPalIterationSettings1Index, CurrentValues.Instance.PayPalIterationSettings1CountRequestsExpectError, CurrentValues.Instance.PayPalIterationSettings1TimeOutAfterRetryingExpiredInMinutes);
            errorRetryingInfo.Info[1] = new ErrorRetryingItemInfo(CurrentValues.Instance.PayPalIterationSettings2Index, CurrentValues.Instance.PayPalIterationSettings2CountRequestsExpectError, CurrentValues.Instance.PayPalIterationSettings2TimeOutAfterRetryingExpiredInMinutes);
            errorRetryingInfo.Info[2] = new ErrorRetryingItemInfo(CurrentValues.Instance.PayPalIterationSettings3Index, CurrentValues.Instance.PayPalIterationSettings3CountRequestsExpectError, CurrentValues.Instance.PayPalIterationSettings3TimeOutAfterRetryingExpiredInMinutes);

            var reqInfo = new PayPalRequestInfo {
                SecurityInfo         = securityInfo,
                StartDate            = startDate.Value,
                EndDate              = endDate,
                ErrorRetryingInfo    = errorRetryingInfo,
                OpenTimeOutInMinutes = CurrentValues.Instance.PayPalOpenTimeoutInMinutes,
                SendTimeoutInMinutes = CurrentValues.Instance.PayPalSendTimeoutInMinutes,
                DaysPerRequest       = CurrentValues.Instance.PayPalDaysPerRequest
            };

            MP_PayPalTransaction mpTransaction = null;
            int numOfTransactions = 0;
            RequestsCounterData requestsCounter = ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds(
                elapsedTimeInfo,
                databaseCustomerMarketPlace.Id,
                ElapsedDataMemberType.RetrieveDataFromExternalService,
                () => PayPalServiceHelper.GetTransactionData(reqInfo, data => {
                mpTransaction      = Helper.SavePayPalTransactionInfo(databaseCustomerMarketPlace, data, historyRecord, mpTransaction);
                numOfTransactions += (data == null ? 0 : data.Count);
                return(true);
            })
                );

            return(new UpdateActionResultInfo {
                Name = UpdateActionResultType.TransactionItemsCount,
                Value = numOfTransactions,
                RequestsCounter = requestsCounter,
                ElapsedTime = elapsedTimeInfo
            });
        }