/*
         *  This method cn be used to patch an order by passing the order id.
         */
        public async static Task <HttpResponse> PatchOrder(string orderId, bool debug = false)
        {
            var request = new OrdersPatchRequest <Object>(orderId);

            request.RequestBody(BuildPatchRequest());
            var response = await PayPalClient.client().Execute(request);

            if (debug)
            {
                var ordersGetRequest = new OrdersGetRequest(orderId);
                response = await PayPalClient.client().Execute(ordersGetRequest);

                var result = response.Result <Order>();
                Console.WriteLine("Retrieved Order Status After Patch");
                Console.WriteLine("Status: {0}", result.Status);
                Console.WriteLine("Order Id: {0}", result.Id);
                Console.WriteLine("Intent: {0}", result.Intent);
                Console.WriteLine("Links:");
                foreach (LinkDescription link in result.Links)
                {
                    Console.WriteLine("\t{0}: {1}\tCall Type: {2}", link.Rel, link.Href, link.Method);
                }
                AmountWithBreakdown amount = result.PurchaseUnits[0].Amount;
                Console.WriteLine("Total Amount: {0} {1}", amount.CurrencyCode, amount.Value);
                Console.WriteLine("Response JSON: \n {0}", PayPalClient.ObjectToJSONString(result));
            }
            return(response);
        }
Exemplo n.º 2
0
        /*
         *  Method for refund the capture. Valid capture Id should be
         *       passed an argument to this method.
         */
        public async static Task <HttpResponse> CapturesRefund(string CaptureId, bool debug = false)
        {
            var request = new CapturesRefundRequest(CaptureId);

            request.Prefer("return=representation");
            RefundRequest refundRequest = new RefundRequest()
            {
                Amount = new Money {
                    Value        = "20.00",
                    CurrencyCode = "USD"
                }
            };

            request.RequestBody(refundRequest);
            var response = await PayPalClient.client().Execute(request);

            if (debug)
            {
                var result = response.Result <Refund>();
                Console.WriteLine("Status: {0}", result.Status);
                Console.WriteLine("Refund Id: {0}", result.Id);
                Console.WriteLine("Links:");
                foreach (LinkDescription link in result.Links)
                {
                    Console.WriteLine("\t{0}: {1}\tCall Type: {2}", link.Rel, link.Href, link.Method);
                }
                Console.WriteLine("Response JSON: \n {0}", PayPalClient.ObjectToJSONString(result));
            }
            return(response);
        }