Ejemplo n.º 1
0
        private void CheckForSuccess()
        {
            if (IsCancelled)
            {
                return;
            }

            if (LineItems.All(li => li.StockConfirmed) && OrderApproved)
            {
                Send(new OrderFulfillmentSuccessfulMessage
                {
                    Id      = Guid.NewGuid(),
                    OrderId = OrderId
                });
            }
        }
Ejemplo n.º 2
0
        private void UpdateRemoteCheckoutFromLocalState(CompletionCallback callback)
        {
            MutationQuery query = new MutationQuery();

            // remove all line items them add them
            List <string> lineItemsToRemove = CartLineItems.ConvertToLineItemIds(LineItems.All());

            lineItemsToRemove.AddRange(DeletedLineItems);

            List <CheckoutLineItemInput> lineItemsToAdd = CartLineItems.ConvertToCheckoutLineItemInput(LineItems.All());

            DefaultQueries.checkout.LineItemsRemove(query, CurrentCheckout.id(), lineItemsToRemove);
            DefaultQueries.checkout.LineItemsAdd(query, CurrentCheckout.id(), lineItemsToAdd);

            Client.Mutation(query, (Mutation response, ShopifyError error) => {
                if (error != null)
                {
                    callback(error);
                    return;
                }

                DeletedLineItems.Clear();

                if (UpdateState(response.checkoutLineItemsAdd().checkout(), response.checkoutLineItemsAdd().userErrors()))
                {
                    if (CurrentCheckout.ready())
                    {
                        callback(null);
                    }
                    else
                    {
                        PollCheckoutAndUpdate(PollCheckoutReady, callback);
                    }
                }
                else
                {
                    HandleUserError(callback);
                }
            });
        }
Ejemplo n.º 3
0
        private void CreateRemoteCheckoutFromLocalState(CompletionCallback callback)
        {
            MutationQuery query = new MutationQuery();

            List <CheckoutLineItemInput> newLineItemInput = CartLineItems.ConvertToCheckoutLineItemInput(LineItems.All());

            DefaultQueries.checkout.Create(query, newLineItemInput);

            Client.Mutation(query, (Mutation response, ShopifyError error) => {
                if (error != null)
                {
                    callback(error);
                    return;
                }

                if (UpdateState(response.checkoutCreate().checkout(), response.checkoutCreate().userErrors()))
                {
                    if (CurrentCheckout.ready())
                    {
                        callback(null);
                    }
                    else
                    {
                        PollCheckoutAndUpdate(PollCheckoutReady, callback);
                    }
                }
                else
                {
                    HandleUserError(callback);
                }
            });
        }