Exemplo n.º 1
0
        /// <summary>
        /// Saves the order payments.
        /// </summary>
        /// <param name="orderPayments">The order payments.</param>
        /// <param name="amazonOrderId">The amazon order identifier.</param>
        /// <returns></returns>
        public bool SaveOrderPayments(AmazonOrderItemAndPayments orderPayments, int amazonOrderId)
        {
            orderPayments.OrderItem.AmazonOrderId = amazonOrderId;

            int orderItemId = (int)SaveOrderItem(orderPayments.OrderItem);

            if (orderItemId < 1)
            {
                return(false);
            }

            bool res = true;

            foreach (var batch in orderPayments.Payments.ForEach(payment => payment.OrderItemId = orderItemId)
                     .Batch(800))
            {
                res &= SaveOrderItemPayments(batch);
                if (!res)
                {
                    break;
                }
            }

            return(res);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the amazon order item.
        /// </summary>
        /// <param name="order">The order.</param>
        /// <returns></returns>
        private AmazonOrderItemAndPayments CreateAmazonOrderItem(Src.OrdersApi.Model.Order order)
        {
            AmazonOrderItemAndPayments orderItemAndPayments = new AmazonOrderItemAndPayments();
            var item = new AmazonOrderItem();

            if (order.IsSetAmazonOrderId())
            {
                item.OrderId = order.AmazonOrderId;
            }
            if (order.IsSetSellerOrderId())
            {
                item.SellerOrderId = order.SellerOrderId;
            }
            if (order.IsSetPurchaseDate())
            {
                item.PurchaseDate = order.PurchaseDate;
            }
            if (order.IsSetLastUpdateDate())
            {
                item.LastUpdateDate = order.LastUpdateDate;
            }
            if (order.IsSetOrderStatus())
            {
                #region Comment

                //      Pending, The order has been placed but payment has not been authorized. The order is not ready for shipment. Note that for orders with OrderType = Standard, the initial order status is Pending. For orders with OrderType = Preorder (available in JP only), the initial order status is PendingAvailability, and the order passes into the Pending status when the payment authorization process begins.
                //		Unshipped, Payment has been authorized and order is ready for shipment, but no items in the order have been shipped.
                //		PartiallyShipped, One or more (but not all) items in the order have been shipped.
                //		Shipped, All items in the order have been shipped.
                //		Canceled, The order was canceled.
                //		Unfulfillable, The order cannot be fulfilled. This state applies only to Amazon-fulfilled orders that were not placed on Amazon's retail web site.
                //		PendingAvailability, This status is available for pre-orders only. The order has been placed, payment has not been authorized, and the release date of the item is in the future. The order is not ready for shipment. Note that Preorder is a possible OrderType value in Japan (JP) only.
                //		InvoiceUnconfirmed, All items in the order have been shipped. The seller has not yet given confirmation to Amazon that the invoice has been shipped to the buyer. Note: This value is available only in China (CN).
                //		All default

                #endregion

                item.OrderStatus = order.OrderStatus;
            }
            if (order.IsSetNumberOfItemsShipped())
            {
                item.NumberOfItemsShipped = (int)order.NumberOfItemsShipped;
            }
            if (order.IsSetNumberOfItemsUnshipped())
            {
                item.NumberOfItemsUnshipped = (int)order.NumberOfItemsUnshipped;
            }
            if (order.IsSetOrderTotal() && order.OrderTotal.IsSetAmount())
            {
                item.OrderTotal = decimal.Parse(order.OrderTotal.Amount);
                if (order.OrderTotal.IsSetCurrencyCode())
                {
                    item.OrderTotalCurrency = order.OrderTotal.CurrencyCode;
                }
                else
                {
                    Log.Error("got empty currency code");
                }
            }
            if (order.IsSetPaymentExecutionDetail())
            {
                orderItemAndPayments.Payments = order.PaymentExecutionDetail
                                                .Select(CreatePayment)
                                                .ToList();
            }

            orderItemAndPayments.OrderItem = item;
            return(orderItemAndPayments);
        }