forked from rajarampadmanathan/Checkout-Java-SDK-1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetOrder.java
More file actions
executable file
·41 lines (35 loc) · 1.23 KB
/
GetOrder.java
File metadata and controls
executable file
·41 lines (35 loc) · 1.23 KB
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
package com.paypal;
import java.io.IOException;
import org.json.JSONObject;
import com.paypal.http.HttpResponse;
import com.paypal.http.serializer.Json;
import com.paypal.AuthorizeIntentExamples.CreateOrder;
import com.paypal.orders.Order;
import com.paypal.orders.OrdersGetRequest;
public class GetOrder extends PayPalClient {
/**
* Method to perform sample GET on an order
*
* @throws IOException Exceptions from API if any
*/
public void getOrder(String orderId) throws IOException {
OrdersGetRequest request = new OrdersGetRequest(orderId);
HttpResponse<Order> response = client().execute(request);
System.out.println("Full response body:");
System.out.println(new JSONObject(new Json().serialize(response.result())).toString(4));
}
/**
* 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.
*
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
HttpResponse<Order> response = new CreateOrder().createOrder(false);
new GetOrder().getOrder(response.result().id());
}
}