Example #1
0
        public static async Task <List <MyArray> > GetResponse(LUM3DCartSetup setup, string specifyLocation)
        {
            string responseData = null;

            var baseAddress = new Uri(setup.SecureURL);

            using (var httpClient = new HttpClient {
                BaseAddress = baseAddress
            })
            {
                httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json");

                httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", "");

                httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", "");

                httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", "");

                httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", setup.AuthToken);

                using (var response = await httpClient.GetAsync(specifyLocation))
                {
                    if (!response.IsSuccessStatusCode)
                    {
                        throw new JsonReaderException(response.ReasonPhrase);
                    }

                    responseData = await response.Content.ReadAsStringAsync();

                    return(JsonConvert.DeserializeObject <List <MyArray> >(responseData));
                }
            }
        }
Example #2
0
        /// <summary>
        /// Create an sales order from external logistic.
        /// </summary>
        public static void ImportRecords(LUM3DCartSetup curSetup, LUM3DCartProcessOrder processOrder)
        {
            try
            {
                SOOrderEntry orderEntry = PXGraph.CreateInstance <SOOrderEntry>();

                SOOrder order = orderEntry.Document.Cache.CreateInstance() as SOOrder;

                order.OrderType        = curSetup.OrderType;
                order.CustomerID       = curSetup.CustomerID;
                order.CustomerOrderNbr = processOrder.OrderID;
                order.DocDate          = processOrder.OrderDate;

                order = orderEntry.Document.Insert(order);

                CreateOrderDetail(orderEntry, curSetup, order);

                orderEntry.Save.Press();

                CreatePaymentProcess(order);
            }
            catch (PXException ex)
            {
                PXProcessing.SetError <LUM3DCartProcessOrder>(ex.Message);
                throw;
            }
        }
Example #3
0
        public static void PrepareRecords(LUM3DCartSetup curSetup, DateTime?endDate)
        {
            LUM3DCartImportProc graph = PXGraph.CreateInstance <LUM3DCartImportProc>();

            LUM3DCartProcessOrder processOrder = graph.ImportOrderList.Current;

            if (processOrder == null)
            {
                try
                {
                    DeleteWrkTableRecs();
                    CreateProcessOrders(GetResponse(curSetup,
                                                    string.Format("3dCartWebAPI/v2/Orders?datestart={0}&limit={1}&orderstatus={2}", endDate.Value.AddDays(-7), 1000, ThreeDCartOrderStatus.New)).Result);
                }
                catch (Exception ex)
                {
                    PXProcessing.SetError <LUM3DCartProcessOrder>(ex.Message);
                    throw;
                }
            }
        }
Example #4
0
        /// <summary>
        /// Generate sales order line.
        /// </summary>
        public static void CreateOrderDetail(SOOrderEntry orderEntry, LUM3DCartSetup curSetup, SOOrder order)
        {
            try
            {
                List <MyArray> list = GetResponse(curSetup, "3dCartWebAPI/v2/Orders/" + order.CustomerOrderNbr).Result;

                UpdateSOContactAddress(orderEntry, list, order);

                var itemList = list.Find(x => x.OrderItemList.Count > 0).OrderItemList;

                for (int i = 0; i < itemList.Count; i++)
                {
                    SOLine line = orderEntry.Transactions.Cache.CreateInstance() as SOLine;

                    line.InventoryID = GetAcuInventoryID(orderEntry, itemList[i].ItemID);
                    line.OrderQty    = (decimal)itemList[i].ItemQuantity;
                    line.UnitPrice   = (decimal)itemList[i].ItemUnitPrice;

                    orderEntry.Transactions.Insert(line);
                }

                orderEntry.Taxes.Cache.SetValueExt <SOTaxTran.curyTaxAmt>(orderEntry.Taxes.Current, list[0].SalesTax + list[0].SalesTax2);
                orderEntry.CurrentDocument.SetValueExt <SOOrder.paymentMethodID>(order, GetAcuPymtMethod(orderEntry, order.CustomerID, list[0].BillingPaymentMethod));

                string tranID = list.Find(x => x.TransactionList.Count > 0).TransactionList[0].TransactionID;
                int    index  = tranID.IndexOf(':') + 2; // Because there is a space between the ':' of transaction ID.

                order.CustomerRefNbr = tranID.Contains(PX.Objects.PO.Messages.Completed) ? tranID.Substring(index, tranID.Length - index) : null;

                // Refer to PX.AmazonIntegration project SetDocumentLevelDiscountandTaxData() to manully update SOOrder total amount fields.
                order.CuryTaxTotal    = orderEntry.Taxes.Current.CuryTaxAmt;
                order.CuryOrderTotal += order.CuryTaxTotal;
            }
            catch (PXException ex)
            {
                PXProcessing.SetError <LUM3DCartProcessOrder>(ex.Message);
                throw;
            }
        }