Esempio n. 1
0
        public static string CreateShippingString(PaypalRecord record, int ID)
        {
            StringBuilder shipping = new StringBuilder();

            shipping.Append(@"""a:25:{s:9:""""parent_id"""";s:{idlength}:""""{id}"""";s:19:""""customer_address_id"""";N;s:16:""""quote_address_id"""";N;s:9:""""region_id"""";s:1:""""1"""";s:11:""""customer_id"""";N;s:3:""""fax"""";N;s:6:""""region"""";s:{regionlength}:""""{region}"""";s:8:""""postcode"""";s:{postcodelength}:""""{postcode}"""";s:8:""""lastname"""";s:{lastnamelength}:""""{lastname}"""";s:6:""""street"""";s:{streetlength}:""""{street}"""";s:4:""""city"""";s:{citylength}:""""{city}"""";s:5:""""email"""";s:{emaillength}:""""{email}"""";s:9:""""telephone"""";N;s:10:""""country_id"""";s:2:""""{countryID}"""";s:9:""""firstname"""";s:{firstnamelength}:""""{firstname}"""";s:12:""""address_type"""";s:8:""""shipping"""";s:6:""""prefix"""";N;s:10:""""middlename"""";N;s:6:""""suffix"""";N;s:7:""""company"""";N;s:6:""""vat_id"""";N;s:12:""""vat_is_valid"""";N;s:14:""""vat_request_id"""";N;s:16:""""vat_request_date"""";N;s:19:""""vat_request_success"""";N;}""");
            shipping.Replace("{id}", ID.ToString());
            shipping.Replace("{idlength}", ID.ToString().Length.ToString());
            shipping.Replace("{postcode}", record.Postcode);
            shipping.Replace("{postcodelength}", record.Postcode.Length.ToString());
            var name = StringFunctions.ParseName(record.FullName);

            shipping.Replace("{firstname}", name.FirstName);
            shipping.Replace("{firstnamelength}", name.FirstName.Length.ToString());
            shipping.Replace("{lastname}", name.LastName);
            shipping.Replace("{lastnamelength}", name.LastName.Length.ToString());
            shipping.Replace("{street}", record.AddressLine1);
            shipping.Replace("{streetlength}", record.AddressLine1.Length.ToString());
            shipping.Replace("{region}", record.StateorCounty);
            shipping.Replace("{regionlength}", record.StateorCounty.Length.ToString());
            shipping.Replace("{city}", record.TownorCity);
            shipping.Replace("{citylength}", record.TownorCity.Length.ToString());
            shipping.Replace("{email}", record.FromEmailAddress);
            shipping.Replace("{emaillength}", record.FromEmailAddress.Length.ToString());
            shipping.Replace("{countryID}", GetCountryCode(record.Country));
            return(shipping.ToString());
        }
Esempio n. 2
0
        public static string CreateBillingString(PaypalRecord record, int ID)
        {
            StringBuilder shipping = new StringBuilder();

            shipping.Append(@"""a:25:{s:9:""""parent_id"""";s:{idlength}:""""{id}"""";s:19:""""customer_address_id"""";N;s:16:""""quote_address_id"""";N;s:9:""""region_id"""";s:1:""""1"""";s:11:""""customer_id"""";N;s:3:""""fax"""";N;s:6:""""region"""";s:{regionlength}:""""{region}"""";s:8:""""postcode"""";s:{postcodelength}:""""{postcode}"""";s:8:""""lastname"""";s:{lastnamelength}:""""{lastname}"""";s:6:""""street"""";s:{streetlength}:""""{street}"""";s:4:""""city"""";s:{citylength}:""""{city}"""";s:5:""""email"""";s:{emaillength}:""""{email}"""";s:9:""""telephone"""";N;s:10:""""country_id"""";s:2:""""{countryID}"""";s:9:""""firstname"""";s:{firstnamelength}:""""{firstname}"""";s:12:""""address_type"""";s:7:""""billing"""";s:6:""""prefix"""";N;s:10:""""middlename"""";N;s:6:""""suffix"""";N;s:7:""""company"""";N;s:6:""""vat_id"""";N;s:12:""""vat_is_valid"""";N;s:14:""""vat_request_id"""";N;s:16:""""vat_request_date"""";N;s:19:""""vat_request_success"""";N;}""");
            shipping.Replace("{id}", ID.ToString());
            shipping.Replace("{idlength}", ID.ToString().Length.ToString());
            shipping.Replace("{postcode}", record.Postcode);
            shipping.Replace("{postcodelength}", record.Postcode.Length.ToString());
            var name = StringFunctions.ParseName(record.FullName);

            shipping.Replace("{firstname}", name.FirstName);
            shipping.Replace("{firstnamelength}", name.FirstName.Length.ToString());
            shipping.Replace("{lastname}", name.LastName);
            shipping.Replace("{lastnamelength}", name.LastName.Length.ToString());
            shipping.Replace("{street}", record.AddressLine1);
            shipping.Replace("{streetlength}", record.AddressLine1.Length.ToString());
            shipping.Replace("{region}", record.StateorCounty);
            shipping.Replace("{regionlength}", record.StateorCounty.Length.ToString());
            shipping.Replace("{city}", record.TownorCity);
            shipping.Replace("{citylength}", record.TownorCity.Length.ToString());
            shipping.Replace("{email}", record.FromEmailAddress);
            shipping.Replace("{emaillength}", record.FromEmailAddress.Length.ToString());
            var regions = CultureInfo.GetCultures(CultureTypes.SpecificCultures);//.Select(x => new RegionInfo(x.LCID));

            foreach (CultureInfo cultureinfo in regions)
            {
                if (cultureinfo.EnglishName.Contains(record.Country))
                {
                    var regionInfo = new RegionInfo(cultureinfo.LCID);
                    shipping.Replace("{countryID}", regionInfo.TwoLetterISORegionName);
                    break;
                }
            }
            return(shipping.ToString());
        }