Skip to content

Commit

Permalink
Add basic console logging for orders/v2 requests made
Browse files Browse the repository at this point in the history
  • Loading branch information
scannillo committed Oct 2, 2019
1 parent f0d7b75 commit c0de50b
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public BTRestController(RestTemplate restTemplate, @Value("${token}") String tok

@RequestMapping("/")
String hello() {
System.out.println("\nHello, World\n");
return "Hello, World";
}

Expand Down Expand Up @@ -146,9 +147,16 @@ OrderValidationInfo getOrderValidationInfo() {
" ]\n" +
"}";

System.out.println("******************************");
System.out.println("\nREQUEST to /v2/checkout/orders:");
System.out.println("Headers: " + orderHeaders.toString());

HttpEntity<String> orderRequest = new HttpEntity<>(orderBody, orderHeaders);
ResponseEntity<Order> orderResponse = restTemplate.postForEntity(url + "/v2/checkout/orders", orderRequest, Order.class);

System.out.println("OrderID: " + orderResponse.getBody().getId());
System.out.println("HTTP status code: " + orderResponse.getStatusCode());

return new OrderValidationInfo(uat, orderResponse.getBody().getId());
}

Expand All @@ -158,9 +166,16 @@ OrderCaptureInfo captureOrder(@PathVariable String orderId) {
orderHeaders.add("Authorization", token);
orderHeaders.setContentType(MediaType.APPLICATION_JSON);

System.out.println("******************************");
System.out.println("\nREQUEST to /v2/checkout/orders/<order-id>/capture:");
System.out.println("Headers: " + orderHeaders.toString());

HttpEntity<String> orderRequest = new HttpEntity<>(null, orderHeaders);
ResponseEntity<Order> orderResponse = restTemplate.postForEntity(url + "/v2/checkout/orders/" + orderId + "/capture", orderRequest, Order.class);

System.out.println("OrderID: " + orderResponse.getBody().getId());
System.out.println("HTTP status code: " + orderResponse.getStatusCode());

return new OrderCaptureInfo(orderResponse.getBody().getId(), orderResponse.getBody().getStatus());
}
}

0 comments on commit c0de50b

Please sign in to comment.