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 Sale  {

Identifier of the authorization transaction.
 
 	private String id;

Time the resource was created.
 
 	private String createTime;

Time the resource was last updated.
 
 	private String updateTime;

Amount being collected.
 
 	private Amount amount;

specifies payment mode of the transaction
 
 	private String paymentMode;

State of the sale transaction.
 
 	private String state;

Reason code for the transaction state being Pending or Reversed.
 
 	private String reasonCode;

Protection Eligibility of the Payer
 
Protection Eligibility Type of the Payer
 
Expected clearing time for eCheck Transactions
 
 	private String clearingTime;

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 Sale() {
	}

Parameterized Constructor
	public Sale(Amount amountString stateString parentPayment) {
		this. = amount;
		this. = state;
		this. = parentPayment;
	}


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

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


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

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


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

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


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

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


Setter for paymentMode
	public Sale setPaymentMode(String paymentMode) {
		this. = paymentMode;
		return this;
	}

Getter for paymentMode
	public String getPaymentMode() {
		return this.;
	}


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

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


Setter for reasonCode
	public Sale setReasonCode(String reasonCode) {
		this. = reasonCode;
		return this;
	}

Getter for reasonCode
	public String getReasonCode() {
		return this.;
	}


Setter for protectionEligibility
	public Sale setProtectionEligibility(String protectionEligibility) {
		this. = protectionEligibility;
		return this;
	}

Getter for protectionEligibility
	}


Setter for protectionEligibilityType
	public Sale setProtectionEligibilityType(String protectionEligibilityType) {
		this. = protectionEligibilityType;
		return this;
	}

Getter for protectionEligibilityType
	}


Setter for clearingTime
	public Sale setClearingTime(String clearingTime) {
		this. = clearingTime;
		return this;
	}

Getter for clearingTime
	public String getClearingTime() {
		return this.;
	}


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

Getter for parentPayment
		return this.;
	}


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

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


Obtain the Sale transaction resource for the given identifier.

Parameters:
accessToken Access Token used for the API call.
saleId String
Returns:
Sale
Throws:
PayPalRESTException
	public static Sale get(String accessTokenString saleIdthrows PayPalRESTException {
		APIContext apiContext = new APIContext(accessToken);
		return get(apiContextsaleId);
	}

Obtain the Sale transaction resource for the given identifier.

Parameters:
apiContext APIContext used for the API call.
saleId String
Returns:
Sale
Throws:
PayPalRESTException
	public static Sale get(APIContext apiContextString saleIdthrows 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 (saleId == null) {
			throw new IllegalArgumentException("saleId cannot be null");
		}
		Object[] parameters = new Object[] {saleId};
		String pattern = "v1/payments/sale/{0}";
		String resourcePath = RESTUtil.formatURIPath(patternparameters);
		String payLoad = "";
		return PayPalResource.configureAndExecute(apiContext, HttpMethod.GET, resourcePathpayLoadSale.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/sale/{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