Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.paypal.api.payments;
  
  import  com.paypal.core.rest.JSONFormatter;
  import java.util.List;
  import  com.paypal.core.rest.PayPalRESTException;
  import  com.paypal.core.rest.PayPalResource;
  import  com.paypal.core.rest.OAuthTokenCredential;
 import  com.paypal.core.rest.HttpMethod;
 import  com.paypal.core.rest.RESTUtil;
 import  com.paypal.core.rest.QueryParameters;
 import  com.paypal.core.rest.APIContext;
 import  com.paypal.core.Constants;
 import  com.paypal.core.SDKVersion;
 import java.io.File;
 import java.util.Map;
 
 public class Capture  {

Identifier of the Capture transaction.
 
 	private String id;

Time the resource was created in UTC ISO8601 format.
 
 	private String createTime;

Time the resource was last updated in UTC ISO8601 format.
 
 	private String updateTime;

Amount being captured. If no amount is specified, amount is used from the authorization being captured. If amount is same as the amount that's authorized for, the state of the authorization changes to captured. If not, the state of the authorization changes to partially_captured. Alternatively, you could indicate a final capture by seting the is_final_capture flag to true.
 
 	private Amount amount;

whether this is a final capture for the given authorization or not. If it's final, all the remaining funds held by the authorization, will be released in the funding instrument.
 
 	private Boolean isFinalCapture;

State of the capture transaction.
 
 	private String state;

ID of the Payment resource that this transaction is based on.
 
 	private String parentPayment;

 
 	private List<Linkslinks;

Returns the last request sent to the Service

Returns:
Last request sent to the server
 
 	public static String getLastRequest() {
 		return PayPalResource.getLastRequest();
 	}

Returns the last response returned by the Service

Returns:
Last response got from the Service
 
 	public static String getLastResponse() {
 		return PayPalResource.getLastResponse();
 	}

Initialize using InputStream(of a Properties file)

Parameters:
is InputStream
Returns:
OAuthTokenCredential instance using client ID and client secret loaded from configuration.
Throws:
PayPalRESTException
 
 	public static OAuthTokenCredential initConfig(InputStream isthrows PayPalRESTException {
 		return PayPalResource.initConfig(is);
 	}

Initialize using a File(Properties file)

Parameters:
file File object of a properties entity
Returns:
OAuthTokenCredential instance using client ID and client secret loaded from configuration.
Throws:
PayPalRESTException
	public static OAuthTokenCredential initConfig(File filethrows PayPalRESTException {
		return PayPalResource.initConfig(file);
	}

Initialize using Properties

Parameters:
properties Properties object
Returns:
OAuthTokenCredential instance using client ID and client secret loaded from configuration.
	public static OAuthTokenCredential initConfig(Properties properties) {
		return PayPalResource.initConfig(properties);
	}
Default Constructor
	public Capture() {
	}

Parameterized Constructor
	public Capture(Amount amount) {
		this. = amount;
	}


Setter for id
	public Capture setId(String id) {
		this. = id;
		return this;
	}

Getter for id
	public String getId() {
		return this.;
	}


Setter for createTime
	public Capture setCreateTime(String createTime) {
		this. = createTime;
		return this;
	}

Getter for createTime
	public String getCreateTime() {
		return this.;
	}


Setter for updateTime
	public Capture setUpdateTime(String updateTime) {
		this. = updateTime;
		return this;
	}

Getter for updateTime
	public String getUpdateTime() {
		return this.;
	}


Setter for amount
	public Capture setAmount(Amount amount) {
		this. = amount;
		return this;
	}

Getter for amount
	public Amount getAmount() {
		return this.;
	}


Setter for isFinalCapture
	public Capture setIsFinalCapture(Boolean isFinalCapture) {
		this. = isFinalCapture;
		return this;
	}

Getter for isFinalCapture
		return this.;
	}


Setter for state
	public Capture setState(String state) {
		this. = state;
		return this;
	}

Getter for state
	public String getState() {
		return this.;
	}


Setter for parentPayment
	public Capture setParentPayment(String parentPayment) {
		this. = parentPayment;
		return this;
	}

Getter for parentPayment
		return this.;
	}


Setter for links
	public Capture setLinks(List<Linkslinks) {
		this. = links;
		return this;
	}

Getter for links
	public List<LinksgetLinks() {
		return this.;
	}


Obtain the Capture transaction resource for the given identifier.

Parameters:
accessToken Access Token used for the API call.
captureId String
Returns:
Capture
Throws:
PayPalRESTException
	public static Capture get(String accessTokenString captureIdthrows PayPalRESTException {
		APIContext apiContext = new APIContext(accessToken);
		return get(apiContextcaptureId);
	}

Obtain the Capture transaction resource for the given identifier.

Parameters:
apiContext APIContext used for the API call.
captureId String
Returns:
Capture
Throws:
PayPalRESTException
	public static Capture get(APIContext apiContextString captureIdthrows PayPalRESTException {
		if (apiContext == null) {
			throw new IllegalArgumentException("APIContext cannot be null");
		}
		if (apiContext.getAccessToken() == null || apiContext.getAccessToken().trim().length() <= 0) {
			throw new IllegalArgumentException("AccessToken cannot be null or empty");
		}
		if (apiContext.getHTTPHeaders() == null) {
			apiContext.setHTTPHeaders(new HashMap<StringString>());
		}
		apiContext.getHTTPHeaders().put(Constants.HTTP_CONTENT_TYPE_HEADER, Constants.HTTP_CONTENT_TYPE_JSON);
		apiContext.setSdkVersion(new SDKVersionImpl());
		if (captureId == null) {
			throw new IllegalArgumentException("captureId cannot be null");
		}
		Object[] parameters = new Object[] {captureId};
		String pattern = "v1/payments/capture/{0}";
		String resourcePath = RESTUtil.formatURIPath(patternparameters);
		String payLoad = "";
		return PayPalResource.configureAndExecute(apiContext, HttpMethod.GET, resourcePathpayLoadCapture.class);
	}


Creates (and processes) a new Refund Transaction added as a related resource.

Parameters:
accessToken Access Token used for the API call.
refund Refund
Returns:
Refund
Throws:
PayPalRESTException
	public Refund refund(String accessTokenRefund refundthrows PayPalRESTException {
		APIContext apiContext = new APIContext(accessToken);
		return refund(apiContextrefund);
	}

Creates (and processes) a new Refund Transaction added as a related resource.

Parameters:
apiContext APIContext used for the API call.
refund Refund
Returns:
Refund
Throws:
PayPalRESTException
	public Refund refund(APIContext apiContextRefund refundthrows PayPalRESTException {
		if (apiContext == null) {
			throw new IllegalArgumentException("APIContext cannot be null");
		}
		if (apiContext.getAccessToken() == null || apiContext.getAccessToken().trim().length() <= 0) {
			throw new IllegalArgumentException("AccessToken cannot be null or empty");
		}
		if (apiContext.getHTTPHeaders() == null) {
			apiContext.setHTTPHeaders(new HashMap<StringString>());
		}
		apiContext.getHTTPHeaders().put(Constants.HTTP_CONTENT_TYPE_HEADER, Constants.HTTP_CONTENT_TYPE_JSON);
		apiContext.setSdkVersion(new SDKVersionImpl());
		if (this.getId() == null) {
			throw new IllegalArgumentException("Id cannot be null");
		}
		if (refund == null) {
			throw new IllegalArgumentException("refund cannot be null");
		}
		Object[] parameters = new Object[] {this.getId()};
		String pattern = "v1/payments/capture/{0}/refund";
		String resourcePath = RESTUtil.formatURIPath(patternparameters);
		String payLoad = refund.toJSON();
		return PayPalResource.configureAndExecute(apiContext, HttpMethod.POST, resourcePathpayLoadRefund.class);
	}

Returns a JSON string corresponding to object state

Returns:
JSON representation
	public String toJSON() {
		return JSONFormatter.toJSON(this);
	}
	public String toString() {
		return toJSON();
	}
New to GrepCode? Check out our FAQ X