Пример #1
0
        public static BuySafeStatus RegisterStore(Store store)
        {
            BuySafeWebReference.BuySafeAPI api = GetAPI();
            BuySafeWebReference.AddStoreRQ req = new BuySafeWebReference.AddStoreRQ();
            req.AccountHash     = AccountHash();
            req.AddStoreList    = new BuySafeWebReference.StoreInformation[1];
            req.AddStoreList[0] = GetStoreInformation(store);

            BuySafeWebReference.AddStoreRS response = api.AddStore(req);
            BuySafeStatus status = new BuySafeStatus()
            {
                HasError = response.Successful == false
            };

            if (response.ErrorInformation != null)
            {
                status.ErrorMessage = response.ErrorInformation.ToString();
            }
            return(status);
        }
Пример #2
0
        public static BuySafeStatus RegisterMerchant(
            String MerchantUserName,
            String MerchantFirstName,
            String MerchantLastName,
            String MerchantPhone,
            String MerchantEMail,
            String MerchantCompany,
            String MerchantAddress1,
            String MerchantAddress2,
            String MerchantCity,
            String MerchantState,
            String MerchantZip,
            String MerchantCountry,
            ResidenceTypes MerchantResidenceType,

            DateTime MinOrderDate,
            List <Store> Stores
            )
        {
            BuySafeWebReference.BuySafeAPI api = GetAPI();

            BuySafeWebReference.AddAccountRQ reqAccount = new BuySafeWebReference.AddAccountRQ();

            reqAccount.AddStoreList = new BuySafeWebReference.StoreInformation[Stores.Count];
            for (int i = 0; i < Stores.Count; i++)
            {
                reqAccount.AddStoreList[i] = GetStoreInformation(Stores[i]);
            }


            reqAccount.BusinessInformation = new BuySafeWebReference.BusinessInformation();

            BuySafeWebReference.Address a = new BuySafeWebReference.Address();
            a.CityName      = MerchantCity;
            a.Country       = MerchantCountry;
            a.CountryCode   = BuySafeWebReference.CountryCode.US;
            a.PostalCode    = MerchantZip;
            a.StateProvince = MerchantState;
            a.StreetLine1   = MerchantAddress1;
            a.StreetLine2   = MerchantAddress2;
            switch (MerchantResidenceType)
            {
            case ResidenceTypes.Residential:
                a.Type = BuySafeWebReference.AddressType.Home;
                break;

            case ResidenceTypes.Commercial:
            case ResidenceTypes.Unknown:
            default:
                a.Type = BuySafeWebReference.AddressType.Business;
                break;
            }
            a.Type = BuySafeWebReference.AddressType.Business;

            reqAccount.BusinessInformation.Address     = a;
            reqAccount.BusinessInformation.CompanyName = MerchantCompany;
            if (UseSandbox)
            {
                reqAccount.BusinessInformation.PromoCode = SandboxPromoCode;
            }
            else
            {
                reqAccount.BusinessInformation.PromoCode = LivePromoCode;
            }
            BuySafeWebReference.CustomDateTime sellingTime = new BuySafeWebReference.CustomDateTime();
            sellingTime.DateTimeValue = MinOrderDate;
            sellingTime.HasDateTime   = true;
            reqAccount.BusinessInformation.DateBeganSelling = sellingTime;
            reqAccount.BusinessInformation.Email            = MerchantEMail;
            reqAccount.BusinessInformation.FirstName        = MerchantFirstName;
            reqAccount.BusinessInformation.LastName         = MerchantLastName;
            BuySafeWebReference.Phone p = new BuySafeWebReference.Phone();
            p.Number = MerchantPhone;
            p.Type   = BuySafeWebReference.PhoneType.Business;
            reqAccount.BusinessInformation.Phone = p;

            BuySafeWebReference.LoginInformation creds = new BuySafeWebReference.LoginInformation();
            creds.AutoGenerateOnCollision = false;
            creds.UserName = MerchantUserName;
            reqAccount.LoginInformation = creds;

            BuySafeWebReference.AddAccountRS response = api.AddAccount(reqAccount);
            BuySafeStatus status = new BuySafeStatus();

            status.HasError = !response.Successful;
            if (status.HasError)
            {
                status.ErrorMessage = response.ErrorInformation.ToString();
            }
            else
            {
                status.Hash = response.AccountResponse.Hash;
            }
            status.UserName = MerchantUserName;
            return(status);
        }
Пример #3
0
        public static BuySafeRegistrationStatus BuySafeOneClickSignup()
        {
            String email = GetEmailAddress();

            if (String.IsNullOrEmpty(email))
            {
                return(new BuySafeRegistrationStatus()
                {
                    ErrorMessage = "No email addresses could be found. Please configure your email before signing up for buySAFE.",
                    Sucessful = false
                });
            }

            List <Store> stores       = Store.GetStoreList(true);
            Store        defaultStore = GetDefaultStore(stores);

            if (defaultStore == null)
            {
                return(new BuySafeRegistrationStatus()
                {
                    ErrorMessage = "No valid stores have been setup. Please setup a store before signing up for buySAFE.",
                    Sucessful = false
                });
            }

            Double gms = 1000;

            AppLogic.SetGlobalConfig("BuySafe.GMS", gms.ToString());

            var minOrderDate = DateTime.Now;

            using (var dbconn5 = DB.dbConn())
            {
                dbconn5.Open();
                using (var rscc = DB.GetRS("select min(capturedon) from orders", dbconn5))
                {
                    if (rscc.Read())
                    {
                        minOrderDate = DB.RSFieldDateTime(rscc, "caputredon");
                    }
                }
            }

            if (minOrderDate == DateTime.MinValue)
            {
                minOrderDate = DateTime.Now.AddDays(-1);
            }


            //register with buysafe
            BuySafeStatus status = BuySafeController.RegisterMerchant(
                defaultStore.ProductionURI, //username
                "AspDotNetStorefront",      //first name
                "Merchant",                 //last name
                "5555555555",               //phone
                email,                      //email
                defaultStore.ProductionURI, //Company Name
                "Address1",                 //address 1
                "Address2",                 //address 2
                "City",                     //city
                "Oregon",                   //state
                "12345",                    //zip
                "US",                       //country
                ResidenceTypes.Commercial,  //residence type
                minOrderDate,
                stores
                );

            if (status.HasError)
            {
                SysLog.LogMessage("buySafe registration failed.", status.ErrorMessage, MessageTypeEnum.GeneralException, MessageSeverityEnum.Error);
                return(new BuySafeRegistrationStatus()
                {
                    Sucessful = false
                });
            }
            AppLogic.SetGlobalConfig("BuySafe.Enabled", "true");
            AppLogic.SetGlobalConfig("BuySafe.UserName", status.UserName);
            AppLogic.SetGlobalConfig("BuySafe.Hash", HttpUtility.UrlEncode(status.Hash));
            AppLogic.SetGlobalConfig("BuySafe.TrialStartDate", DateTime.Now.ToShortDateString());
            AppLogic.m_RestartApp();
            return(new BuySafeRegistrationStatus()
            {
                Sucessful = true
            });
        }