www in docker support
This commit is contained in:
parent
539a848e95
commit
c227fce036
2145 changed files with 399596 additions and 58 deletions
|
|
@ -0,0 +1,59 @@
|
|||
package com.paypal.AuthorizeIntentExamples;
|
||||
|
||||
import com.paypal.http.HttpResponse;
|
||||
import com.paypal.orders.LinkDescription;
|
||||
import com.paypal.orders.Order;
|
||||
import com.paypal.payments.Capture;
|
||||
import com.paypal.payments.Refund;
|
||||
|
||||
public class RunAll {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
HttpResponse<Order> orderResponse = new CreateOrder().createOrder(false);
|
||||
String orderId = "";
|
||||
System.out.println("Creating Order...");
|
||||
if (orderResponse.statusCode() == 201) {
|
||||
orderId = ((Order)orderResponse.result()).id();
|
||||
System.out.println("Order ID: " + orderId);
|
||||
System.out.println("Links:");
|
||||
for (LinkDescription link : (Iterable<LinkDescription>)((Order)orderResponse.result()).links())
|
||||
System.out.println("\t" + link.rel() + ": " + link.href());
|
||||
}
|
||||
System.out.println("Created Successfully\n");
|
||||
System.out.println("Copy approve link and paste it in browser. Login with buyer account and follow the instructions.\nOnce approved hit enter...");
|
||||
System.in.read();
|
||||
System.out.println("Authorizing Order...");
|
||||
orderResponse = new AuthorizeOrder().authorizeOrder(orderId, false);
|
||||
String authId = "";
|
||||
if (orderResponse.statusCode() == 201) {
|
||||
System.out.println("Authorized Successfully\n");
|
||||
authId = ((Order)orderResponse.result()).purchaseUnits().get(0).payments().authorizations().get(0).id();
|
||||
}
|
||||
System.out.println("Capturing Order...");
|
||||
HttpResponse<Capture> captureOrderResponse = new CaptureOrder().captureOrder(authId, false);
|
||||
if (orderResponse.statusCode() == 201) {
|
||||
System.out.println("Captured Successfully");
|
||||
System.out.println("Status Code: " + captureOrderResponse.statusCode());
|
||||
System.out.println("Status: " + ((Capture)captureOrderResponse.result()).status());
|
||||
System.out.println("Capture ID: " + ((Capture)captureOrderResponse.result()).id());
|
||||
System.out.println("Links: ");
|
||||
for (com.paypal.payments.LinkDescription link : (Iterable<com.paypal.payments.LinkDescription>)((Capture)captureOrderResponse.result()).links())
|
||||
System.out.println("\t" + link.rel() + ": " + link.href() + "\tCall Type: " + link.method());
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println("Refunding Order...");
|
||||
HttpResponse<Refund> refundHttpResponse = new RefundOrder().refundOrder(((Capture)captureOrderResponse.result()).id(), false);
|
||||
if (refundHttpResponse.statusCode() == 201) {
|
||||
System.out.println("Refunded Successfully");
|
||||
System.out.println("Status Code: " + refundHttpResponse.statusCode());
|
||||
System.out.println("Status: " + ((Refund)refundHttpResponse.result()).status());
|
||||
System.out.println("Order ID: " + ((Refund)refundHttpResponse.result()).id());
|
||||
System.out.println("Links: ");
|
||||
for (com.paypal.payments.LinkDescription link : (Iterable<com.paypal.payments.LinkDescription>)((Refund)refundHttpResponse.result()).links())
|
||||
System.out.println("\t" + link.rel() + ": " + link.href() + "\tCall Type: " + link.method());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue