Ejemplo n.º 1
0
        public async Task <bool> ShoppingCartGuestCustomerSet(int shoppingCart, string customerfirstname, string customerMail, string customerlastname, string store)
        {
            try
            {
                var sessionId = await this.GetSessionId().ConfigureAwait(false);

                var customer = new shoppingCartCustomerEntity
                {
                    email      = customerMail,
                    firstname  = customerfirstname,
                    lastname   = customerlastname,
                    website_id = 0,
                    store_id   = 0,
                    mode       = "guest",
                };

                var res = await this._magentoSoapService.shoppingCartCustomerSetAsync(sessionId.SessionId, shoppingCart, customer, store).ConfigureAwait(false);

                return(res.result);
            }
            catch (Exception exc)
            {
                throw new MagentoSoapException(string.Format("An error occured during GetMagentoInfoAsync()"), exc);
            }
        }
Ejemplo n.º 2
0
        public async Task <bool> ShoppingCartCustomerSet(int shoppingCart, int customerId, string customerPass, string store)
        {
            try
            {
                var sessionId = await this.GetSessionId().ConfigureAwait(false);

                var cutomers = await this._magentoSoapService.customerCustomerListAsync(sessionId.SessionId, new filters()).ConfigureAwait(false);

                var customer = cutomers.result.First(x => x.customer_id == customerId);

                var customerShoppingCart = new shoppingCartCustomerEntity
                {
                    confirmation         = (customer.confirmation ? 1 : 0).ToString(CultureInfo.InvariantCulture),
                    customer_id          = customer.customer_id,
                    customer_idSpecified = customer.customer_idSpecified,
                    email             = customer.email,
                    firstname         = customer.firstname,
                    group_id          = customer.group_id,
                    group_idSpecified = customer.group_idSpecified,
                    lastname          = customer.lastname,
                    mode                = "customer",
                    password            = customerPass,
                    store_id            = customer.store_id,
                    store_idSpecified   = customer.store_idSpecified,
                    website_id          = customer.website_id,
                    website_idSpecified = customer.website_idSpecified
                };
                var res = await this._magentoSoapService.shoppingCartCustomerSetAsync(sessionId.SessionId, shoppingCart, customerShoppingCart, store).ConfigureAwait(false);

                return(res.result);
            }
            catch (Exception exc)
            {
                throw new MagentoSoapException(string.Format("An error occured during GetMagentoInfoAsync()"), exc);
            }
        }
Ejemplo n.º 3
0
        public string create_order_g360(Models.g360_order[] g360order)
        {
            string result = "";

            foreach (var order in g360order)
            {
                try
                {
                    MagentoService mservice = new MagentoService();
                    String         mlogin   = mservice.login("admin", "Interconnection123!");
                    //create shopping cart
                    var cart = mservice.shoppingCartCreate(mlogin, "1");
                    //set customer to cart
                    shoppingCartCustomerEntity customer = new shoppingCartCustomerEntity();
                    customer.firstname  = order.Organization_Name;
                    customer.lastname   = order.Organization_Name;
                    customer.email      = order.Email;
                    customer.mode       = "guest";
                    customer.website_id = 1;
                    mservice.shoppingCartCustomerSet(mlogin, cart, customer, "1");
                    //set customer address
                    List <shoppingCartCustomerAddressEntity> customer_Address_List = new List <shoppingCartCustomerAddressEntity>();
                    shoppingCartCustomerAddressEntity        address = new shoppingCartCustomerAddressEntity();
                    address.mode               = "billing";
                    address.firstname          = order.Organization_Name;
                    address.lastname           = order.Organization_Name;
                    address.street             = order.Address1 + " " + order.Address2;
                    address.city               = order.City;
                    address.region             = order.State;
                    address.country_id         = "US";
                    address.postcode           = order.Zip;
                    address.telephone          = order.Phone;
                    address.is_default_billing = 1;
                    customer_Address_List.Add(address);
                    shoppingCartCustomerAddressEntity customer_Address_Billing = new shoppingCartCustomerAddressEntity();
                    customer_Address_Billing.mode = "shipping";
                    // If you have already a Magento User address list then use below field "address_id".
                    //customer_Address_Billing.address_id = Session["Customer_Address_ID"].ToString();
                    customer_Address_Billing.firstname  = order.Organization_Name;
                    customer_Address_Billing.lastname   = order.Organization_Name;
                    customer_Address_Billing.company    = order.Organization_Name;
                    customer_Address_Billing.street     = order.Address1 + " " + order.Address2;
                    customer_Address_Billing.city       = order.City;
                    customer_Address_Billing.country_id = "US";
                    customer_Address_Billing.region     = order.State;
                    customer_Address_Billing.postcode   = order.Zip;
                    customer_Address_Billing.telephone  = order.Phone;
                    customer_Address_Billing.fax        = "";
                    customer_Address_List.Add(customer_Address_Billing);
                    mservice.shoppingCartCustomerAddresses(mlogin, cart, customer_Address_List.ToArray(), "1");
                    //add product
                    var Products_list = new shoppingCartProductEntity()
                    {
                        qty          = order.Quantity,
                        qtySpecified = true,
                        sku          = order.Display_Name
                    };



                    mservice.shoppingCartProductAdd(mlogin, cart, new shoppingCartProductEntity[] { Products_list }, null);
                    //add shipping method
                    var avaiable_method = mservice.shoppingCartShippingList(mlogin, cart, "1");

                    mservice.shoppingCartShippingMethod(mlogin, cart, "storepickup_storepickup", "1");
                    //add payment method
                    var avaiable_payment = mservice.shoppingCartPaymentList(mlogin, cart, "1");
                    shoppingCartPaymentMethodEntity payment_method_entity = new shoppingCartPaymentMethodEntity();
                    // payment_method_entity.method = "custompayment";
                    payment_method_entity.method       = "free";
                    payment_method_entity.cc_cid       = null;
                    payment_method_entity.cc_owner     = null;
                    payment_method_entity.cc_number    = null;
                    payment_method_entity.cc_type      = null;
                    payment_method_entity.cc_exp_month = null;
                    payment_method_entity.cc_exp_year  = null;

                    mservice.shoppingCartPaymentMethod(mlogin, cart, payment_method_entity, "1");
                    //var price_total = mservice.shoppingCartTotals(mlogin, cart, "1");
                    var order_ID = mservice.shoppingCartOrder(mlogin, cart, "1", null);
                    result += "<p style='color:green'>Order " + order.Display_Name + " for " + order.Organization_Name + " Created\n</p>";
                }
                catch (Exception e)
                {
                    result += "<p style='color:red'>Order " + order.Display_Name + " for " + order.Organization_Name + "Failed\n Message : " + e.Message + "\n</p>";
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
        public string create_order_ts(Models.ts_order[] tsorder)
        {
            string result = "";

            foreach (var order in tsorder)
            {
                try
                {
                    MagentoService mservice = new MagentoService();
                    String         mlogin   = mservice.login("admin", "Interconnection123!");
                    //create shopping cart
                    var cart = mservice.shoppingCartCreate(mlogin, "1");
                    //set customer to cart
                    shoppingCartCustomerEntity customer = new shoppingCartCustomerEntity();
                    customer.firstname            = "import";
                    customer.lastname             = "Orders";
                    customer.email                = "*****@*****.**";
                    customer.password             = "******";
                    customer.customer_id          = 15795;
                    customer.customer_idSpecified = true;
                    customer.mode       = "customer";
                    customer.website_id = 1;
                    mservice.shoppingCartCustomerSet(mlogin, cart, customer, "1");
                    //set customer address
                    List <shoppingCartCustomerAddressEntity> customer_Address_List = new List <shoppingCartCustomerAddressEntity>();
                    shoppingCartCustomerAddressEntity        address = new shoppingCartCustomerAddressEntity();
                    address.mode               = "billing";
                    address.firstname          = order.first_name;
                    address.lastname           = order.last_name;
                    address.street             = order.Org_Street_Address;
                    address.city               = order.Org_City;
                    address.region             = order.Org_State;
                    address.country_id         = "US";
                    address.postcode           = order.Org_Zip_Code;
                    address.telephone          = order.Org_Phone;
                    address.is_default_billing = 1;
                    customer_Address_List.Add(address);
                    shoppingCartCustomerAddressEntity customer_Address_Billing = new shoppingCartCustomerAddressEntity();
                    customer_Address_Billing.mode = "shipping";
                    // If you have already a Magento User address list then use below field "address_id".
                    //customer_Address_Billing.address_id = Session["Customer_Address_ID"].ToString();
                    customer_Address_Billing.firstname  = order.first_name;
                    customer_Address_Billing.lastname   = order.last_name;
                    customer_Address_Billing.company    = order.Org_Name;
                    customer_Address_Billing.street     = order.Org_Street_Address;
                    customer_Address_Billing.city       = order.Org_City;
                    customer_Address_Billing.country_id = "US";
                    customer_Address_Billing.region     = order.Org_State;
                    customer_Address_Billing.postcode   = order.Org_Zip_Code;
                    customer_Address_Billing.telephone  = order.Org_Phone;
                    customer_Address_Billing.fax        = "";
                    customer_Address_List.Add(customer_Address_Billing);
                    mservice.shoppingCartCustomerAddresses(mlogin, cart, customer_Address_List.ToArray(), "1");
                    //add product
                    var Products_list = new shoppingCartProductEntity()
                    {
                        qty          = order.Total_Product_Quantity,
                        qtySpecified = true,
                        sku          = order.Item_ID
                    };



                    mservice.shoppingCartProductAdd(mlogin, cart, new shoppingCartProductEntity[] { Products_list }, null);
                    //add shipping method
                    var avaiable_method = mservice.shoppingCartShippingList(mlogin, cart, "1");

                    mservice.shoppingCartShippingMethod(mlogin, cart, "fedex_FEDEX_GROUND", "1");
                    //add payment method
                    var avaiable_payment = mservice.shoppingCartPaymentList(mlogin, cart, "1");
                    shoppingCartPaymentMethodEntity payment_method_entity = new shoppingCartPaymentMethodEntity();
                    payment_method_entity.method = "custompayment";
                    //   payment_method_entity.method = "authorizenet";
                    payment_method_entity.cc_cid       = null;
                    payment_method_entity.cc_owner     = null;
                    payment_method_entity.cc_number    = null;
                    payment_method_entity.cc_type      = null;
                    payment_method_entity.cc_exp_month = null;
                    payment_method_entity.cc_exp_year  = null;

                    mservice.shoppingCartPaymentMethod(mlogin, cart, payment_method_entity, "1");
                    //var price_total = mservice.shoppingCartTotals(mlogin, cart, "1");
                    var order_ID = mservice.shoppingCartOrder(mlogin, cart, "1", null);
                    result += "<p style='color:green'>Order " + order.Item_ID + " for " + order.Org_Contact_Name + " Created\n</p>";
                }
                catch (Exception e)
                {
                    result += "<p style='color:red'>Order " + order.Item_ID + " for " + order.Org_Contact_Name + "Failed\n Message : " + e.Message + "\n</p>";
                }
            }
            return(result);
        }