/* * 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); }
//This function can be used to perform authorization on the approved order. public async static Task <PayPalHttp.HttpResponse> AuthorizeOrder(string OrderId, bool debug = false) { var request = new OrdersAuthorizeRequest(OrderId); request.Prefer("return=representation"); request.RequestBody(new AuthorizeRequest()); var response = await PayPalClient.client().Execute(request); string s = ""; if (debug) { var result = response.Result <Order>(); s = s + "Status: " + result.Status + "\n"; s = s + "Order Id: " + result.Id + "\n"; s = s + "Authorization Id: " + result.PurchaseUnits[0].Payments.Authorizations[0].Id + "\n"; s = s + "Intent: " + result.CheckoutPaymentIntent + "\n"; s = s + "Links:"; foreach (LinkDescription link in result.Links) { s = s + "Rel: " + link.Rel + " | " + link.Href + " | " + link.Method + "\n"; } AmountWithBreakdown amount = result.PurchaseUnits[0].AmountWithBreakdown; s = s + "Buyer: "; s = s + "\tEmail Address: " + result.Payer.Email; // Console.WriteLine("Response JSON: \n {0}", PayPalClient.ObjectToJSONString(result)); } MessageBox.Show(s); return(response); }
//This method can be used to capture the payment on the approved authorization. public async static Task <HttpResponse> CaptureOrder(string AuthorizationId, bool debug = false) { var request = new AuthorizationsCaptureRequest(AuthorizationId); request.Prefer("return=representation"); request.RequestBody(new CaptureRequest()); var response = await PayPalClient.client().Execute(request); if (debug) { var result = response.Result <Capture>(); Console.WriteLine("Status: {0}", result.Status); Console.WriteLine("Order 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); }