コード例 #1
0
        /// <summary>
        /// A helper function designed to construct a refund object that will be accepted by Shopify Refund "/orders/#{order_id}/refunds/calculate.json" endpoint
        /// </summary>
        public Refund Prepare_Calculate(Order order)
        {
            var RequestedRefund = new Refund()
            {
                Currency = "USD",
                Shipping = new Shipping()
                {
                    FullRefund = true,
                },
                RefundLineItems = new List <ShopifySharp.RefundLineItem>(),
            };
            var liList = new List <RefundLineItem>();

            foreach (var li in order.LineItems)
            {
                var newLi = new ShopifySharp.RefundLineItem()
                {
                    LineItemId  = li.Id,
                    Quantity    = li.Quantity,
                    RestockType = "no_restock",
                };
                liList.Add(newLi);
            }
            RequestedRefund.RefundLineItems = liList;
            return(RequestedRefund);
        }
コード例 #2
0
        /// <summary>
        /// A helper function designed to construct a refund object that will be accepted by Shopify Refund "/orders/#{order_id}/refunds.json" endpoint
        /// </summary>
        public Refund Prepare_Refund(Refund calculateRefundResponse)
        {
            var fullRefundForAnOrder = new Refund()
            {
                Currency = "USD",
                Notify   = true,
                Note     = "Shopify Sharp Test",
                Shipping = new Shipping()
                {
                    FullRefund = true,
                },
                RefundLineItems = new List <ShopifySharp.RefundLineItem>(),
                Transactions    = new List <ShopifySharp.Transaction>(),
            };
            var liList = new List <RefundLineItem>();

            foreach (var orderLi in calculateRefundResponse.RefundLineItems)
            {
                var lineItem = new ShopifySharp.RefundLineItem()
                {
                    LineItemId  = orderLi.LineItemId,
                    Quantity    = orderLi.Quantity,
                    RestockType = orderLi.RestockType,
                };
                liList.Add(lineItem);
            }
            ;
            fullRefundForAnOrder.RefundLineItems = liList;
            var transactionList = new List <Transaction>();

            foreach (var shopifyTransaction in calculateRefundResponse.Transactions)
            {
                var transactionLi = new ShopifySharp.Transaction()
                {
                    ParentId = shopifyTransaction.ParentId,
                    Amount   = shopifyTransaction.Amount,
                    Kind     = "refund",
                    Gateway  = "ShopifySharp Test",
                };
                transactionList.Add(transactionLi);
            }
            fullRefundForAnOrder.Transactions = transactionList;
            return(fullRefundForAnOrder);
        }