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,50 @@
|
|||
package com.paypal.AuthorizeIntentExamples;
|
||||
|
||||
import com.paypal.PayPalClient;
|
||||
import com.paypal.http.HttpRequest;
|
||||
import com.paypal.http.HttpResponse;
|
||||
import com.paypal.http.serializer.Json;
|
||||
import com.paypal.payments.CapturesRefundRequest;
|
||||
import com.paypal.payments.LinkDescription;
|
||||
import com.paypal.payments.Money;
|
||||
import com.paypal.payments.Refund;
|
||||
import com.paypal.payments.RefundRequest;
|
||||
import java.io.IOException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class RefundOrder extends PayPalClient {
|
||||
public RefundRequest buildRequestBody() {
|
||||
RefundRequest refundRequest = new RefundRequest();
|
||||
Money money = new Money();
|
||||
money.currencyCode("USD");
|
||||
money.value("20.00");
|
||||
refundRequest.amount(money);
|
||||
return refundRequest;
|
||||
}
|
||||
|
||||
public HttpResponse<Refund> refundOrder(String captureId, boolean debug) throws IOException {
|
||||
CapturesRefundRequest request = new CapturesRefundRequest(captureId);
|
||||
request.prefer("return=representation");
|
||||
request.requestBody(buildRequestBody());
|
||||
HttpResponse<Refund> response = client().execute((HttpRequest)request);
|
||||
if (debug) {
|
||||
System.out.println("Status Code: " + response.statusCode());
|
||||
System.out.println("Status: " + ((Refund)response.result()).status());
|
||||
System.out.println("Refund Id: " + ((Refund)response.result()).id());
|
||||
System.out.println("Links: ");
|
||||
for (LinkDescription link : (Iterable<LinkDescription>)((Refund)response.result()).links())
|
||||
System.out.println("\t" + link.rel() + ": " + link.href() + "\tCall Type: " + link.method());
|
||||
System.out.println("Full response body:");
|
||||
System.out.println(new JSONObject(new Json().serialize(response.result())).toString(4));
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
new RefundOrder().refundOrder("<<REPLACE-WITH-VALID-CAPTURE-ID>>", true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue