Ejemplo n.º 1
0
        public void SaveMarketplaceEbay()
        {
            int customerId = 1;

            var tokens = new[]
            {
                "AgAAAA**AQAAAA**aAAAAA**/zT8Tw**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wJkYGoD5KHogmdj6x9nY+seQ**kXgBAA**AAMAAA**ZtzWCT7y/CDuAWGaA082vd91NFpT+178ZI43eyd/xsxP+ugZ3XbSslbtCT01q7rzfueXYDYfh7+X09O4lt1DRFvLNmfZjTwsy2U13rLLJLAQoREyEOWerVyZUiBemb0YhSJItaV9NlioKMk4x7wXEnjVThOxfTHSW3KkKQYdwf2itfUM8FGRHrQGpLr+9MVaHAvHk7j6Ns1LV+/S75ylttXIk7m/e8E4qpFlMUqLdgl3xB0pIOc9mnNsQYhHBlNkYzzbi9/44SovH/e730UJGaNI3YiU7xVn6OeedFyUEiOx4cY/eN8Z7lN47ofNyY8j7aUEfvr364pGdVzgqUsBiTzTg8DwrsMcEwaK89eIdiHaaybaKX0W7HM6TwXO/iNgNzR9/RPhpk4qSDuJI2pqJdC+bJ3pL986o52puLcXAAo4X2QyxK/xM3MR79K0XFPgbQ5PlQld8J50VrnIhX62Jur3Ig/LDwga1pTaxYVEZC506nP9lMx0XG8QzfzS6BP5lfPpFXV+7GhlQ7LnQxQDiocaMEOqg9svYFXG4s47Y875Bg4b7kFXGVIQ3TKhOblDJE1ADyb0aZ9GoyUbabYdt3Q8rMi1X+44r9FGGR5UHNopUMM2zOgsVFFgRnkVnJDu/mKUXyZEbKiek8BeDHkv1El/2vOXhI5Ncf1/CMmHleCPAH5Sdo/Q7843WUM+MUd804PHu5bzZI4/pYgelS4AgXhW4wTgoZwGF6WUB7g8GDcQESAIBmRh1vLKPu25gWCN",
                "AgAAAA**AQAAAA**aAAAAA**CzQDUA**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wFkIqnCJOFpQydj6x9nY+seQ**kXgBAA**AAMAAA**ahr1JPnT4xKHh6+OIWluq09/FMw3xh7idxmn23CRX1t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wF7HIioJMiC7KsOeJ3uCISYZpRwFEPIYzC5Qm3JiuD71T1PBCTKzVfhfcx4XfQyb7HZuhPU6qwkqm1sjoId9mJBGP1+QS85fo9wE8sCeBfZOrfHw89nX2G7chz4/zI5pbomXUAn0Wuqb4wtvQ+fNMWM7ssIp";

            var customer = GetCustomerInfo(customerId);

            Assert.NotNull(customer);

            foreach (var token in tokens)
            {
                var data = new eBaySecurityInfo
                {
                    Token = token
                };

                var info            = EBayRetriveDataHelper.GetCustomerUserInfo(data);
                var marketplaceName = info.UserID;

                EBayRetriveDataHelper.StoreOrUpdateCustomerSecurityInfo(customer, data, marketplaceName);
            }
        }
Ejemplo n.º 2
0
        }         // CheckTokenStatus

        private DataProviderCreationInfo CreateProviderCreationInfo(eBaySecurityInfo securityInfo)
        {
            var serviceConnectionInfo = this.connectionInfo;
            IServiceTokenProvider serviceTokenProvider = new ServiceTokenProviderCustom(securityInfo.Token);
            IEbayServiceProvider  serviceProvider      = new EbayTradingServiceProvider(serviceConnectionInfo);

            return(new DataProviderCreationInfo(serviceProvider)
            {
                ServiceTokenProvider = serviceTokenProvider,
                Settings = this.settings
            });
        }         // CreateProviderCreationInfo
Ejemplo n.º 3
0
        private DataProviderCreationInfo CreateProviderCreationInfo(eBaySecurityInfo securityInfo)
        {
            var ebayConnectionInfo = ObjectFactory.GetInstance <IEbayMarketplaceTypeConnection>();
            var connectionInfo     = eBayServiceHelper.CreateConnection(ebayConnectionInfo);;

            IServiceTokenProvider serviceTokenProvider = new ServiceTokenProviderCustom(securityInfo.Token);
            IEbayServiceProvider  serviceProvider      = new EbayTradingServiceProvider(connectionInfo);

            return(new DataProviderCreationInfo(serviceProvider)
            {
                ServiceTokenProvider = serviceTokenProvider,
                Settings = ObjectFactory.GetInstance <IEbayMarketplaceSettings>()
            });
        }
Ejemplo n.º 4
0
        public static void TestStoreCustomerSecurityData(int customerId, string token, string marketplaceName = null)
        {
            var databaseCustomer = GetCustomerInfo(customerId);

            var data = new eBaySecurityInfo
            {
                Token = token
            };

            if (string.IsNullOrEmpty(marketplaceName))
            {
                var info = EBayRetriveDataHelper.GetCustomerUserInfo(data);
                marketplaceName = info.UserID;
            }
            EBayRetriveDataHelper.StoreOrUpdateCustomerSecurityInfo(databaseCustomer, data, marketplaceName);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Checking if during account info retrieve there is an exception with following data:
        /// ErrorCode: "332"
        /// LongMessage: "Your account has not been activated yet. Accounts are not accessible until an actual debit or credit has first been posted to the account, even though you may have already filled out our account creation form."
        /// SeverityCode: Error
        /// ShortMessage: "Your account has not been created."
        /// If it is returns false else true
        /// </summary>
        /// <param name="eBaySecurityInfo"></param>
        /// <returns>false if account is not activated</returns>
        public bool ValidateAccount(eBaySecurityInfo eBaySecurityInfo)
        {
            var creationInfo = CreateProviderCreationInfo(eBaySecurityInfo);
            var getAccount   = new DataProviderGetAccount(creationInfo);

            try
            {
                getAccount.GetAccount();
            }
            catch (Exception ex)
            {
                var inner = ex.InnerException;
                if (inner != null && typeof(FailServiceRequestException) == inner.GetType())
                {
                    var errorCodes = ((FailServiceRequestException)inner).ResultInfoError.Errors.Select(x => new{ x.ErrorCode, x.LongMessage });
                    if (errorCodes.Any(x => x.ErrorCode == "332"))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 6
0
        }         // GetTopSealedProductItems

        public ResultInfoEbayUser GetCustomerUserInfo(eBaySecurityInfo data)
        {
            DataProviderCreationInfo info = CreateProviderCreationInfo(data);

            return(GetCustomerUserInfo(info));
        }         // GetCustomerUserInfo
Ejemplo n.º 7
0
        public JsonResult FetchToken(string username)
        {
            try {
                var customer = this.context.Customer;
                if (customer == null)
                {
                    Log.Warn("Customer is not authorized in system");
                    return(Json(new { error = "Customer is not authorized in system" }, JsonRequestBehavior.AllowGet));
                }

                var ebay = new eBayDatabaseMarketPlace();

                var sid      = TempData["SID"] as string;
                var isUpdate = TempData["isUpdate"] is bool && (bool)TempData["isUpdate"];

                if (string.IsNullOrEmpty(sid))
                {
                    Log.Warn("Sid is empty");
                    return(Json(new { error = "Username is empty" }, JsonRequestBehavior.AllowGet));
                }
                if (string.IsNullOrEmpty(username))
                {
                    Log.Warn("Username is empty");
                    return(Json(new { error = "Username is empty" }, JsonRequestBehavior.AllowGet));
                }
                bool             isValid          = false;
                eBaySecurityInfo eBaySecurityInfo = null;
                try {
                    Log.InfoFormat("Saving sid {0} for username {1}", sid, username);
                    var token = this.eBayServiceHelper.FetchToken(sid);
                    Log.InfoFormat("Token {0} was generated.", token);

                    eBaySecurityInfo = new eBaySecurityInfo {
                        Token = token
                    };

                    isValid = this.eBayServiceHelper.ValidateAccount(eBaySecurityInfo);
                } catch (Exception ex) {
                    Log.Warn("Failed fetching token", ex);
                }

                if (!isValid)
                {
                    Log.WarnFormat("eBay account has not been activated yet");
                    return(Json(new { error = "Your account has not been activated yet. Accounts are not accessible until an actual debit or credit has first been posted to the account, even though you may have already filled out our account creation form." }, JsonRequestBehavior.AllowGet));
                }

                this.mpChecker.Check(ebay.InternalId, customer, username);

                var mp = this.helper.SaveOrUpdateCustomerMarketplace(username, ebay, eBaySecurityInfo, customer);

                this.session.Flush();

                if (!isUpdate)
                {
                    this.serviceClient.Instance.UpdateMarketplace(this.context.Customer.Id, mp.Id, true, this.context.UserId);
                }

                this.customers.SaveOrUpdate(customer);

                return(Json(new { msg = string.Format("Congratulations. Your shop was {0} successfully.", isUpdate ? "updated" : "added") }, JsonRequestBehavior.AllowGet));
            } catch (MarketPlaceAddedByThisCustomerException) {
                return(Json(new { error = DbStrings.StoreAddedByYou }, JsonRequestBehavior.AllowGet));
            } catch (MarketPlaceIsAlreadyAddedException) {
                return(Json(new { error = DbStrings.StoreAlreadyExistsInDb }, JsonRequestBehavior.AllowGet));
            } catch (Exception e) {
                Log.Error(e);
                return(Json(new { error = e.Message }, JsonRequestBehavior.AllowGet));
            }
        }