-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathGetOrderSample.cs
51 lines (46 loc) · 1.93 KB
/
GetOrderSample.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using BraintreeHttp;
using PayPalCheckoutSdk.Core;
using PayPalCheckoutSdk.Orders;
using Samples.CaptureIntentExamples;
namespace Samples
{
public class GetOrderSample
{
/*
This method cn be used to retrieve an order by passing the order id.
*/
public async static Task<HttpResponse> GetOrder(string orderId, bool debug = false)
{
OrdersGetRequest request = new OrdersGetRequest(orderId);
var response = await PayPalClient.client().Execute(request);
var result = response.Result<Order>();
Console.WriteLine("Retrieved Order Status");
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;
}
/*
This is the driver method which invokes the getOrder function with Order Id
to retrieve an order details.
To get the correct Order id, we are using the createOrder to create new order
and then we are using the newly created order id.
*/
// static void Main(string[] args)
// {
// HttpResponse createdResponse = CreateOrderSample.CreateOrder().Result;
// GetOrder(createdResponse.Result<Order>().Id).Wait();
// }
}
}