public void ProcessOrder(long shopifyOrderId)
        {
            // Clear-out any un-Released Transaction
            //
            ProcessPaymentReleases(shopifyOrderId);

            // Refresh Status and run for Payment Transaction
            //
            ProcessPaymentTransaction(shopifyOrderId);
            ProcessPaymentReleases(shopifyOrderId);

            // Refresh Status and run for Refund Transactions
            //
            var rootAction = _pendingActionService.Create(shopifyOrderId);

            foreach (var refundAction in rootAction.RefundPaymentActions)
            {
                ProcessRefundTransaction(refundAction);
                ProcessPaymentReleases(shopifyOrderId);
            }

            var rootAction2 = _pendingActionService.Create(shopifyOrderId);

            foreach (var memoAction in rootAction2.AdjustmentMemoActions)
            {
                ProcessAdjustmentMemo(memoAction);
                ProcessAdjustmentReleases(shopifyOrderId);
            }
        }
Exemplo n.º 2
0
        public void RunOrder(long shopifyOrderId)
        {
            try
            {
                CorrectSalesOrderWithUnknownRef(shopifyOrderId);

                // *** SAVE THIS, JONES! - This little branch of logic increases throughput!!
                //
                var orderPreAction = _pendingActionService.Create(shopifyOrderId).OrderAction;
                if (orderPreAction.ActionCode == ActionCode.UpdateInAcumatica && !orderPreAction.IsValid)
                {
                    _acumaticaOrderPaymentPut.ProcessOrder(shopifyOrderId);
                }

                var orderAction = _pendingActionService.Create(shopifyOrderId).OrderAction;
                if (!orderAction.IsValid)
                {
                    _logService.Log(LogBuilder.SkippingInvalidShopifyOrder(shopifyOrderId));
                    return;
                }

                if (orderAction.ActionCode == ActionCode.CreateInAcumatica)
                {
                    CreateSalesOrder(shopifyOrderId);
                    _acumaticaOrderPaymentPut.ProcessOrder(shopifyOrderId);
                    return;
                }

                if (orderAction.ActionCode == ActionCode.UpdateInAcumatica)
                {
                    _acumaticaOrderPaymentPut.ProcessOrder(shopifyOrderId);
                    UpdateExistingSalesOrder(shopifyOrderId);
                    return;
                }

                if (orderAction.ActionCode == ActionCode.CreateBlankSyncRecord)
                {
                    CreateBlankSalesOrderRecord(shopifyOrderId);
                    return;
                }
            }
            catch (Exception ex)
            {
                _systemLogger.Error(ex);
                _logService.Log($"Encountered error syncing Shopify Order {shopifyOrderId}");
                _syncOrderRepository.IncreaseOrderErrorCount(shopifyOrderId);
            }
        }
Exemplo n.º 3
0
        public ActionResult OrderAnalysis(long shopifyOrderId)
        {
            var financialSummary = _analysisDataService.GetOrderFinancialSummary(shopifyOrderId);
            var rootAction       = _pendingActionService.Create(shopifyOrderId);

            var record      = _shopifyOrderRepository.RetrieveOrder(shopifyOrderId);
            var order       = _shopifyJsonService.RetrieveOrder(record.ShopifyOrderId);
            var finAnalyzer = record.ToFinAnalyzer(order);

            var shopifyDetail = new
            {
                ShopifyOrderId      = shopifyOrderId,
                ShopifyOrderNbr     = record.ShopifyOrderNumber,
                ShopifyOrderHref    = _shopifyUrlService.ShopifyOrderUrl(shopifyOrderId),
                ShopifyCustomerId   = record.ShopifyCustomer.ShopifyCustomerId,
                ShopifyCustomerHref = _shopifyUrlService.ShopifyCustomerUrl(record.ShopifyCustomer.ShopifyCustomerId),

                ShopifyFinancialStatus     = record.ShopifyFinancialStatus,
                ShopifyFulfillmentStatus   = record.ShopifyFulfillmentStatus,
                ShopifyIsCancelled         = record.ShopifyIsCancelled,
                ShopifyAreAllItemsRefunded = record.IsCancelledOrAllRefunded(),

                Transfer = finAnalyzer,
            };

            return(new JsonNetResult(new
            {
                FinancialSummary = financialSummary,
                ShopifyDetail = shopifyDetail,
                RootAction = rootAction,
            }));
        }