index
int64
0
0
repo_id
stringlengths
9
205
file_path
stringlengths
31
246
content
stringlengths
1
12.2M
__index_level_0__
int64
0
10k
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/MerchantInfo.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class MerchantInfo extends PayPalModel { /** * The merchant email address. Maximum length is 260 characters. */ private String email; /** * The merchant first name. Maximum length is 30 characters. */ private String firstName; /** * The merchant last name. Maximum length is 30 characters. */ private String lastName; /** * The merchant address. */ private InvoiceAddress address; /** * The merchant company business name. Maximum length is 100 characters. */ private String businessName; /** * The merchant phone number. */ private Phone phone; /** * The merchant fax number. */ private Phone fax; /** * The merchant website. Maximum length is 2048 characters. */ private String website; /** * The merchant tax ID. Maximum length is 100 characters. */ private String taxId; /** * Option to provide a label to the additional_info field. 40 characters max. */ private String additionalInfoLabel; /** * Additional information, such as business hours. Maximum length is 40 characters. */ private String additionalInfo; /** * Default Constructor */ public MerchantInfo() { } /** * Parameterized Constructor */ public MerchantInfo(String email) { this.email = email; } }
3,800
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/CurrencyConversion.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class CurrencyConversion extends PayPalModel { /** * Date of validity for the conversion rate. */ private String conversionDate; /** * 3 letter currency code */ private String fromCurrency; /** * Amount participating in currency conversion, set to 1 as default */ private String fromAmount; /** * 3 letter currency code */ private String toCurrency; /** * Amount resulting from currency conversion. */ private String toAmount; /** * Field indicating conversion type applied. */ private String conversionType; /** * Allow Payer to change conversion type. */ private Boolean conversionTypeChangeable; /** * Base URL to web applications endpoint */ private String webUrl; /** * */ private List<DefinitionsLinkdescription> links; /** * Default Constructor */ public CurrencyConversion() { } /** * Parameterized Constructor */ public CurrencyConversion(String fromCurrency, String fromAmount, String toCurrency, String toAmount) { this.fromCurrency = fromCurrency; this.fromAmount = fromAmount; this.toCurrency = toCurrency; this.toAmount = toAmount; } }
3,801
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PayerNotification.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class PayerNotification extends PayPalModel { /** * Email Address associated with the Payer's PayPal Account. */ private String email; /** * Default Constructor */ public PayerNotification() { } }
3,802
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/FileAttachment.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class FileAttachment extends PayPalModel { /** * Name of the file attached. */ private String name; /** * URL of the attached file that can be downloaded. */ private String url; /** * Default Constructor */ public FileAttachment() { } }
3,803
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/WebhookList.java
package com.paypal.api.payments; import com.paypal.base.rest.*; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class WebhookList extends PayPalResource { /** * A list of webhooks. */ private List<Webhook> webhooks; /** * Default Constructor */ public WebhookList() { } /** * Retrieves all Webhooks for the application associated with access token. * @deprecated Please use {@link #getAll(APIContext)} instead. * * @param accessToken * Access Token used for the API call. * @return WebhookList * @throws PayPalRESTException */ public WebhookList getAll(String accessToken) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return getAll(apiContext); } /** * Retrieves all Webhooks for the application associated with access token. * @param apiContext * {@link APIContext} used for the API call. * @return WebhookList * @throws PayPalRESTException */ public WebhookList getAll(APIContext apiContext) throws PayPalRESTException { Object[] parameters = new Object[] {}; String pattern = "v1/notifications/webhooks/"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = ""; return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, WebhookList.class); } }
3,804
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Event.java
package com.paypal.api.payments; import com.paypal.base.Constants; import com.paypal.base.SDKUtil; import com.paypal.base.SSLUtil; import com.paypal.base.rest.*; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import lombok.Getter; import lombok.Setter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.SignatureException; import java.security.cert.X509Certificate; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Event extends PayPalResource { private static final Logger log = LoggerFactory.getLogger(Event.class); /** * Identifier of the Webhooks event resource. */ private String id; /** * Time the resource was created. */ private String createTime; /** * Name of the resource contained in resource element. */ private String resourceType; /** * Name of the event type that occurred on resource, identified by data_resource element, to trigger the Webhooks event. */ private String eventType; /** * A summary description of the event. E.g. A successful payment authorization was created for $$ */ private String summary; /** * This contains the resource that is identified by resource_type element. */ private Object resource; /** * Hateoas links. */ private List<Links> links; /** * Default Constructor */ public Event() { } /** * Retrieves the Webhooks event resource identified by event_id. Can be used to retrieve the payload for an event. * @deprecated Please use {@link #get(APIContext, String)} instead. * @param accessToken * Access Token used for the API call. * @param eventId * String * @return Event * @throws PayPalRESTException */ @Deprecated public static Event get(String accessToken, String eventId) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return get(apiContext, eventId); } /** * Retrieves the Webhooks event resource identified by event_id. Can be used to retrieve the payload for an event. * @param apiContext * {@link APIContext} used for the API call. * @param eventId * String * @return Event * @throws PayPalRESTException */ public static Event get(APIContext apiContext, String eventId) throws PayPalRESTException { if (eventId == null) { throw new IllegalArgumentException("eventId cannot be null"); } Object[] parameters = new Object[] {eventId}; String pattern = "v1/notifications/webhooks-events/{0}"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = ""; return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, Event.class); } /** * Resends the Webhooks event resource identified by event_id. * @deprecated Please use {@link #resend(APIContext)} instead. * @param accessToken * Access Token used for the API call. * @return Event * @throws PayPalRESTException */ @Deprecated public Event resend(String accessToken) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return resend(apiContext); } /** * Resends the Webhooks event resource identified by event_id. * @param apiContext * {@link APIContext} used for the API call. * @return Event * @throws PayPalRESTException */ public Event resend(APIContext apiContext) throws PayPalRESTException { if (this.getId() == null) { throw new IllegalArgumentException("Id cannot be null"); } Object[] parameters = new Object[] {this.getId()}; String pattern = "v1/notifications/webhooks-events/{0}/resend"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = ""; return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Event.class); } /** * Retrieves the list of Webhooks events resources for the application associated with token. The developers can use it to see list of past webhooks events. * @deprecated Please use {@link #list(APIContext, String)} instead. * @param accessToken * Access Token used for the API call. * @return EventList * @throws PayPalRESTException */ @Deprecated public static EventList list(String accessToken, String queryParams) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return list(apiContext, queryParams); } /** * Retrieves the list of Webhooks events resources for the application associated with token. The developers can use it to see list of past webhooks events. * @param apiContext * {@link APIContext} used for the API call. * @return EventList * @throws PayPalRESTException */ public static EventList list(APIContext apiContext, String queryParams) throws PayPalRESTException { String resourcePath = "v1/notifications/webhooks-events" + queryParams; String payLoad = ""; return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, EventList.class); } /** * Validates received event received from PayPal to webhook endpoint set for particular webhook Id with PayPal trust source, to verify Data and Certificate integrity. * It validates both certificate chain, as well as data integrity. * * @param apiContext APIContext object * @param headers Map of Headers received in the event, from request * @param requestBody Request body received in the provided webhook * @return true if valid, false otherwise * @throws PayPalRESTException * @throws InvalidKeyException * @throws NoSuchAlgorithmException * @throws SignatureException */ public static boolean validateReceivedEvent(APIContext apiContext, Map<String, String> headers, String requestBody) throws PayPalRESTException, InvalidKeyException, NoSuchAlgorithmException, SignatureException { if (headers == null) { throw new PayPalRESTException("Headers cannot be null"); } Map<String, String> cmap; Boolean isChainValid = false, isDataValid = false; Collection<X509Certificate> trustCerts, clientCerts; // Load the configurations from all possible sources cmap = getConfigurations(apiContext); // Fetch Certificate Locations String clientCertificateLocation = SDKUtil.validateAndGet(headers, Constants.PAYPAL_HEADER_CERT_URL); // Default to `DigiCertSHA2ExtendedValidationServerCA` if none provided if (cmap != null && !cmap.containsKey(Constants.PAYPAL_TRUST_CERT_URL)) { cmap.put(Constants.PAYPAL_TRUST_CERT_URL, Constants.PAYPAL_TRUST_DEFAULT_CERT); } String trustCertificateLocation = SDKUtil.validateAndGet(cmap, Constants.PAYPAL_TRUST_CERT_URL); // Load certificates clientCerts = SSLUtil.getCertificateFromStream(SSLUtil.downloadCertificateFromPath(clientCertificateLocation, cmap)); trustCerts = SSLUtil.getCertificateFromStream(Event.class.getClassLoader().getResourceAsStream(trustCertificateLocation)); // Check if Chain Valid isChainValid = SSLUtil.validateCertificateChain(clientCerts, trustCerts, SDKUtil.validateAndGet(cmap, Constants.PAYPAL_WEBHOOK_CERTIFICATE_AUTHTYPE)); log.debug("Is Chain Valid: " + isChainValid); if (isChainValid) { // If Chain Valid, check for data signature valid // Lets check for data now String webhookId = SDKUtil.validateAndGet(cmap, Constants.PAYPAL_WEBHOOK_ID); String actualSignatureEncoded = SDKUtil.validateAndGet(headers, Constants.PAYPAL_HEADER_TRANSMISSION_SIG); String authAlgo = SDKUtil.validateAndGet(headers, Constants.PAYPAL_HEADER_AUTH_ALGO); String transmissionId = SDKUtil.validateAndGet(headers, Constants.PAYPAL_HEADER_TRANSMISSION_ID); String transmissionTime = SDKUtil.validateAndGet(headers, Constants.PAYPAL_HEADER_TRANSMISSION_TIME); String expectedSignature = String.format("%s|%s|%s|%s", transmissionId, transmissionTime, webhookId, SSLUtil.crc32(requestBody)); // Validate Data isDataValid = SSLUtil.validateData(clientCerts, authAlgo, actualSignatureEncoded, expectedSignature, requestBody, webhookId); log.debug("Is Data Valid: " + isDataValid); // Return true if both data and chain valid return isDataValid; } return false; } /** * Returns configurations by merging apiContext configurations in Map format * * @param apiContext * @return Map of configurations to be used for particular request */ private static Map<String, String> getConfigurations(APIContext apiContext) { Map<String, String> cmap; if (apiContext != null) { if (apiContext.getConfigurationMap() == null) { apiContext.setConfigurationMap(new HashMap<String, String>()); } cmap = SDKUtil.combineDefaultMap(apiContext.getConfigurationMap()); cmap = SDKUtil.combineMap(cmap, PayPalResource.getConfigurations()); } else { cmap = SDKUtil.combineDefaultMap(PayPalResource.getConfigurations()); } return cmap; } }
3,805
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/ProcessorResponse.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class ProcessorResponse extends PayPalModel { /** * Paypal normalized response code, generated from the processor's specific response code */ private String responseCode; /** * Address Verification System response code. https://developer.paypal.com/webapps/developer/docs/classic/api/AVSResponseCodes/ */ private String avsCode; /** * CVV System response code. https://developer.paypal.com/webapps/developer/docs/classic/api/AVSResponseCodes/ */ private String cvvCode; /** * Provides merchant advice on how to handle declines related to recurring payments */ private String adviceCode; /** * Response back from the authorization. Provided by the processor */ private String eciSubmitted; /** * Visa Payer Authentication Service status. Will be return from processor */ private String vpas; /** * Default Constructor */ public ProcessorResponse() { } /** * Parameterized Constructor */ public ProcessorResponse(String responseCode) { this.responseCode = responseCode; } }
3,806
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Authorization.java
package com.paypal.api.payments; import com.paypal.base.rest.*; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Authorization extends PayPalResource { /** * ID of the authorization transaction. */ private String id; /** * Amount being authorized. */ private Amount amount; /** * Specifies the payment mode of the transaction. */ private String paymentMode; /** * State of the authorization. */ private String state; /** * Reason code, `AUTHORIZATION`, for a transaction state of `pending`. */ private String reasonCode; /** * [DEPRECATED] Reason code for the transaction state being Pending.Obsolete. use reason_code field instead. */ private String pendingReason; /** * The level of seller protection in force for the transaction. Only supported when the `payment_method` is set to `paypal`. Allowed values:<br> `ELIGIBLE`- Merchant is protected by PayPal's Seller Protection Policy for Unauthorized Payments and Item Not Received.<br> `PARTIALLY_ELIGIBLE`- Merchant is protected by PayPal's Seller Protection Policy for Item Not Received or Unauthorized Payments. Refer to `protection_eligibility_type` for specifics. <br> `INELIGIBLE`- Merchant is not protected under the Seller Protection Policy. */ private String protectionEligibility; /** * The kind of seller protection in force for the transaction. This property is returned only when the `protection_eligibility` property is set to `ELIGIBLE`or `PARTIALLY_ELIGIBLE`. Only supported when the `payment_method` is set to `paypal`. Allowed values:<br> `ITEM_NOT_RECEIVED_ELIGIBLE`- Sellers are protected against claims for items not received.<br> `UNAUTHORIZED_PAYMENT_ELIGIBLE`- Sellers are protected against claims for unauthorized payments.<br> One or both of the allowed values can be returned. */ private String protectionEligibilityType; /** * Fraud Management Filter (FMF) details applied for the payment that could result in accept, deny, or pending action. Returned in a payment response only if the merchant has enabled FMF in the profile settings and one of the fraud filters was triggered based on those settings. See [Fraud Management Filters Summary](https://developer.paypal.com/docs/classic/fmf/integration-guide/FMFSummary/) for more information. */ private FmfDetails fmfDetails; /** * ID of the Payment resource that this transaction is based on. */ private String parentPayment; /** * Authorization expiration time and date as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String validUntil; /** * Time of authorization as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String createTime; /** * Time that the resource was last updated. */ private String updateTime; /** * Identifier to the purchase or transaction unit corresponding to this authorization transaction. */ private String referenceId; /** * Receipt id is 16 digit number payment identification number returned for guest users to identify the payment. */ private String receiptId; /** * */ private List<Links> links; /** * Default Constructor */ public Authorization() { } /** * Parameterized Constructor */ public Authorization(Amount amount) { this.amount = amount; } /** * Shows details for an authorization, by ID. * @deprecated Please use {@link #get(APIContext, String)} instead. * @param accessToken * Access Token used for the API call. * @param authorizationId * String * @return Authorization * @throws PayPalRESTException */ public static Authorization get(String accessToken, String authorizationId) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return get(apiContext, authorizationId); } /** * Shows details for an authorization, by ID. * @param apiContext * {@link APIContext} used for the API call. * @param authorizationId * String * @return Authorization * @throws PayPalRESTException */ public static Authorization get(APIContext apiContext, String authorizationId) throws PayPalRESTException { if (authorizationId == null) { throw new IllegalArgumentException("authorizationId cannot be null"); } Object[] parameters = new Object[] {authorizationId}; String pattern = "v1/payments/authorization/{0}"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = ""; return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, Authorization.class); } /** * Captures and processes an authorization, by ID. To use this call, the original payment call must specify an intent of `authorize`. * @deprecated Please use {@link #capture(APIContext, Capture)} instead. * @param accessToken * Access Token used for the API call. * @param capture * Capture * @return Capture * @throws PayPalRESTException */ public Capture capture(String accessToken, Capture capture) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return capture(apiContext, capture); } /** * Captures and processes an authorization, by ID. To use this call, the original payment call must specify an intent of `authorize`. * @param apiContext * {@link APIContext} used for the API call. * @param capture * Capture * @return Capture * @throws PayPalRESTException */ public Capture capture(APIContext apiContext, Capture capture) throws PayPalRESTException { if (this.getId() == null) { throw new IllegalArgumentException("Id cannot be null"); } if (capture == null) { throw new IllegalArgumentException("capture cannot be null"); } Object[] parameters = new Object[] {this.getId()}; String pattern = "v1/payments/authorization/{0}/capture"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = capture.toJSON(); return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Capture.class); } /** * Voids, or cancels, an authorization, by ID. You cannot void a fully captured authorization. * @deprecated Please use {@link #doVoid(APIContext)} instead. * @param accessToken * Access Token used for the API call. * @return Authorization * @throws PayPalRESTException */ public Authorization doVoid(String accessToken) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return doVoid(apiContext); } /** * Voids, or cancels, an authorization, by ID. You cannot void a fully captured authorization. * @param apiContext * {@link APIContext} used for the API call. * @return Authorization * @throws PayPalRESTException */ public Authorization doVoid(APIContext apiContext) throws PayPalRESTException { if (this.getId() == null) { throw new IllegalArgumentException("Id cannot be null"); } Object[] parameters = new Object[] {this.getId()}; String pattern = "v1/payments/authorization/{0}/void"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = ""; return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Authorization.class); } /** * Reauthorizes a PayPal account payment, by authorization ID. To ensure that funds are still available, reauthorize a payment after the initial three-day honor period. Supports only the `amount` request parameter. * @deprecated Please use {@link #reauthorize(APIContext)} instead. * @param accessToken * Access Token used for the API call. * @return Authorization * @throws PayPalRESTException */ public Authorization reauthorize(String accessToken) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return reauthorize(apiContext); } /** * Reauthorizes a PayPal account payment, by authorization ID. To ensure that funds are still available, reauthorize a payment after the initial three-day honor period. Supports only the `amount` request parameter. * @param apiContext * {@link APIContext} used for the API call. * @return Authorization * @throws PayPalRESTException */ public Authorization reauthorize(APIContext apiContext) throws PayPalRESTException { if (this.getId() == null) { throw new IllegalArgumentException("Id cannot be null"); } Object[] parameters = new Object[] {this.getId()}; String pattern = "v1/payments/authorization/{0}/reauthorize"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = this.toJSON(); return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Authorization.class); } }
3,807
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/FlowConfig.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class FlowConfig extends PayPalModel { /** * The type of landing page to display on the PayPal site for user checkout. Set to `Billing` to use the non-PayPal account landing page. Set to `Login` to use the PayPal account login landing page. */ private String landingPageType; /** * The merchant site URL to display after a bank transfer payment. Valid for only the Giropay or bank transfer payment method in Germany. */ private String bankTxnPendingUrl; /** * Defines whether buyers can complete purchases on the PayPal or merchant website. */ private String userAction; /** * Defines the HTTP method to use to redirect the user to a return URL. A valid value is `GET` or `POST`. */ private String returnUriHttpMethod; /** * Default Constructor */ public FlowConfig() { } }
3,808
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PaymentHistory.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class PaymentHistory extends PayPalModel { /** * A list of Payment resources */ private List<Payment> payments; /** * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items. Maximum value: 20. */ private int count; /** * Identifier of the next element to get the next range of results. */ private String nextId; /** * Default Constructor */ public PaymentHistory() { } }
3,809
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PaymentDetail.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class PaymentDetail extends PayPalModel { /** * The PayPal payment detail. Indicates whether payment was made in an invoicing flow through PayPal or externally. In the case of the mark-as-paid API, the supported payment type is `EXTERNAL`. For backward compatibility, the `PAYPAL` payment type is still supported. */ private String type; /** * The PayPal payment transaction ID. Required with the `PAYPAL` payment type. */ private String transactionId; /** * Type of the transaction. */ private String transactionType; /** * The date when the invoice was paid. The date format is *yyyy*-*MM*-*dd* *z* as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String date; /** * The payment mode or method. Required with the `EXTERNAL` payment type. */ private String method; /** * Optional. A note associated with the payment. */ private String note; /** * The amount to record as payment against invoice. If you omit this parameter, the total invoice amount is recorded as payment. */ private Currency amount; /** * Default Constructor */ public PaymentDetail() { } /** * Parameterized Constructor */ public PaymentDetail(String method) { this.method = method; } }
3,810
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Capture.java
package com.paypal.api.payments; import com.paypal.base.rest.*; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Capture extends PayPalResource { /** * The ID of the capture transaction. */ private String id; /** * The amount to capture. If the amount matches the orginally authorized amount, the state of the authorization changes to `captured`. If not, the state of the authorization changes to `partially_captured`. */ private Amount amount; /** * Indicates whether to release all remaining funds that the authorization holds in the funding instrument. Default is `false`. */ private Boolean isFinalCapture; /** * The state of the capture. */ private String state; /** * The reason code that describes why the transaction state is pending or reversed. */ private String reasonCode; /** * The ID of the payment on which this transaction is based. */ private String parentPayment; /** * The invoice number to track this payment. */ private String invoiceNumber; /** * The transaction fee for this payment. */ private Currency transactionFee; /** * The date and time of capture, as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String createTime; /** * The date and time when the resource was last updated. */ private String updateTime; /** * */ private List<Links> links; /** * Default Constructor */ public Capture() { } /** * Shows details for a captured payment, by ID. * @deprecated Please use {@link #get(APIContext, String)} instead. * @param accessToken * Access Token used for the API call. * @param captureId * String * @return Capture * @throws PayPalRESTException */ public static Capture get(String accessToken, String captureId) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return get(apiContext, captureId); } /** * Shows details for a captured payment, by ID. * @param apiContext * {@link APIContext} used for the API call. * @param captureId * String * @return Capture * @throws PayPalRESTException */ public static Capture get(APIContext apiContext, String captureId) throws PayPalRESTException { 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(pattern, parameters); String payLoad = ""; return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, Capture.class); } /** * Creates (and processes) a new Refund Transaction added as a related resource. * @deprecated Please use {@link #refund(APIContext, Refund)} instead. * @param accessToken * Access Token used for the API call. * @param refund * Refund * @return Refund * @throws PayPalRESTException */ public Refund refund(String accessToken, Refund refund) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return refund(apiContext, refund); } /** * @deprecated Please use {@link #refund(APIContext, RefundRequest)} instead * Refunds a captured payment, by ID. Include an `amount` object in the JSON request body. * @param apiContext * {@link APIContext} used for the API call. * @param refund * Refund * @return Refund * @throws PayPalRESTException */ public Refund refund(APIContext apiContext, Refund refund) throws PayPalRESTException { if (this.getId() == null) { throw new IllegalArgumentException("Id cannot be null"); } if (refund == null) { throw new IllegalArgumentException("refund cannot be null"); } apiContext.setRequestId(null); Object[] parameters = new Object[] {this.getId()}; String pattern = "v1/payments/capture/{0}/refund"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = refund.toJSON(); Refund refundResponse = configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Refund.class); apiContext.setRequestId(null); return refundResponse; } /** * Refunds a captured payment, by ID. Include an `amount` object in the JSON request body. * @param apiContext * {@link APIContext} used for the API call. * @param refundRequest * RefundRequest * @return DetailedRefund * @throws PayPalRESTException */ public DetailedRefund refund(APIContext apiContext, RefundRequest refundRequest) throws PayPalRESTException { if (this.getId() == null) { throw new IllegalArgumentException("Id cannot be null"); } if (refundRequest == null) { throw new IllegalArgumentException("refundRequest cannot be null"); } Object[] parameters = new Object[] {this.getId()}; String pattern = "v1/payments/capture/{0}/refund"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = refundRequest.toJSON(); return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, DetailedRefund.class); } }
3,811
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/RelatedResources.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class RelatedResources extends PayPalModel { /** * Sale transaction */ private Sale sale; /** * Authorization transaction */ private Authorization authorization; /** * Order transaction */ private Order order; /** * Capture transaction */ private Capture capture; /** * Refund transaction */ private Refund refund; /** * Default Constructor */ public RelatedResources() { } }
3,812
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/AgreementTransaction.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import lombok.Getter; import lombok.Setter; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class AgreementTransaction extends PayPalModel { /** * Id corresponding to this transaction. */ private String transactionId; /** * State of the subscription at this time. */ private String status; /** * Type of transaction, usually Recurring Payment. */ private String transactionType; /** * Amount for this transaction. */ private Currency amount; /** * Fee amount for this transaction. */ private Currency feeAmount; /** * Net amount for this transaction. */ private Currency netAmount; /** * Email id of payer. */ private String payerEmail; /** * Business name of payer. */ private String payerName; /** * Time zone of time_updated field. */ private String timeZone; /** * Time at which this transaction happened. */ private String timeStamp; /** * Default Constructor */ public AgreementTransaction() { } /** * Parameterized Constructor */ public AgreementTransaction(Currency amount, Currency feeAmount, Currency netAmount) { this.amount = amount; this.feeAmount = feeAmount; this.netAmount = netAmount; } /** * @deprecated use setTimeStamp instead. * Setter for timeUpdated */ public AgreementTransaction setTimeUpdated(String timeUpdated) { this.timeStamp = timeUpdated; return this; } /** * @deprecated use getTimeStamp instead. * Getter for timeUpdated */ public String getTimeUpdated() { return this.timeStamp; } }
3,813
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/InvoicingSearch.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import lombok.Getter; import lombok.Setter; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class InvoicingSearch extends PayPalModel { /** * Initial letters of the email address. */ private String email; /** * Initial letters of the recipient's first name. */ private String recipientFirstName; /** * Initial letters of the recipient's last name. */ private String recipientLastName; /** * Initial letters of the recipient's business name. */ private String recipientBusinessName; /** * The invoice number that appears on the invoice. */ private String number; /** * Status of the invoice. */ private String status; /** * Lower limit of total amount. */ private Currency lowerTotalAmount; /** * Upper limit of total amount. */ private Currency upperTotalAmount; /** * Start invoice date. */ private String startInvoiceDate; /** * End invoice date. */ private String endInvoiceDate; /** * Start invoice due date. */ private String startDueDate; /** * End invoice due date. */ private String endDueDate; /** * Start invoice payment date. */ private String startPaymentDate; /** * End invoice payment date. */ private String endPaymentDate; /** * Start invoice creation date. */ private String startCreationDate; /** * End invoice creation date. */ private String endCreationDate; /** * Offset of the search results. */ private float page; /** * Page size of the search results. */ private float pageSize; /** * A flag indicating whether total count is required in the response. */ private Boolean totalCountRequired; /** * Default Constructor */ public InvoicingSearch() { } }
3,814
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/InstallmentInfo.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class InstallmentInfo extends PayPalModel { /** * Installment id. */ private String installmentId; /** * Credit card network. */ private String network; /** * Credit card issuer. */ private String issuer; /** * List of available installment options and the cost associated with each one. */ private List<InstallmentOption> installmentOptions; /** * Default Constructor */ public InstallmentInfo() { } /** * Parameterized Constructor */ public InstallmentInfo(List<InstallmentOption> installmentOptions) { this.installmentOptions = installmentOptions; } }
3,815
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/RedirectUrls.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class RedirectUrls extends PayPalModel { /** * Url where the payer would be redirected to after approving the payment. **Required for PayPal account payments.** */ private String returnUrl; /** * Url where the payer would be redirected to after canceling the payment. **Required for PayPal account payments.** */ private String cancelUrl; /** * Default Constructor */ public RedirectUrls() { } }
3,816
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Metadata.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Metadata extends PayPalModel { /** * The date and time when the resource was created. */ private String createdDate; /** * The email address of the account that created the resource. */ private String createdBy; /** * The date and time when the resource was cancelled. */ private String cancelledDate; /** * The actor who cancelled the resource. */ private String cancelledBy; /** * The date and time when the resource was last edited. */ private String lastUpdatedDate; /** * The email address of the account that last edited the resource. */ private String lastUpdatedBy; /** * The date and time when the resource was first sent. */ private String firstSentDate; /** * The date and time when the resource was last sent. */ private String lastSentDate; /** * The email address of the account that last sent the resource. */ private String lastSentBy; /** * URL representing the payer's view of the invoice. */ private String payerViewUrl; /** * Default Constructor */ public Metadata() { } }
3,817
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PayoutItemDetails.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class PayoutItemDetails extends PayPalModel { /** * The ID for the payout item. Viewable when you show details for a batch payout. */ private String payoutItemId; /** * The PayPal-generated ID for the transaction. */ private String transactionId; /** * The transaction status. */ private String transactionStatus; /** * The amount of money, in U.S. dollars, for fees. */ private Currency payoutItemFee; /** * The PayPal-generated ID for the batch payout. */ private String payoutBatchId; /** * A sender-specified ID number. Tracks the batch payout in an accounting system. */ private String senderBatchId; /** * The sender-provided information for the payout item. */ private PayoutItem payoutItem; /** * The date and time when this item was last processed. */ private String timeProcessed; /** * */ private Error errors; /** * The HATEOAS links related to the call. */ private List<Links> links; /** * Default Constructor */ public PayoutItemDetails() { } /** * Parameterized Constructor */ public PayoutItemDetails(String payoutItemId, String payoutBatchId, PayoutItem payoutItem, String timeProcessed) { this.payoutItemId = payoutItemId; this.payoutBatchId = payoutBatchId; this.payoutItem = payoutItem; this.timeProcessed = timeProcessed; } /** * Setter for error. Please use this over {@link #setErrors(Error)}. * errors field in {@link PayoutItemDetails} takes one {@link Error} object. * Not using lombok autogeneration as `setErrors` is not a feasible option. */ public PayoutItemDetails setError(Error error) { this.errors = error; return this; } /** * Getter for error. Please use this over {@link #getErrors()}. * errors field in {@link PayoutItemDetails} takes one {@link Error} object. */ public Error getError() { return this.errors; } }
3,818
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/ExternalFunding.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class ExternalFunding extends PayPalModel { /** * Unique identifier for the external funding */ private String referenceId; /** * Generic identifier for the external funding */ private String code; /** * Encrypted PayPal Account identifier for the funding account */ private String fundingAccountId; /** * Description of the external funding being applied */ private String displayText; /** * Amount being funded by the external funding account */ private Amount amount; /** * Indicates that the Payment should be fully funded by External Funded Incentive */ private String fundingInstruction; /** * Default Constructor */ public ExternalFunding() { } /** * Parameterized Constructor */ public ExternalFunding(String referenceId, String fundingAccountId, Amount amount) { this.referenceId = referenceId; this.fundingAccountId = fundingAccountId; this.amount = amount; } }
3,819
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Measurement.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Measurement extends PayPalModel { /** * Value this measurement represents. */ private String value; /** * Unit in which the value is represented. */ private String unit; }
3,820
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/EventList.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import lombok.Getter; import lombok.Setter; import java.util.ArrayList; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class EventList extends PayPalModel { /** * A list of Webhooks event resources */ private List<Event> events; /** * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items. */ private int count; /** * */ private List<Links> links; /** * Default Constructor */ public EventList() { events = new ArrayList<Event>(); } }
3,821
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/CartBase.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class CartBase extends PayPalModel { /** * Merchant identifier to the purchase unit. Optional parameter */ private String referenceId; /** * Amount being collected. */ private Amount amount; /** * Recipient of the funds in this transaction. */ private Payee payee; /** * Description of what is being paid for. */ private String description; /** * Note to the recipient of the funds in this transaction. */ private String noteToPayee; /** * free-form field for the use of clients */ private String custom; /** * invoice number to track this payment */ private String invoiceNumber; /** * Soft descriptor used when charging this funding source. If length exceeds max length, the value will be truncated */ private String softDescriptor; /** * Soft descriptor city used when charging this funding source. If length exceeds max length, the value will be truncated. Only supported when the `payment_method` is set to `credit_card` */ private String softDescriptorCity; /** * Payment options requested for this purchase unit */ private PaymentOptions paymentOptions; /** * List of items being paid for. */ private ItemList itemList; /** * URL to send payment notifications */ private String notifyUrl; /** * Url on merchant site pertaining to this payment. */ private String orderUrl; /** * List of external funding being applied to the purchase unit. Each external_funding unit should have a unique reference_id */ private List<ExternalFunding> externalFunding; /** * Default Constructor */ public CartBase() { } /** * Parameterized Constructor */ public CartBase(Amount amount) { this.amount = amount; } }
3,822
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Currency.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Currency extends PayPalModel { /** * 3 letter currency code as defined by ISO 4217. */ private String currency; /** * amount up to N digit after the decimals separator as defined in ISO 4217 for the appropriate currency code. */ private String value; /** * Default Constructor */ public Currency() { } /** * Parameterized Constructor */ public Currency(String currency, String value) { this.currency = currency; this.value = value; } }
3,823
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/CustomAmount.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class CustomAmount extends PayPalModel { /** * The custom amount label. Maximum length is 25 characters. */ private String label; /** * The custom amount value. Valid range is from -999999.99 to 999999.99. */ private Currency amount; /** * Default Constructor */ public CustomAmount() { } }
3,824
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/ItemList.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class ItemList extends PayPalModel { /** * List of items. */ private List<Item> items; /** * Shipping address. */ private ShippingAddress shippingAddress; /** * Shipping method used for this payment like USPSParcel etc. */ private String shippingMethod; /** * Allows merchant's to share payer’s contact number with PayPal for the current payment. Final contact number of payer associated with the transaction might be same as shipping_phone_number or different based on Payer’s action on PayPal. The phone number must be represented in its canonical international format, as defined by the E.164 numbering plan */ private String shippingPhoneNumber; /** * Default Constructor */ public ItemList() { } }
3,825
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Cost.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Cost extends PayPalModel { /** * Cost in percent. Range of 0 to 100. */ private double percent; /** * The cost, as an amount. Valid range is from 0 to 1,000,000. */ private Currency amount; /** * Default Constructor */ public Cost() { } }
3,826
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Links.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Links extends PayPalModel { /** * */ private String href; /** * */ private String rel; /** * */ private HyperSchema targetSchema; /** * */ private String method; /** * */ private String enctype; /** * */ private HyperSchema schema; /** * Default Constructor */ public Links() { } /** * Parameterized Constructor */ public Links(String href, String rel) { this.href = href; this.rel = rel; } }
3,827
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/RecipientBankingInstruction.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class RecipientBankingInstruction extends PayPalModel { /** * Name of the financial institution. */ private String bankName; /** * Name of the account holder */ private String accountHolderName; /** * bank account number */ private String accountNumber; /** * bank routing number */ private String routingNumber; /** * IBAN equivalent of the bank */ private String internationalBankAccountNumber; /** * BIC identifier of the financial institution */ private String bankIdentifierCode; /** * Default Constructor */ public RecipientBankingInstruction() { } /** * Parameterized Constructor */ public RecipientBankingInstruction(String bankName, String accountHolderName, String internationalBankAccountNumber) { this.bankName = bankName; this.accountHolderName = accountHolderName; this.internationalBankAccountNumber = internationalBankAccountNumber; } }
3,828
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PayoutSenderBatchHeader.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class PayoutSenderBatchHeader extends PayPalModel { /** * A sender-specified ID number. Tracks the batch payout in an accounting system.<blockquote><strong>Note:</strong> PayPal prevents duplicate batches from being processed. If you specify a `sender_batch_id` that was used in the last 30 days, the API rejects the request and returns an error message that indicates the duplicate `sender_batch_id` and includes a HATEOAS link to the original batch payout with the same `sender_batch_id`. If you receive a HTTP `5nn` status code, you can safely retry the request with the same `sender_batch_id`. In any case, the API completes a payment only once for a specific `sender_batch_id` that is used within 30 days.</blockquote> */ private String senderBatchId; /** * The subject line text for the email that PayPal sends when a payout item completes. The subject line is the same for all recipients. Value is an alphanumeric string with a maximum length of 255 single-byte characters. */ private String emailSubject; /** * The type of ID that identifies the payment receiver. Value is:<ul><code>EMAIL</code>. Unencrypted email. Value is a string of up to 127 single-byte characters.</li><li><code>PHONE</code>. Unencrypted phone number.<blockquote><strong>Note:</strong> The PayPal sandbox does not support the <code>PHONE</code> recipient type.</blockquote></li><li><code>PAYPAL_ID</code>. Encrypted PayPal account number.</li></ul>If the <code>sender_batch_header</code> includes the <code>recipient_type</code> attribute, any payout item without its own <code>recipient_type</code> attribute uses the <code>recipient_type</code> value from <code>sender_batch_header</code>. If the <code>sender_batch_header</code> omits the <code>recipient_type</code> attribute, each payout item must include its own <code>recipient_type</code> value. */ private String recipientType; /** * Default Constructor */ public PayoutSenderBatchHeader() { } }
3,829
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Payee.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Payee extends PayPalModel { /** * Email Address associated with the Payee's PayPal Account. If the provided email address is not associated with any PayPal Account, the payee can only receive PayPal Wallet Payments. Direct Credit Card Payments will be denied due to card compliance requirements. */ private String email; /** * Encrypted PayPal account identifier for the Payee. */ private String merchantId; /** * First Name of the Payee. */ private String firstName; /** * Last Name of the Payee. */ private String lastName; /** * Unencrypted PayPal account Number of the Payee */ private String accountNumber; /** * Information related to the Payee. */ private Phone phone; /** * Default Constructor */ public Payee() { } }
3,830
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/DetailedRefund.java
package com.paypal.api.payments; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class DetailedRefund extends Refund { /** * free-form field for the use of clients */ private String custom; /** * Amount refunded to payer of the original transaction, in the current Refund call */ private Currency refundToPayer; /** * List of external funding that were refunded by the Refund call. Each external_funding unit should have a unique reference_id */ private List<ExternalFunding> refundToExternalFunding; /** * Transaction fee refunded to original recipient of payment. */ private Currency refundFromTransactionFee; /** * Amount subtracted from PayPal balance of the original recipient of payment, to make this refund. */ private Currency refundFromReceivedAmount; /** * Total amount refunded so far from the original purchase. Say, for example, a buyer makes $100 purchase, the buyer was refunded $20 a week ago and is refunded $30 in this transaction. The gross refund amount is $30 (in this transaction). The total refunded amount is $50. */ private Currency totalRefundedAmount; /** * Default Constructor */ public DetailedRefund() { } }
3,831
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/AgreementDetails.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import lombok.Getter; import lombok.Setter; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class AgreementDetails extends PayPalModel { /** * The outstanding balance for this agreement. */ private Currency outstandingBalance; /** * Number of cycles remaining for this agreement. */ private String cyclesRemaining; /** * Number of cycles completed for this agreement. */ private String cyclesCompleted; /** * The next billing date for this agreement, represented as 2014-02-19T10:00:00Z format. */ private String nextBillingDate; /** * Last payment date for this agreement, represented as 2014-06-09T09:42:31Z format. */ private String lastPaymentDate; /** * Last payment amount for this agreement. */ private Currency lastPaymentAmount; /** * Last payment date for this agreement, represented as 2015-02-19T10:00:00Z format. */ private String finalPaymentDate; /** * Total number of failed payments for this agreement. */ private String failedPaymentCount; /** * Default Constructor */ public AgreementDetails() { } }
3,832
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Percentage.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Percentage extends PayPalModel { /** * Default Constructor */ public Percentage() { } }
3,833
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/EventType.java
package com.paypal.api.payments; import com.paypal.base.rest.*; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import lombok.Getter; import lombok.Setter; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class EventType extends PayPalResource { /** * Unique event-type name. */ private String name; /** * Human readable description of the event-type */ private String description; /** * Default Constructor */ public EventType() { } /** * Parameterized Constructor */ public EventType(String name) { this.name = name; } /** * Retrieves the list of events-types subscribed by the given Webhook. * @deprecated Please use {@link #subscribedEventTypes(APIContext, String)} instead. * @param accessToken * Access Token used for the API call. * @param webhookId * String * @return EventTypeList * @throws PayPalRESTException */ public static EventTypeList subscribedEventTypes(String accessToken, String webhookId) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return subscribedEventTypes(apiContext, webhookId); } /** * Retrieves the list of events-types subscribed by the given Webhook. * @param apiContext * {@link APIContext} used for the API call. * @param webhookId * String * @return EventTypeList * @throws PayPalRESTException */ public static EventTypeList subscribedEventTypes(APIContext apiContext, String webhookId) throws PayPalRESTException { if (webhookId == null) { throw new IllegalArgumentException("webhookId cannot be null"); } Object[] parameters = new Object[] {webhookId}; String pattern = "v1/notifications/webhooks/{0}/event-types"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = ""; EventTypeList eventTypeList = configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, EventTypeList.class); if (eventTypeList == null) { eventTypeList = new EventTypeList(); } return eventTypeList; } /** * Retrieves the master list of available Webhooks events-types resources for any webhook to subscribe to. * @deprecated Please use {@link #availableEventTypes(APIContext)} instead. * @param accessToken * Access Token used for the API call. * @return EventTypeList * @throws PayPalRESTException */ public static EventTypeList availableEventTypes(String accessToken) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return availableEventTypes(apiContext); } /** * Retrieves the master list of available Webhooks events-types resources for any webhook to subscribe to. * @param apiContext * {@link APIContext} used for the API call. * @return EventTypeList * @throws PayPalRESTException */ public static EventTypeList availableEventTypes(APIContext apiContext) throws PayPalRESTException { String resourcePath = "v1/notifications/webhooks-event-types"; String payLoad = ""; EventTypeList eventTypeList = configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, EventTypeList.class); return eventTypeList; } }
3,834
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/TemplateData.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class TemplateData extends PayPalModel { /** * Information about the merchant who is sending the invoice. */ private MerchantInfo merchantInfo; /** * The required invoice recipient email address and any optional billing information. One recipient is supported. */ private List<BillingInfo> billingInfo; /** * For invoices sent by email, one or more email addresses to which to send a Cc: copy of the notification. Supports only email addresses under participant. */ private List<String> ccInfo; /** * The shipping information for entities to whom items are being shipped. */ private ShippingInfo shippingInfo; /** * The list of items to include in the invoice. Maximum value is 100 items per invoice. */ private List<InvoiceItem> items; /** * Optional. The payment deadline for the invoice. Value is either `term_type` or `due_date` but not both. */ private PaymentTerm paymentTerm; /** * Reference data, such as PO number, to add to the invoice. Maximum length is 60 characters. */ private String reference; /** * The invoice level discount, as a percent or an amount value. */ private Cost discount; /** * The shipping cost, as a percent or an amount value. */ private ShippingCost shippingCost; /** * The custom amount to apply on an invoice. If you include a label, the amount cannot be empty. */ private CustomAmount custom; /** * Indicates whether the invoice allows a partial payment. If set to `false`, invoice must be paid in full. If set to `true`, the invoice allows partial payments. Default is `false`. */ private Boolean allowPartialPayment; /** * If `allow_partial_payment` is set to `true`, the minimum amount allowed for a partial payment. */ private Currency minimumAmountDue; /** * Indicates whether tax is calculated before or after a discount. If set to `false`, the tax is calculated before a discount. If set to `true`, the tax is calculated after a discount. Default is `false`. */ private Boolean taxCalculatedAfterDiscount; /** * Indicates whether the unit price includes tax. Default is `false`. */ private Boolean taxInclusive; /** * General terms of the invoice. 4000 characters max. */ private String terms; /** * Note to the payer. 4000 characters max. */ private String note; /** * A private bookkeeping memo for the merchant. Maximum length is 150 characters. */ private String merchantMemo; /** * Full URL of an external image to use as the logo. Maximum length is 4000 characters. */ private String logoUrl; /** * The total amount of the invoice. */ private Currency totalAmount; /** * List of files attached to the invoice. */ private List<FileAttachment> attachments; /** * Default Constructor */ public TemplateData() { } /** * Parameterized Constructor */ public TemplateData(MerchantInfo merchantInfo) { this.merchantInfo = merchantInfo; } }
3,835
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Invoices.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import lombok.Getter; import lombok.Setter; import java.util.ArrayList; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Invoices extends PayPalModel { /** * */ private int totalCount; /** * List of invoices belonging to a merchant. */ private List<Invoice> invoices; /** * Default Constructor */ public Invoices() { invoices = new ArrayList<Invoice>(); } }
3,836
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Webhook.java
package com.paypal.api.payments; import com.paypal.base.rest.*; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Webhook extends PayPalResource { /** * The ID of the webhook. */ private String id; /** * The URL that is configured to listen on `localhost` for incoming `POST` notification messages that contain event information. */ private String url; /** * A list of up to ten events to which to subscribe your webhook. To subscribe to all events including new events as they are added, specify the asterisk (`*`) wildcard. To replace the `event_types` array, specify the `*` wildcard. To see all supported events, [list available events](#available-event-type.list). */ private List<EventType> eventTypes; /** * The HATEOAS links related to this call. */ private List<Links> links; /** * Default Constructor */ public Webhook() { } /** * Parameterized Constructor */ public Webhook(String url, List<EventType> eventTypes) { this.url = url; this.eventTypes = eventTypes; } /** * Subscribes your webhook listener to events. A successful call returns a [`webhook`](/docs/api/webhooks/#definition-webhook) object, which includes the webhook ID for later use. * * @param accessToken Access Token used for the API call. * @param webhook Webhook request * @return Webhook * @throws PayPalRESTException * @deprecated Please use {@link #create(APIContext, Webhook)} instead. */ @Deprecated public Webhook create(String accessToken, Webhook webhook) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return create(apiContext, webhook); } /** * Subscribes your webhook listener to events. A successful call returns a [`webhook`](/docs/api/webhooks/#definition-webhook) object, which includes the webhook ID for later use. * * @param apiContext {@link APIContext} used for the API call. * @param webhook Webhook request * @return Webhook * @throws PayPalRESTException */ public Webhook create(APIContext apiContext, Webhook webhook) throws PayPalRESTException { if (webhook == null) { throw new IllegalArgumentException("webhook cannot be null"); } Object[] parameters = new Object[]{}; String pattern = "v1/notifications/webhooks"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = webhook.toJSON(); return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Webhook.class); } /** * Shows details for a webhook, by ID. * * @param accessToken Access Token used for the API call. * @param webhookId Identifier of the webhook * @return Webhook * @throws PayPalRESTException * @deprecated Please use {@link #get(APIContext, String)} instead. */ @Deprecated public Webhook get(String accessToken, String webhookId) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return get(apiContext, webhookId); } /** * Shows details for a webhook, by ID. * * @param apiContext {@link APIContext} used for the API call. * @param webhookId Identifier of the webhook * @return Webhook * @throws PayPalRESTException */ public Webhook get(APIContext apiContext, String webhookId) throws PayPalRESTException { if (webhookId == null) { throw new IllegalArgumentException("webhookId cannot be null"); } Object[] parameters = new Object[]{webhookId}; String pattern = "v1/notifications/webhooks/{0}"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = ""; return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, Webhook.class); } /** * Replaces webhook fields with new values. Pass a `json_patch` object with `replace` operation and `path`, which is `/url` for a URL or `/event_types` for events. The `value` is either the URL or a list of events. * * @param accessToken Access Token used for the API call. * @param webhookId Identifier of the webhook * @param patchRequest patchRequest * @return Webhook * @throws PayPalRESTException * @deprecated Please use {@link #update(APIContext, String, String)} instead. */ @Deprecated public Webhook update(String accessToken, String webhookId, String patchRequest) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return update(apiContext, webhookId, patchRequest); } /** * Replaces webhook fields with new values. Pass a `json_patch` object with `replace` operation and `path`, which is `/url` for a URL or `/event_types` for events. The `value` is either the URL or a list of events. * * @param apiContext {@link APIContext} used for the API call. * @return Webhook * @throws PayPalRESTException */ public Webhook update(APIContext apiContext, String webhookId, String patchRequest) throws PayPalRESTException { if (webhookId == null) { throw new IllegalArgumentException("webhookId cannot be null"); } if (patchRequest == null) { throw new IllegalArgumentException("patchRequest cannot be null"); } Object[] parameters = new Object[]{webhookId}; String pattern = "v1/notifications/webhooks/{0}"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = patchRequest; return configureAndExecute(apiContext, HttpMethod.PATCH, resourcePath, payLoad, Webhook.class); } /** * Deletes a webhook, by ID. * * @param accessToken Access Token used for the API call. * @param webhookId Identifier of the webhook * @throws PayPalRESTException * @deprecated Please use {@link #delete(APIContext, String)} instead. */ @Deprecated public void delete(String accessToken, String webhookId) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); delete(apiContext, webhookId); } /** * Deletes a webhook, by ID. * * @param apiContext {@link APIContext} used for the API call. * @param webhookId Identifier of the webhook * @throws PayPalRESTException */ public void delete(APIContext apiContext, String webhookId) throws PayPalRESTException { if (webhookId == null) { throw new IllegalArgumentException("webhookId cannot be null"); } Object[] parameters = new Object[]{webhookId}; String pattern = "v1/notifications/webhooks/{0}"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = ""; configureAndExecute(apiContext, HttpMethod.DELETE, resourcePath, payLoad, null); } }
3,837
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PaymentOptions.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class PaymentOptions extends PayPalModel { /** * Payment method requested for this purchase unit */ private String allowedPaymentMethod; /** * Indicator if this payment request is a recurring payment. Only supported when the `payment_method` is set to `credit_card` */ private Boolean recurringFlag; /** * Indicator if fraud management filters (fmf) should be skipped for this transaction. Only supported when the `payment_method` is set to `credit_card` */ private Boolean skipFmf; /** * Default Constructor */ public PaymentOptions() { } }
3,838
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/FundingInstrument.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class FundingInstrument extends PayPalModel { /** * Credit Card instrument. */ private CreditCard creditCard; /** * PayPal vaulted credit Card instrument. */ private CreditCardToken creditCardToken; /** * Payment Card information. */ private PaymentCard paymentCard; /** * Bank Account information. */ private ExtendedBankAccount bankAccount; /** * Vaulted bank account instrument. */ private BankToken bankAccountToken; /** * PayPal credit funding instrument. */ private Credit credit; /** * Incentive funding instrument. */ private Incentive incentive; /** * External funding instrument. */ private ExternalFunding externalFunding; /** * Carrier account token instrument. */ private CarrierAccountToken carrierAccountToken; /** * Carrier account instrument */ private CarrierAccount carrierAccount; /** * Private Label Card funding instrument. These are store cards provided by merchants to drive business with value to customer with convenience and rewards. */ private PrivateLabelCard privateLabelCard; /** * Billing instrument that references pre-approval information for the payment */ private Billing billing; /** * Alternate Payment information - Mostly regional payment providers. For e.g iDEAL in Netherlands */ private AlternatePayment alternatePayment; /** * Default Constructor */ public FundingInstrument() { } }
3,839
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Search.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Search extends PayPalModel { /** * The initial letters of the email address. */ private String email; /** * The initial letters of the recipient's first name. */ private String recipientFirstName; /** * The initial letters of the recipient's last name. */ private String recipientLastName; /** * The initial letters of the recipient's business name. */ private String recipientBusinessName; /** * The invoice number. */ private String number; /** * The invoice status. */ private String status; /** * The lower limit of the total amount. */ private Currency lowerTotalAmount; /** * The upper limit of total amount. */ private Currency upperTotalAmount; /** * The start date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String startInvoiceDate; /** * The end date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String endInvoiceDate; /** * The start due date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String startDueDate; /** * The end due date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String endDueDate; /** * The start payment date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String startPaymentDate; /** * The end payment date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String endPaymentDate; /** * The start creation date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String startCreationDate; /** * The end creation date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String endCreationDate; /** * The offset for the search results. */ private float page; /** * The page size for the search results. */ private float pageSize; /** * Indicates whether the total count appears in the response. Default is `false`. */ private Boolean totalCountRequired; /** * A flag indicating whether search is on invoices archived by merchant. true - returns archived / false returns unarchived / null returns all. */ private Boolean archived; /** * Default Constructor */ public Search() { } }
3,840
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Template.java
package com.paypal.api.payments; import com.google.gson.annotations.SerializedName; import com.paypal.base.rest.*; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import lombok.Getter; import lombok.Setter; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Template extends PayPalResource { /** * Unique identifier id of the template. */ private String templateId; /** * Name of the template. */ private String name; /** * Indicates that this template is merchant's default. There can be only one template which can be a default. */ @SerializedName("default") private Boolean isDefault; /** * Customized invoice data which is saved as template */ private TemplateData templateData; /** * Settings for each template */ private List<TemplateSettings> settings; /** * Unit of measure for the template, possible values are Quantity, Hours, Amount. */ private String unitOfMeasure; /** * Indicates whether this is a custom template created by the merchant. Non custom templates are system generated */ private Boolean custom; /** * Default Constructor */ public Template() { } /** * Retrieve the details for a particular template by passing the template ID to the request URI. * @param apiContext * {@link APIContext} used for the API call. * @param templateId * String * @return Template * @throws PayPalRESTException */ public static Template get(APIContext apiContext, String templateId) throws PayPalRESTException { if (templateId == null) { throw new IllegalArgumentException("templateId cannot be null"); } Object[] parameters = new Object[] {templateId}; String pattern = "v1/invoicing/templates/{0}"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = ""; return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, Template.class); } /** * Retrieves the template information of the merchant. * @param apiContext * {@link APIContext} used for the API call. * @return Templates * @throws PayPalRESTException */ public static Templates getAll(APIContext apiContext) throws PayPalRESTException { String resourcePath = "v1/invoicing/templates"; String payLoad = ""; return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, Templates.class); } /** * Delete a particular template by passing the template ID to the request URI. * @param apiContext * {@link APIContext} used for the API call. * @return * @throws PayPalRESTException */ public void delete(APIContext apiContext) throws PayPalRESTException { if (this.getTemplateId() == null) { throw new IllegalArgumentException("Id cannot be null"); } apiContext.setMaskRequestId(true); Object[] parameters = new Object[] {this.getTemplateId()}; String pattern = "v1/invoicing/templates/{0}"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = ""; configureAndExecute(apiContext, HttpMethod.DELETE, resourcePath, payLoad, null); } /** * Creates a template. * @param apiContext * {@link APIContext} used for the API call. * @return Template * @throws PayPalRESTException */ public Template create(APIContext apiContext) throws PayPalRESTException { String resourcePath = "v1/invoicing/templates"; String payLoad = this.toJSON(); return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Template.class); } /** * Update an existing template by passing the template ID to the request URI. In addition, pass a complete template object in the request JSON. Partial updates are not supported. * @param apiContext * {@link APIContext} used for the API call. * Template * @return Template * @throws PayPalRESTException */ public Template update(APIContext apiContext) throws PayPalRESTException { if (this.getTemplateId() == null) { throw new IllegalArgumentException("Id cannot be null"); } Object[] parameters = new Object[] {this.getTemplateId()}; String pattern = "v1/invoicing/templates/{0}"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = this.toJSON(); return configureAndExecute(apiContext, HttpMethod.PUT, resourcePath, payLoad, Template.class); } }
3,841
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/CountryCode.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class CountryCode extends PayPalModel { /** * ISO country code based on 2-character IS0-3166-1 codes. */ private String countryCode; /** * Default Constructor */ public CountryCode() { } /** * Parameterized Constructor */ public CountryCode(String countryCode) { this.countryCode = countryCode; } }
3,842
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Sale.java
package com.paypal.api.payments; import com.paypal.base.rest.*; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Sale extends PayPalResource { /** * Identifier of the sale transaction. */ private String id; /** * Identifier to the purchase or transaction unit corresponding to this sale transaction. */ private String purchaseUnitReferenceId; /** * Amount being collected. */ private Amount amount; /** * Specifies payment mode of the transaction. Only supported when the `payment_method` is set to `paypal`. */ private String paymentMode; /** * State of the sale transaction. */ private String state; /** * Reason code for the transaction state being Pending or Reversed. Only supported when the `payment_method` is set to `paypal`. */ private String reasonCode; /** * The level of seller protection in force for the transaction. Only supported when the `payment_method` is set to `paypal`. */ private String protectionEligibility; /** * The kind of seller protection in force for the transaction. It is returned only when protection_eligibility is ELIGIBLE or PARTIALLY_ELIGIBLE. Only supported when the `payment_method` is set to `paypal`. */ private String protectionEligibilityType; /** * Expected clearing time for eCheck Transactions. Returned when payment is made with eCheck. Only supported when the `payment_method` is set to `paypal`. */ private String clearingTime; /** * Status of the Recipient Fund. For now, it will be returned only when fund status is held */ private String paymentHoldStatus; /** * Reasons for PayPal holding recipient fund. It is set only if payment hold status is held */ private List<String> paymentHoldReasons; /** * Transaction fee applicable for this payment. */ private Currency transactionFee; /** * Net amount the merchant receives for this transaction in their receivable currency. Returned only in cross-currency use cases where a merchant bills a buyer in a non-primary currency for that buyer. */ private Currency receivableAmount; /** * Exchange rate applied for this transaction. Returned only in cross-currency use cases where a merchant bills a buyer in a non-primary currency for that buyer. */ private String exchangeRate; /** * Fraud Management Filter (FMF) details applied for the payment that could result in accept, deny, or pending action. Returned in a payment response only if the merchant has enabled FMF in the profile settings and one of the fraud filters was triggered based on those settings. See [Fraud Management Filters Summary](/docs/classic/fmf/integration-guide/FMFSummary/) for more information. */ private FmfDetails fmfDetails; /** * Receipt id is a payment identification number returned for guest users to identify the payment. */ private String receiptId; /** * ID of the payment resource on which this transaction is based. */ private String parentPayment; /** * Response codes returned by the processor concerning the submitted payment. Only supported when the `payment_method` is set to `credit_card`. */ private ProcessorResponse processorResponse; /** * ID of the billing agreement used as reference to execute this transaction. */ private String billingAgreementId; /** * Time of sale as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6) */ private String createTime; /** * Time the resource was last updated in UTC ISO8601 format. */ private String updateTime; /** * */ private List<Links> links; /** * Default Constructor */ public Sale() { } /** * Parameterized Constructor */ public Sale(String id, Amount amount, String state, String parentPayment, String createTime) { this.id = id; this.amount = amount; this.state = state; this.parentPayment = parentPayment; this.createTime = createTime; } /** * Shows details for a sale, by ID. Returns only sales that were created through the REST API. * @deprecated Please use {@link #get(APIContext, String)} instead. * @param accessToken * Access Token used for the API call. * @param saleId * String * @return Sale * @throws PayPalRESTException */ public static Sale get(String accessToken, String saleId) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return get(apiContext, saleId); } /** * Shows details for a sale, by ID. Returns only sales that were created through the REST API. * @param apiContext * {@link APIContext} used for the API call. * @param saleId * String * @return Sale * @throws PayPalRESTException */ public static Sale get(APIContext apiContext, String saleId) throws PayPalRESTException { 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(pattern, parameters); String payLoad = ""; return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, Sale.class); } /** * Creates (and processes) a new Refund Transaction added as a related resource. * @deprecated Please use {@link #refund(APIContext, Refund)} instead. * * @param accessToken * Access Token used for the API call. * @param refund * Refund * @return Refund * @throws PayPalRESTException */ @Deprecated public Refund refund(String accessToken, Refund refund) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return refund(apiContext, refund); } /** * @deprecated Please use {@link #refund(APIContext, RefundRequest)} instead * * Refunds a sale, by ID. For a full refund, include an empty payload in the JSON request body. For a partial refund, include an `amount` object in the JSON request body. * @param apiContext * {@link APIContext} used for the API call. * @param refund * Refund * @return Refund * @throws PayPalRESTException */ @Deprecated public Refund refund(APIContext apiContext, Refund refund) throws PayPalRESTException { 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(pattern, parameters); String payLoad = refund.toJSON(); Refund refundResponse = configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Refund.class); apiContext.setRequestId(null); return refundResponse; } /** * Refunds a sale, by ID. For a full refund, include an empty payload in the JSON request body. For a partial refund, include an `amount` object in the JSON request body. * @param apiContext * {@link APIContext} used for the API call. * @param refundRequest * RefundRequest * @return DetailedRefund * @throws PayPalRESTException */ public DetailedRefund refund(APIContext apiContext, RefundRequest refundRequest) throws PayPalRESTException { if (this.getId() == null) { throw new IllegalArgumentException("Id cannot be null"); } if (refundRequest == null) { throw new IllegalArgumentException("refundRequest cannot be null"); } Object[] parameters = new Object[] {this.getId()}; String pattern = "v1/payments/sale/{0}/refund"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = refundRequest.toJSON(); return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, DetailedRefund.class); } }
3,843
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/HyperSchema.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class HyperSchema extends PayPalModel { /** * */ private List<Links> links; /** * */ private String fragmentResolution; /** * */ private Boolean readonly; /** * */ private String contentEncoding; /** * */ private String pathStart; /** * */ private String mediaType; /** * Default Constructor */ public HyperSchema() { } }
3,844
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/ExtendedBankAccount.java
package com.paypal.api.payments; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class ExtendedBankAccount extends BankAccount { /** * Identifier of the direct debit mandate to validate. Currently supported only for EU bank accounts(SEPA). */ private String mandateReferenceNumber; /** * Default Constructor */ public ExtendedBankAccount() { } }
3,845
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/ShippingInfo.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class ShippingInfo extends PayPalModel { /** * The invoice recipient first name. Maximum length is 30 characters. */ private String firstName; /** * The invoice recipient last name. Maximum length is 30 characters. */ private String lastName; /** * The invoice recipient company business name. Maximum length is 100 characters. */ private String businessName; /** * The invoice recipient address. */ private InvoiceAddress address; /** * The invoice recipient phone number. */ private Phone phone; /** * Default Constructor */ public ShippingInfo() { } }
3,846
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Plan.java
package com.paypal.api.payments; import com.paypal.base.rest.*; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import lombok.Getter; import lombok.Setter; import java.util.List; import java.util.Map; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Plan extends PayPalResource { /** * Identifier of the billing plan. 128 characters max. */ private String id; /** * Name of the billing plan. 128 characters max. */ private String name; /** * Description of the billing plan. 128 characters max. */ private String description; /** * Type of the billing plan. Allowed values: `FIXED`, `INFINITE`. */ private String type; /** * Status of the billing plan. Allowed values: `CREATED`, `ACTIVE`, `INACTIVE`, and `DELETED`. */ private String state; /** * Time when the billing plan was created. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String createTime; /** * Time when this billing plan was updated. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String updateTime; /** * Array of payment definitions for this billing plan. */ private List<PaymentDefinition> paymentDefinitions; /** * Array of terms for this billing plan. */ private List<Terms> terms; /** * Specific preferences such as: set up fee, max fail attempts, autobill amount, and others that are configured for this billing plan. */ private MerchantPreferences merchantPreferences; /** * */ private List<Links> links; /** * Default Constructor */ public Plan() { } /** * Parameterized Constructor */ public Plan(String name, String description, String type) { this.name = name; this.description = description; this.type = type; } /** * Retrieve the details for a particular billing plan by passing the billing plan ID to the request URI. * @deprecated Please use {@link #get(APIContext, String)} instead. * * @param accessToken * Access Token used for the API call. * @param planId * String * @return Plan * @throws PayPalRESTException */ public static Plan get(String accessToken, String planId) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return get(apiContext, planId); } /** * Retrieve the details for a particular billing plan by passing the billing plan ID to the request URI. * @param apiContext * {@link APIContext} used for the API call. * @param planId * String * @return Plan * @throws PayPalRESTException */ public static Plan get(APIContext apiContext, String planId) throws PayPalRESTException { if (planId == null) { throw new IllegalArgumentException("planId cannot be null"); } Object[] parameters = new Object[] {planId}; String pattern = "v1/payments/billing-plans/{0}"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = ""; return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, Plan.class); } /** * Create a new billing plan by passing the details for the plan, including the plan name, description, and type, to the request URI. * @deprecated Please use {@link #create(APIContext)} instead. * * @param accessToken * Access Token used for the API call. * @return Plan * @throws PayPalRESTException */ public Plan create(String accessToken) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return create(apiContext); } /** * Create a new billing plan by passing the details for the plan, including the plan name, description, and type, to the request URI. * @param apiContext * {@link APIContext} used for the API call. * @return Plan * @throws PayPalRESTException */ public Plan create(APIContext apiContext) throws PayPalRESTException { String resourcePath = "v1/payments/billing-plans"; String payLoad = this.toJSON(); return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Plan.class); } /** * Replace specific fields within a billing plan by passing the ID of the billing plan to the request URI. In addition, pass a patch object in the request JSON that specifies the operation to perform, field to update, and new value for each update. * @deprecated Please use {@link #update(APIContext, List)} instead. * * @param accessToken * Access Token used for the API call. * @param patchRequest * PatchRequest * @throws PayPalRESTException */ public void update(String accessToken, List<Patch> patchRequest) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); update(apiContext, patchRequest); return; } /** * Replace specific fields within a billing plan by passing the ID of the billing plan to the request URI. In addition, pass a patch object in the request JSON that specifies the operation to perform, field to update, and new value for each update. * @param apiContext * {@link APIContext} used for the API call. * @param patchRequest * PatchRequest * @throws PayPalRESTException */ public void update(APIContext apiContext, List<Patch> patchRequest) throws PayPalRESTException { if (this.getId() == null) { throw new IllegalArgumentException("Id cannot be null"); } if (patchRequest == null) { throw new IllegalArgumentException("patchRequest cannot be null"); } Object[] parameters = new Object[] {this.getId()}; String pattern = "v1/payments/billing-plans/{0}"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = JSONFormatter.toJSON(patchRequest); configureAndExecute(apiContext, HttpMethod.PATCH, resourcePath, payLoad, null); return; } /** * List billing plans according to optional query string parameters specified. * @deprecated Please use {@link #list(APIContext, Map)} instead. * * @param accessToken * Access Token used for the API call. * @param containerMap * Map<String, String> * @return PlanList * @throws PayPalRESTException */ public static PlanList list(String accessToken, Map<String, String> containerMap) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return list(apiContext, containerMap); } /** * List billing plans according to optional query string parameters specified. * @param apiContext * {@link APIContext} used for the API call. * @param containerMap * Map<String, String> * @return PlanList * @throws PayPalRESTException */ public static PlanList list(APIContext apiContext, Map<String, String> containerMap) throws PayPalRESTException { if (containerMap == null) { throw new IllegalArgumentException("containerMap cannot be null"); } Object[] parameters = new Object[] {containerMap}; String pattern = "v1/payments/billing-plans?page_size={0}&status={1}&page={2}&total_required={3}"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = ""; PlanList plans = configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, PlanList.class); return plans; } }
3,847
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/RefundRequest.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class RefundRequest extends PayPalModel { /** * Details including both refunded amount (to payer) and refunded fee (to payee). */ private Amount amount; /** * Description of what is being refunded for. Character length and limitations: 255 single-byte alphanumeric characters. */ private String description; /** * Type of refund you are making. */ private String refundType; /** * Type of PayPal funding source (balance or eCheck) that can be used for auto refund. */ private String refundSource; /** * Reason description for the Sale transaction being refunded. */ private String reason; /** * The invoice number that is used to track this payment. Character length and limitations: 127 single-byte alphanumeric characters. */ private String invoiceNumber; /** * Flag to indicate that the buyer was already given store credit for a given transaction. */ private Boolean refundAdvice; /** * It indicates that the resource id passed is not processed by payments platform */ private String isNonPlatformTransaction; /** * Default Constructor */ public RefundRequest() { } }
3,848
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/EventTypeList.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import lombok.Getter; import lombok.Setter; import java.util.ArrayList; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class EventTypeList extends PayPalModel { /** * A list of Webhooks event-types */ private List<EventType> eventTypes; /** * Default Constructor */ public EventTypeList() { eventTypes = new ArrayList<EventType>(); } }
3,849
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/FundingDetail.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class FundingDetail extends PayPalModel { /** * Expected clearing time */ private String clearingTime; /** * [DEPRECATED] Hold-off duration of the payment. payment_debit_date should be used instead. */ private String paymentHoldDate; /** * Date when funds will be debited from the payer's account */ private String paymentDebitDate; /** * Processing type of the payment card */ private String processingType; /** * Default Constructor */ public FundingDetail() { } }
3,850
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/InvoiceItem.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class InvoiceItem extends PayPalModel { /** * Name of the item. 200 characters max. */ private String name; /** * Description of the item. 1000 characters max. */ private String description; /** * Quantity of the item. Range of -10000 to 10000. */ private float quantity; /** * Unit price of the item. Range of -1,000,000 to 1,000,000. */ private Currency unitPrice; /** * Tax associated with the item. */ private Tax tax; /** * The date when the item or service was provided. The date format is *yyyy*-*MM*-*dd* *z* as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String date; /** * The item discount, as a percent or an amount value. */ private Cost discount; /** * The image URL. Maximum length is 4000 characters. */ private String imageUrl; /** * The unit of measure of the item being invoiced. */ private String unitOfMeasure; /** * Default Constructor */ public InvoiceItem() { } /** * Parameterized Constructor */ public InvoiceItem(String name, float quantity, Currency unitPrice) { this.name = name; this.quantity = quantity; this.unitPrice = unitPrice; } }
3,851
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Agreement.java
package com.paypal.api.payments; import com.paypal.base.rest.*; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import lombok.Getter; import lombok.Setter; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLDecoder; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Agreement extends PayPalResource { /** * Identifier of the agreement. */ private String id; /** * State of the agreement */ private String state; /** * Name of the agreement. */ private String name; /** * Description of the agreement. */ private String description; /** * Start date of the agreement. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String startDate; /** * Details of the agreement. */ private AgreementDetails agreementDetails; /** * Details of the buyer who is enrolling in this agreement. This information is gathered from execution of the approval URL. */ private Payer payer; /** * Shipping address object of the agreement, which should be provided if it is different from the default address. */ private Address shippingAddress; /** * Default merchant preferences from the billing plan are used, unless override preferences are provided here. */ private MerchantPreferences overrideMerchantPreferences; /** * Array of override_charge_model for this agreement if needed to change the default models from the billing plan. */ private List<OverrideChargeModel> overrideChargeModels; /** * Plan details for this agreement. */ private Plan plan; /** * Date and time that this resource was created. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String createTime; /** * Date and time that this resource was updated. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String updateTime; /** * Payment token */ private String token; /** * */ private List<Links> links; /** * Default Constructor */ public Agreement() { } /** * Parameterized Constructor */ public Agreement(String name, String description, String startDate, Payer payer, Plan plan) { this.name = name; this.description = description; this.startDate = startDate; this.payer = payer; this.plan = plan; } /** * Create a new billing agreement by passing the details for the agreement, including the name, description, start date, payer, and billing plan in the request JSON. * @deprecated Please use {@link #create(APIContext)} instead. * * @param accessToken * Access Token used for the API call. * @return Agreement * @throws PayPalRESTException * @throws UnsupportedEncodingException * @throws MalformedURLException */ public Agreement create(String accessToken) throws PayPalRESTException, MalformedURLException, UnsupportedEncodingException { APIContext apiContext = new APIContext(accessToken); return create(apiContext); } /** * Create a new billing agreement by passing the details for the agreement, including the name, description, start date, payer, and billing plan in the request JSON. * @param apiContext * {@link APIContext} used for the API call. * @return Agreement * @throws PayPalRESTException * @throws MalformedURLException * @throws UnsupportedEncodingException */ public Agreement create(APIContext apiContext) throws PayPalRESTException, MalformedURLException, UnsupportedEncodingException { String resourcePath = "v1/payments/billing-agreements"; String payLoad = this.toJSON(); Agreement agreement = configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Agreement.class); for (Links links : agreement.getLinks()) { if ("approval_url".equals(links.getRel())) { URL url = new URL(links.getHref()); agreement.setToken(splitQuery(url).get("token")); break; } } return agreement; } /** * Helper class to parse Query part of a URL * @param url * @return Query part in the given URL in name-value pair * @throws UnsupportedEncodingException */ private static Map<String, String> splitQuery(URL url) throws UnsupportedEncodingException { Map<String, String> queryPairs = new HashMap<String, String>(); String query = url.getQuery(); String[] pairs = query.split("&"); for (String pair : pairs) { int idx = pair.indexOf("="); queryPairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8")); } return queryPairs; } /** * Execute a billing agreement after buyer approval by passing the payment token to the request URI. * @deprecated Please use {@link #execute(APIContext, String)} instead. * @param accessToken * Access Token used for the API call. * @return Agreement * @throws PayPalRESTException */ public Agreement execute(String accessToken) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return execute(apiContext, this.getToken()); } /** * Execute a billing agreement after buyer approval by passing the payment token to the request URI. * @param apiContext * {@link APIContext} used for the API call. * @param token * payment token (e.g., EC-0JP008296V451950C) * @return Agreement * @throws PayPalRESTException */ public static Agreement execute(APIContext apiContext, String token) throws PayPalRESTException { Object[] parameters = new Object[] { token }; String pattern = "v1/payments/billing-agreements/{0}/agreement-execute"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = ""; return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Agreement.class); } /** * Retrieve details for a particular billing agreement by passing the ID of the agreement to the request URI. * @deprecated Please use {@link #get(APIContext, String)} instead. * * @param accessToken * Access Token used for the API call. * @param agreementId * String * @return Agreement * @throws PayPalRESTException */ public static Agreement get(String accessToken, String agreementId) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return get(apiContext, agreementId); } /** * Retrieve details for a particular billing agreement by passing the ID of the agreement to the request URI. * @param apiContext * {@link APIContext} used for the API call. * @param agreementId * String * @return Agreement * @throws PayPalRESTException */ public static Agreement get(APIContext apiContext, String agreementId) throws PayPalRESTException { if (agreementId == null) { throw new IllegalArgumentException("agreementId cannot be null"); } Object[] parameters = new Object[] {agreementId}; String pattern = "v1/payments/billing-agreements/{0}"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = ""; return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, Agreement.class); } /** * Update details of a billing agreement, such as the description, shipping address, and start date, by passing the ID of the agreement to the request URI. * @deprecated Please use {@link #update(APIContext, List)} instead. * @param accessToken * Access Token used for the API call. * @param patchRequest * PatchRequest * @return Agreement * @throws PayPalRESTException */ public Agreement update(String accessToken, List<Patch> patchRequest) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return update(apiContext, patchRequest); } /** * Update details of a billing agreement, such as the description, shipping address, and start date, by passing the ID of the agreement to the request URI. * @param apiContext * {@link APIContext} used for the API call. * @param patchRequest * PatchRequest (list of patches) * @return Agreement * @throws PayPalRESTException */ public Agreement update(APIContext apiContext, List<Patch> patchRequest) throws PayPalRESTException { if (this.getId() == null) { throw new IllegalArgumentException("Id cannot be null"); } if (patchRequest == null) { throw new IllegalArgumentException("patchRequest cannot be null"); } Object[] parameters = new Object[] {this.getId()}; String pattern = "v1/payments/billing-agreements/{0}"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = JSONFormatter.toJSON(patchRequest); return configureAndExecute(apiContext, HttpMethod.PATCH, resourcePath, payLoad, Agreement.class); } /** * Suspend a particular billing agreement by passing the ID of the agreement to the request URI. * @deprecated Please use {@link #suspend(APIContext, AgreementStateDescriptor)} instead. * @param accessToken * Access Token used for the API call. * @param agreementStateDescriptor * AgreementStateDescriptor * @throws PayPalRESTException */ public void suspend(String accessToken, AgreementStateDescriptor agreementStateDescriptor) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); suspend(apiContext, agreementStateDescriptor); return; } /** * Suspend a particular billing agreement by passing the ID of the agreement to the request URI. * @param apiContext * {@link APIContext} used for the API call. * @param agreementStateDescriptor * AgreementStateDescriptor * @throws PayPalRESTException */ public void suspend(APIContext apiContext, AgreementStateDescriptor agreementStateDescriptor) throws PayPalRESTException { if (this.getId() == null) { throw new IllegalArgumentException("Id cannot be null"); } if (agreementStateDescriptor == null) { throw new IllegalArgumentException("agreementStateDescriptor cannot be null"); } Object[] parameters = new Object[] {this.getId()}; String pattern = "v1/payments/billing-agreements/{0}/suspend"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = agreementStateDescriptor.toJSON(); configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, null); return; } /** * Reactivate a suspended billing agreement by passing the ID of the agreement to the appropriate URI. In addition, pass an agreement_state_descriptor object in the request JSON that includes a note about the reason for changing the state of the agreement and the amount and currency for the agreement. * @deprecated Please use {@link #reActivate(APIContext, AgreementStateDescriptor)} instead. * @param accessToken * Access Token used for the API call. * @param agreementStateDescriptor * AgreementStateDescriptor * @throws PayPalRESTException */ public void reActivate(String accessToken, AgreementStateDescriptor agreementStateDescriptor) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); reActivate(apiContext, agreementStateDescriptor); return; } /** * Reactivate a suspended billing agreement by passing the ID of the agreement to the appropriate URI. In addition, pass an agreement_state_descriptor object in the request JSON that includes a note about the reason for changing the state of the agreement and the amount and currency for the agreement. * @param apiContext * {@link APIContext} used for the API call. * @param agreementStateDescriptor * AgreementStateDescriptor * @throws PayPalRESTException */ public void reActivate(APIContext apiContext, AgreementStateDescriptor agreementStateDescriptor) throws PayPalRESTException { if (this.getId() == null) { throw new IllegalArgumentException("Id cannot be null"); } if (agreementStateDescriptor == null) { throw new IllegalArgumentException("agreementStateDescriptor cannot be null"); } Object[] parameters = new Object[] {this.getId()}; String pattern = "v1/payments/billing-agreements/{0}/re-activate"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = agreementStateDescriptor.toJSON(); configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, null); return; } /** * Cancel a billing agreement by passing the ID of the agreement to the request URI. In addition, pass an agreement_state_descriptor object in the request JSON that includes a note about the reason for changing the state of the agreement and the amount and currency for the agreement. * @deprecated Please use {@link #cancel(APIContext, AgreementStateDescriptor)} instead. * @param accessToken * Access Token used for the API call. * @param agreementStateDescriptor * AgreementStateDescriptor * @throws PayPalRESTException */ public void cancel(String accessToken, AgreementStateDescriptor agreementStateDescriptor) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); cancel(apiContext, agreementStateDescriptor); return; } /** * Cancel a billing agreement by passing the ID of the agreement to the request URI. In addition, pass an agreement_state_descriptor object in the request JSON that includes a note about the reason for changing the state of the agreement and the amount and currency for the agreement. * @param apiContext * {@link APIContext} used for the API call. * @param agreementStateDescriptor * AgreementStateDescriptor * @throws PayPalRESTException */ public void cancel(APIContext apiContext, AgreementStateDescriptor agreementStateDescriptor) throws PayPalRESTException { if (this.getId() == null) { throw new IllegalArgumentException("Id cannot be null"); } if (agreementStateDescriptor == null) { throw new IllegalArgumentException("agreementStateDescriptor cannot be null"); } Object[] parameters = new Object[] {this.getId()}; String pattern = "v1/payments/billing-agreements/{0}/cancel"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = agreementStateDescriptor.toJSON(); configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, null); return; } /** * Bill an outstanding amount for an agreement by passing the ID of the agreement to the request URI. In addition, pass an agreement_state_descriptor object in the request JSON that includes a note about the reason for changing the state of the agreement and the amount and currency for the agreement. * @deprecated Please use {@link #billBalance(APIContext, AgreementStateDescriptor)} instead. * @param accessToken * Access Token used for the API call. * @param agreementStateDescriptor * AgreementStateDescriptor * @throws PayPalRESTException */ public void billBalance(String accessToken, AgreementStateDescriptor agreementStateDescriptor) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); billBalance(apiContext, agreementStateDescriptor); return; } /** * Bill an outstanding amount for an agreement by passing the ID of the agreement to the request URI. In addition, pass an agreement_state_descriptor object in the request JSON that includes a note about the reason for changing the state of the agreement and the amount and currency for the agreement. * @param apiContext * {@link APIContext} used for the API call. * @param agreementStateDescriptor * AgreementStateDescriptor * @throws PayPalRESTException */ public void billBalance(APIContext apiContext, AgreementStateDescriptor agreementStateDescriptor) throws PayPalRESTException { if (this.getId() == null) { throw new IllegalArgumentException("Id cannot be null"); } if (agreementStateDescriptor == null) { throw new IllegalArgumentException("agreementStateDescriptor cannot be null"); } Object[] parameters = new Object[] {this.getId()}; String pattern = "v1/payments/billing-agreements/{0}/bill-balance"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = agreementStateDescriptor.toJSON(); configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, null); return; } /** * Set the balance for an agreement by passing the ID of the agreement to the request URI. In addition, pass a common_currency object in the request JSON that specifies the currency type and value of the balance. * @deprecated Please use {@link #setBalance(APIContext, Currency)} instead. * @param accessToken * Access Token used for the API call. * @param currency * Currency * @throws PayPalRESTException */ public void setBalance(String accessToken, Currency currency) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); setBalance(apiContext, currency); return; } /** * Set the balance for an agreement by passing the ID of the agreement to the request URI. In addition, pass a common_currency object in the request JSON that specifies the currency type and value of the balance. * @param apiContext * {@link APIContext} used for the API call. * @param currency * Currency * @throws PayPalRESTException */ public void setBalance(APIContext apiContext, Currency currency) throws PayPalRESTException { if (this.getId() == null) { throw new IllegalArgumentException("Id cannot be null"); } if (currency == null) { throw new IllegalArgumentException("currency cannot be null"); } Object[] parameters = new Object[] {this.getId()}; String pattern = "v1/payments/billing-agreements/{0}/set-balance"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = currency.toJSON(); configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, null); return; } /** * List transactions for a billing agreement by passing the ID of the agreement, as well as the start and end dates of the range of transactions to list, to the request URI. * @deprecated Please use {@link #transactions(APIContext, String, Date, Date)} instead. * @param accessToken * Access Token used for the API call. * @param agreementId * String * @return AgreementTransactions * @throws PayPalRESTException */ public static AgreementTransactions transactions(String accessToken, String agreementId, Date startDate, Date endDate) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return transactions(apiContext, agreementId, startDate, endDate); } /** * List transactions for a billing agreement by passing the ID of the agreement, as well as the start and end dates of the range of transactions to list, to the request URI. * @param apiContext * {@link APIContext} used for the API call. * @param agreementId * String * @return AgreementTransactions * @throws PayPalRESTException */ public static AgreementTransactions transactions(APIContext apiContext, String agreementId, Date startDate, Date endDate) throws PayPalRESTException { if (startDate == null) { throw new IllegalArgumentException("startDate cannot be null"); } if (endDate == null) { throw new IllegalArgumentException("endDate cannot be null"); } if (agreementId == null) { throw new IllegalArgumentException("agreementId cannot be null"); } SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); String sDate = dateFormat.format(startDate); String eDate = dateFormat.format(endDate); Object[] parameters = new Object[] {agreementId, sDate, eDate}; String pattern = "v1/payments/billing-agreements/{0}/transactions?start_date={1}&end_date={2}"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = ""; AgreementTransactions transactions = configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, AgreementTransactions.class); return transactions; } }
3,852
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/FundingSource.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class FundingSource extends PayPalModel { /** * Default Constructor */ public FundingSource() { } }
3,853
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/TransactionBase.java
package com.paypal.api.payments; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import lombok.Getter; import lombok.Setter; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class TransactionBase extends CartBase { /** * List of financial transactions (Sale, Authorization, Capture, Refund) related to the payment. */ private List<RelatedResources> relatedResources; /** * Identifier to the purchase unit corresponding to this sale transaction. */ private String purchaseUnitReferenceId; /** * Default Constructor */ public TransactionBase() { } }
3,854
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PaymentExecution.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class PaymentExecution extends PayPalModel { /** * The ID of the Payer, passed in the `return_url` by PayPal. */ private String payerId; /** * Carrier account id for a carrier billing payment. For a carrier billing payment, payer_id is not applicable. */ private String carrierAccountId; /** * Transactional details including the amount and item details. */ private List<Transactions> transactions; /** * Default Constructor */ public PaymentExecution() { } }
3,855
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Error.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Error extends PayPalModel { /** * Human readable, unique name of the error. */ private String name; /** * Message describing the error. */ private String message; /** * Additional details of the error */ private List<ErrorDetails> details; /** * URI for detailed information related to this error for the developer. */ private String informationLink; /** * PayPal internal identifier used for correlation purposes. */ private String debugId; /** * Links */ private List<DefinitionsLinkdescription> links; /** * @deprecated This property is not available publicly * PayPal internal error code. */ @Deprecated private String code; /** * @deprecated This property is not available publicly * Fraud filter details. Only supported when the `payment_method` is set to `credit_card` */ @Deprecated private FmfDetails fmfDetails; /** * @deprecated This property is not available publicly * response codes returned from a payment processor such as avs, cvv, etc. Only supported when the `payment_method` is set to `credit_card`. */ @Deprecated private ProcessorResponse processorResponse; /** * @deprecated This property is not available publicly * Reference ID of the purchase_unit associated with this error */ @Deprecated() private String purchaseUnitReferenceId; /** * Default Constructor */ public Error() { } /** * Parameterized Constructor */ public Error(String name, String message, String informationLink, String debugId) { this.name = name; this.message = message; this.informationLink = informationLink; this.debugId = debugId; } public String toString() { return "name: " + this.name + "\tmessage: " + this.message + "\tdetails: " + this.details + "\tdebug-id: " + this.debugId + "\tinformation-link: " + this.informationLink; } }
3,856
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/ShippingAddress.java
package com.paypal.api.payments; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class ShippingAddress extends Address { /** * Address ID assigned in PayPal system. */ private String id; /** * Name of the recipient at this address. */ private String recipientName; /** * Default shipping address of the Payer. */ private Boolean defaultAddress; /** * Default Constructor */ public ShippingAddress() { } /** * Parameterized Constructor */ public ShippingAddress(String recipientName) { this.recipientName = recipientName; } }
3,857
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/TemplateSettingsMetadata.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class TemplateSettingsMetadata extends PayPalModel { /** * Indicates whether this field should be hidden. default is false */ private Boolean hidden; /** * Default Constructor */ public TemplateSettingsMetadata() { } }
3,858
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PayoutBatchHeader.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class PayoutBatchHeader extends PayPalModel { /** * The PayPal-generated ID for a batch payout. */ private String payoutBatchId; /** * The PayPal-generated batch payout status. If the batch payout passes the preliminary checks, the status is `PENDING`. */ private String batchStatus; /** * The time the batch entered processing. */ private String timeCreated; /** * The time that processing for the batch was completed. */ private String timeCompleted; /** * The original batch header as provided by the payment sender. */ private PayoutSenderBatchHeader senderBatchHeader; /** * Total amount, in U.S. dollars, requested for the applicable payouts. */ private Currency amount; /** * Total estimate in U.S. dollars for the applicable payouts fees. */ private Currency fees; /** * */ private Error errors; /** * */ private List<Links> links; /** * Default Constructor */ public PayoutBatchHeader() { } /** * Parameterized Constructor */ public PayoutBatchHeader(String payoutBatchId, String batchStatus, String timeCreated, PayoutSenderBatchHeader senderBatchHeader, Currency amount, Currency fees) { this.payoutBatchId = payoutBatchId; this.batchStatus = batchStatus; this.timeCreated = timeCreated; this.senderBatchHeader = senderBatchHeader; this.amount = amount; this.fees = fees; } }
3,859
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/CreateProfileResponse.java
package com.paypal.api.payments; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class CreateProfileResponse extends WebProfile { /** * Default Constructor */ public CreateProfileResponse() { } }
3,860
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/TemplateSettings.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class TemplateSettings extends PayPalModel { /** * The field name (for any field in template_data) for which the corresponding display preferences will be mapped to. */ private String fieldName; /** * Settings metadata for each field. */ private TemplateSettingsMetadata displayPreference; /** * Default Constructor */ public TemplateSettings() { } }
3,861
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Payout.java
package com.paypal.api.payments; import com.paypal.base.rest.*; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import lombok.Getter; import lombok.Setter; import java.util.HashMap; import java.util.List; import java.util.Map; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Payout extends PayPalResource { /** * The original batch header as provided by the payment sender. */ private PayoutSenderBatchHeader senderBatchHeader; /** * An array of payout items (that is, a set of individual payouts). */ private List<PayoutItem> items; /** * */ private List<Links> links; /** * Default Constructor */ public Payout() { } /** * Parameterized Constructor */ public Payout(PayoutSenderBatchHeader senderBatchHeader, List<PayoutItem> items) { this.senderBatchHeader = senderBatchHeader; this.items = items; } /** * You can submit a payout with a synchronous API call, which immediately returns the results of a PayPal payment. * @deprecated Please use {@link #createSynchronous(APIContext)} instead. * * @param accessToken * Access Token used for the API call. * @return PayoutBatch * @throws PayPalRESTException */ public PayoutBatch createSynchronous(String accessToken) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); Map<String, String> parameters = new HashMap<String, String>(); parameters.put("sync_mode", "true"); return create(apiContext, parameters); } /** * You can submit a payout with a synchronous API call, which immediately returns the results of a PayPal payment. * * @param apiContext * {@link APIContext} used for the API call. * @return PayoutBatch * @throws PayPalRESTException */ public PayoutBatch createSynchronous(APIContext apiContext) throws PayPalRESTException { Map<String, String> parameters = new HashMap<String, String>(); parameters.put("sync_mode", "true"); return create(apiContext, parameters); } /** * Create a payout batch resource by passing a sender_batch_header and an * items array to the request URI. The sender_batch_header contains payout * parameters that describe the handling of a batch resource while the items * array conatins payout items. * @deprecated Please use {@link #create(APIContext, Map)} instead. * * @param accessToken * Access Token used for the API call. * @param parameters * Map<String, String> * @return PayoutBatch * @throws PayPalRESTException */ public PayoutBatch create(String accessToken, Map<String, String> parameters) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return create(apiContext, parameters); } /** * Create a payout batch resource by passing a sender_batch_header and an * items array to the request URI. The sender_batch_header contains payout * parameters that describe the handling of a batch resource while the items * array conatins payout items. * * @param apiContext * {@link APIContext} used for the API call. * @param parameters * Map<String, String> * @return PayoutBatch * @throws PayPalRESTException */ public PayoutBatch create(APIContext apiContext, Map<String, String> parameters) throws PayPalRESTException { if (parameters == null) { parameters = new HashMap<String, String>(); } Object[] parametersObj = new Object[] {parameters}; String pattern = "v1/payments/payouts?sync_mode={0}"; String resourcePath = RESTUtil.formatURIPath(pattern, parametersObj); String payLoad = this.toJSON(); return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, PayoutBatch.class); } /** * Obtain the status of a specific batch resource by passing the payout * batch ID to the request URI. You can issue this call multiple times to * get the current status. * @deprecated Please use {@link #get(APIContext, String)} instead. * * @param accessToken * Access Token used for the API call. * @param payoutBatchId * String * @return PayoutBatch * @throws PayPalRESTException */ public static PayoutBatch get(String accessToken, String payoutBatchId) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return get(apiContext, payoutBatchId); } /** * Obtain the status of a specific batch resource by passing the payout * batch ID to the request URI. You can issue this call multiple times to * get the current status. * * @param apiContext * {@link APIContext} used for the API call. * @param payoutBatchId * String * @return PayoutBatch * @throws PayPalRESTException */ public static PayoutBatch get(APIContext apiContext, String payoutBatchId) throws PayPalRESTException { if (payoutBatchId == null) { throw new IllegalArgumentException("payoutBatchId cannot be null"); } Object[] parameters = new Object[] { payoutBatchId }; String pattern = "v1/payments/payouts/{0}"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = ""; return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, PayoutBatch.class); } }
3,862
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/CarrierAccountToken.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class CarrierAccountToken extends PayPalModel { /** * ID of a previously saved carrier account resource. */ private String carrierAccountId; /** * The unique identifier of the payer used when saving this carrier account instrument. */ private String externalCustomerId; /** * Default Constructor */ public CarrierAccountToken() { } /** * Parameterized Constructor */ public CarrierAccountToken(String carrierAccountId, String externalCustomerId) { this.carrierAccountId = carrierAccountId; this.externalCustomerId = externalCustomerId; } }
3,863
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PaymentSummary.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class PaymentSummary extends PayPalModel { /** * Total Amount paid/refunded via PayPal. */ private Currency paypal; /** * Total Amount paid/refunded via other sources. */ private Currency other; /** * Default Constructor */ public PaymentSummary() { } }
3,864
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Item.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Item extends PayPalModel { /** * Stock keeping unit corresponding (SKU) to item. */ private String sku; /** * Item name. 127 characters max. */ private String name; /** * Description of the item. Only supported when the `payment_method` is set to `paypal`. */ private String description; /** * Number of a particular item. 10 characters max. */ private String quantity; /** * Item cost. 10 characters max. */ private String price; /** * 3-letter [currency code](https://developer.paypal.com/docs/integration/direct/rest_api_payment_country_currency_support/). */ private String currency; /** * Tax of the item. Only supported when the `payment_method` is set to `paypal`. */ private String tax; /** * URL linking to item information. Available to payer in transaction history. */ private String url; /** * Category type of the item. */ private String category; /** * Weight of the item. */ private Measurement weight; /** * Length of the item. */ private Measurement length; /** * Height of the item. */ private Measurement height; /** * Width of the item. */ private Measurement width; /** * Set of optional data used for PayPal risk determination. */ private List<NameValuePair> supplementaryData; /** * Set of optional data used for PayPal post-transaction notifications. */ private List<NameValuePair> postbackData; /** * Default Constructor */ public Item() { } /** * Parameterized Constructor */ public Item(String name, String quantity, String price, String currency) { this.name = name; this.quantity = quantity; this.price = price; this.currency = currency; } }
3,865
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Transaction.java
package com.paypal.api.payments; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.util.List; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Transaction extends TransactionBase { /** * Financial transactions related to a payment. */ private List<Transaction> transactions; /** * Default Constructor */ public Transaction() { } }
3,866
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/OverrideChargeModel.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import lombok.Getter; import lombok.Setter; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class OverrideChargeModel extends PayPalModel { /** * ID of charge model. */ private String chargeId; /** * Updated Amount to be associated with this charge model. */ private Currency amount; /** * Default Constructor */ public OverrideChargeModel() { } }
3,867
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/MerchantPreferences.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import lombok.Getter; import lombok.Setter; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class MerchantPreferences extends PayPalModel { /** * Identifier of the merchant_preferences. 128 characters max. */ private String id; /** * Setup fee amount. Default is 0. */ private Currency setupFee; /** * Redirect URL on cancellation of agreement request. 1000 characters max. */ private String cancelUrl; /** * Redirect URL on creation of agreement request. 1000 characters max. */ private String returnUrl; /** * Notify URL on agreement creation. 1000 characters max. */ private String notifyUrl; /** * Total number of failed attempts allowed. Default is 0, representing an infinite number of failed attempts. */ private String maxFailAttempts; /** * Allow auto billing for the outstanding amount of the agreement in the next cycle. Allowed values: `YES`, `NO`. Default is `NO`. */ private String autoBillAmount; /** * Action to take if a failure occurs during initial payment. Allowed values: `CONTINUE`, `CANCEL`. Default is continue. */ private String initialFailAmountAction; /** * Payment types that are accepted for this plan. */ private String acceptedPaymentType; /** * char_set for this plan. */ private String charSet; /** * Default Constructor */ public MerchantPreferences() { } /** * Parameterized Constructor */ public MerchantPreferences(String cancelUrl, String returnUrl) { this.cancelUrl = cancelUrl; this.returnUrl = returnUrl; } }
3,868
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/ErrorDetails.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class ErrorDetails extends PayPalModel { /** * Name of the field that caused the error. */ private String field; /** * Reason for the error. */ private String issue; /** * @deprecated This property is not publicly available * Reference ID of the purchase_unit associated with this error */ @Deprecated private String purchaseUnitReferenceId; /** * @deprecated This property is not publicly available * PayPal internal error code. */ @Deprecated private String code; /** * Default Constructor */ public ErrorDetails() { } /** * Parameterized Constructor */ public ErrorDetails(String field, String issue) { this.field = field; this.issue = issue; } }
3,869
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/AgreementStateDescriptor.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import lombok.Getter; import lombok.Setter; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class AgreementStateDescriptor extends PayPalModel { /** * Reason for changing the state of the agreement. */ private String note; /** * The amount and currency of the agreement. */ private Currency amount; /** * Default Constructor */ public AgreementStateDescriptor() { } /** * Parameterized Constructor */ public AgreementStateDescriptor(Currency amount) { this.amount = amount; } }
3,870
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PaymentTerm.java
package com.paypal.api.payments; import com.paypal.base.rest.PayPalModel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class PaymentTerm extends PayPalModel { /** * The terms by which the invoice payment is due. */ private String termType; /** * The date when the invoice payment is due. This date must be a future date. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). */ private String dueDate; /** * Default Constructor */ public PaymentTerm() { } }
3,871
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/openidconnect/CreateFromRefreshTokenParameters.java
package com.paypal.api.openidconnect; import com.paypal.base.ClientCredentials; import java.util.HashMap; import java.util.Map; public class CreateFromRefreshTokenParameters extends ClientCredentials { /** * Scope */ private static final String SCOPE = "scope"; /** * Grant Type */ private static final String GRANTTYPE = "grant_type"; // Map backing QueryParameters intended to processed // by SDK library 'RESTUtil' private Map<String, String> containerMap; public CreateFromRefreshTokenParameters() { containerMap = new HashMap<String, String>(); containerMap.put(GRANTTYPE, "refresh_token"); } /** * @return the containerMap */ public Map<String, String> getContainerMap() { return containerMap; } /** * Set the Scope * * @param scope */ public void setScope(String scope) { containerMap.put(SCOPE, scope); } /** * Set the Grant Type * * @param grantType */ public void setGrantType(String grantType) { containerMap.put(GRANTTYPE, grantType); } }
3,872
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/openidconnect/Tokeninfo.java
package com.paypal.api.openidconnect; import com.paypal.base.Constants; import com.paypal.base.rest.*; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; /** * Class Tokeninfo * */ public class Tokeninfo extends PayPalResource { /** * OPTIONAL, if identical to the scope requested by the client; otherwise, * REQUIRED. */ private String scope; /** * The access token issued by the authorization server. */ private String accessToken; /** * The refresh token, which can be used to obtain new access tokens using * the same authorization grant as described in OAuth2.0 RFC6749 in Section * 6. */ private String refreshToken; /** * The type of the token issued as described in OAuth2.0 RFC6749 (Section * 7.1). Value is case insensitive. */ private String tokenType; /** * The lifetime in seconds of the access token. */ private Integer expiresIn; /** * APP ID associated with this token */ private String appId; /** * Default Constructor */ public Tokeninfo() { } /** * Parameterized Constructor */ public Tokeninfo(String accessToken, String tokenType, Integer expiresIn) { this.accessToken = accessToken; this.tokenType = tokenType; this.expiresIn = expiresIn; } /** * Setter for scope */ public void setScope(String scope) { this.scope = scope; } /** * Getter for scope */ public String getScope() { return this.scope; } /** * Setter for accessToken */ public void setAccessToken(String accessToken) { this.accessToken = accessToken; } /** * Getter for just accessToken without type (e.g., "EEwJ6tF9x5WCIZDYzyZGaz6Khbw7raYRIBV_WxVvgmsG") */ public String getAccessToken() { return this.accessToken; } /** * Getter for accessToken with token type (e.g., "Bearer: EEwJ6tF9x5WCIZDYzyZGaz6Khbw7raYRIBV_WxVvgmsG") */ public String getAccessTokenWithType() { return this.tokenType + " " + this.accessToken; } /** * Setter for refreshToken */ public void setRefreshToken(String refreshToken) { this.refreshToken = refreshToken; } /** * Getter for refreshToken */ public String getRefreshToken() { return this.refreshToken; } /** * Setter for tokenType */ public void setTokenType(String tokenType) { this.tokenType = tokenType; } /** * Getter for tokenType */ public String getTokenType() { return this.tokenType; } /** * Setter for expiresIn */ public void setExpiresIn(Integer expiresIn) { this.expiresIn = expiresIn; } /** * Getter for expiresIn */ public Integer getExpiresIn() { return this.expiresIn; } /** * Setter for appId */ public void setAppId(String appId) { this.appId = appId; } /** * Getter for appId */ public String getAppId() { return this.appId; } /** * @deprecated Please use {@link #createFromAuthorizationCode(APIContext, String)} instead. * There is no more need for passing clientId and secret in the params object anymore. * * @param createFromAuthorizationCodeParameters * Query parameters used for API call * @return Tokeninfo * @throws PayPalRESTException */ public static Tokeninfo createFromAuthorizationCode( CreateFromAuthorizationCodeParameters createFromAuthorizationCodeParameters) throws PayPalRESTException { return createFromAuthorizationCode(null, createFromAuthorizationCodeParameters); } /** * @deprecated Please use {@link #createFromAuthorizationCode(APIContext, String)} instead. * There is no more need for passing clientId and secret in the params object anymore. * * @param apiContext * {@link APIContext} to be used for the call. * @param createFromAuthorizationCodeParameters * Query parameters used for API call * @return Tokeninfo * @throws PayPalRESTException */ public static Tokeninfo createFromAuthorizationCode( APIContext apiContext, CreateFromAuthorizationCodeParameters createFromAuthorizationCodeParameters) throws PayPalRESTException { String pattern = "v1/identity/openidconnect/tokenservice?grant_type={0}&code={1}&redirect_uri={2}"; Object[] parameters = new Object[] { createFromAuthorizationCodeParameters }; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); return createFromAuthorizationCodeParameters(apiContext, createFromAuthorizationCodeParameters, resourcePath); } /** * Creates an Access Token from an Authorization Code. * * @param apiContext * {@link APIContext} to be used for the call. * @param code * Code returned from PayPal redirect. * @return Tokeninfo * @throws PayPalRESTException */ public static Tokeninfo createFromAuthorizationCode( APIContext apiContext, String code) throws PayPalRESTException { String pattern = "v1/identity/openidconnect/tokenservice?grant_type={0}&code={1}&redirect_uri={2}"; CreateFromAuthorizationCodeParameters params = new CreateFromAuthorizationCodeParameters(); params.setClientID(apiContext.getClientID()); params.setClientSecret(apiContext.getClientSecret()); params.setCode(code); Object[] parameters = new Object[] { params }; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); return createFromAuthorizationCodeParameters(apiContext, params, resourcePath); } /** * Creates an Access and a Refresh Tokens from an Authorization Code for future payment. * * @param apiContext * {@link APIContext} to be used for the call. * @param createFromAuthorizationCodeParameters * Query parameters used for API call * @return Tokeninfo * @throws PayPalRESTException */ public static Tokeninfo createFromAuthorizationCodeForFpp( APIContext apiContext, CreateFromAuthorizationCodeParameters createFromAuthorizationCodeParameters) throws PayPalRESTException { String pattern = "v1/oauth2/token?grant_type=authorization_code&response_type=token&redirect_uri=urn:ietf:wg:oauth:2.0:oob&code={0}"; Object[] parameters = new Object[] { createFromAuthorizationCodeParameters.getContainerMap().get("code") }; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); return createFromAuthorizationCodeParameters(apiContext, createFromAuthorizationCodeParameters, resourcePath); } private static Tokeninfo createFromAuthorizationCodeParameters( APIContext apiContext, CreateFromAuthorizationCodeParameters createFromAuthorizationCodeParameters, String resourcePath) throws PayPalRESTException { String authorizationHeader; String payLoad = resourcePath.substring(resourcePath.indexOf('?') + 1); resourcePath = resourcePath.substring(0, resourcePath.indexOf('?')); Map<String, String> headersMap = new HashMap<String, String>(); if (apiContext == null) { apiContext = new APIContext(); } apiContext.setRequestId(null); if (createFromAuthorizationCodeParameters.getClientID() == null || createFromAuthorizationCodeParameters.getClientID().trim() .length() <= 0 || createFromAuthorizationCodeParameters.getClientSecret() == null || createFromAuthorizationCodeParameters.getClientSecret() .trim().length() <= 0) { throw new PayPalRESTException( "ClientID and ClientSecret not set in CreateFromAuthorizationCodeParameters"); } apiContext.setRequestId(null); OAuthTokenCredential oauthTokenCredential = new OAuthTokenCredential( createFromAuthorizationCodeParameters.getClientID(), createFromAuthorizationCodeParameters.getClientSecret(), apiContext.getConfigurationMap()); authorizationHeader = oauthTokenCredential .getAuthorizationHeader(); headersMap.put(Constants.AUTHORIZATION_HEADER, authorizationHeader); headersMap.put(Constants.HTTP_CONTENT_TYPE_HEADER, Constants.HTTP_CONFIG_DEFAULT_CONTENT_TYPE); headersMap.put(Constants.HTTP_ACCEPT_HEADER, Constants.HTTP_CONTENT_TYPE_JSON); apiContext.addHTTPHeaders(headersMap); Tokeninfo tokeninfo = configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Tokeninfo.class, authorizationHeader); apiContext.setRequestId(null); return tokeninfo; } /** * Creates an Access Token from an Refresh Token. * * @param createFromRefreshTokenParameters * Query parameters used for API call * @return Tokeninfo * @throws PayPalRESTException */ public Tokeninfo createFromRefreshToken( CreateFromRefreshTokenParameters createFromRefreshTokenParameters) throws PayPalRESTException { return createFromRefreshToken(null, createFromRefreshTokenParameters); } /** * Creates an Access Token from an Refresh Token. * * @param apiContext * {@link APIContext} to be used for the call. * @param createFromRefreshTokenParameters * Query parameters used for API call * @return Tokeninfo * @throws PayPalRESTException */ public Tokeninfo createFromRefreshToken(APIContext apiContext, CreateFromRefreshTokenParameters createFromRefreshTokenParameters) throws PayPalRESTException { String pattern = "v1/identity/openidconnect/tokenservice?grant_type={0}&refresh_token={1}&scope={2}&client_id={3}&client_secret={4}"; Map<String, String> paramsMap = new HashMap<String, String>(); paramsMap.putAll(createFromRefreshTokenParameters.getContainerMap()); try { paramsMap.put("refresh_token", URLEncoder.encode(getRefreshToken(), Constants.ENCODING_FORMAT)); } catch (UnsupportedEncodingException ex) { // Ignore } Object[] parameters = new Object[] { paramsMap }; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = resourcePath.substring(resourcePath.indexOf('?') + 1); resourcePath = resourcePath.substring(0, resourcePath.indexOf('?')); if (apiContext == null) { apiContext = new APIContext(); } apiContext.setRequestId(null); Map<String, String> headersMap = new HashMap<String, String>(); if (createFromRefreshTokenParameters.getClientID() == null || createFromRefreshTokenParameters.getClientID().trim() .length() <= 0 || createFromRefreshTokenParameters.getClientSecret() == null || createFromRefreshTokenParameters.getClientSecret() .trim().length() <= 0) { throw new PayPalRESTException( "ClientID and ClientSecret not set in CreateFromRefreshTokenParameters"); } OAuthTokenCredential oauthTokenCredential = new OAuthTokenCredential( createFromRefreshTokenParameters.getClientID(), createFromRefreshTokenParameters.getClientSecret(), apiContext.getConfigurationMap()); String authorizationHeader = oauthTokenCredential .getAuthorizationHeader(); headersMap.put(Constants.AUTHORIZATION_HEADER, authorizationHeader); headersMap.put(Constants.HTTP_CONTENT_TYPE_HEADER, Constants.HTTP_CONFIG_DEFAULT_CONTENT_TYPE); apiContext.addHTTPHeaders(headersMap); Tokeninfo tokeninfo = configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Tokeninfo.class, authorizationHeader); apiContext.setRequestId(null); return tokeninfo; } /** * Creates an Access Token from an Refresh Token for future payment. * * @param apiContext * {@link APIContext} to be used for the call. * @return Tokeninfo * @throws PayPalRESTException */ public Tokeninfo createFromRefreshTokenForFpp(APIContext apiContext) throws PayPalRESTException { if (getRefreshToken() == null || getRefreshToken().equals("")) { throw new PayPalRESTException("refresh token is empty"); } String pattern = "v1/oauth2/token?refresh_token={0}&grant_type=refresh_token"; Map<String, String> paramsMap = new HashMap<String, String>(); try { paramsMap.put("refresh_token", URLEncoder.encode(getRefreshToken(), Constants.ENCODING_FORMAT)); } catch (UnsupportedEncodingException ex) { // Ignore } Object[] parameters = new Object[] { paramsMap }; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = resourcePath.substring(resourcePath.indexOf('?') + 1); resourcePath = resourcePath.substring(0, resourcePath.indexOf('?')); if (apiContext == null) { apiContext = new APIContext(); } apiContext.setRequestId(null); Map<String, String> headersMap = new HashMap<String, String>(); headersMap.put(Constants.HTTP_CONTENT_TYPE_HEADER, Constants.HTTP_CONFIG_DEFAULT_CONTENT_TYPE); apiContext.addHTTPHeaders(headersMap); Tokeninfo tokeninfo = configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Tokeninfo.class); apiContext.setRequestId(null); return tokeninfo; } }
3,873
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/openidconnect/Address.java
package com.paypal.api.openidconnect; import com.paypal.base.rest.PayPalModel; public class Address extends PayPalModel { /** * Full street address component, which may include house number, street name. */ private String streetAddress; /** * City or locality component. */ private String locality; /** * State, province, prefecture or region component. */ private String region; /** * Zip code or postal code component. */ private String postalCode; /** * Country name component. */ private String country; /** * Default Constructor */ public Address() { } /** * Setter for streetAddress * @param streetAddress */ public void setStreetAddress(String streetAddress) { this.streetAddress = streetAddress; } /** * Getter for streetAddress */ public String getStreetAddress() { return this.streetAddress; } /** * Setter for locality */ public void setLocality(String locality) { this.locality = locality; } /** * Getter for locality */ public String getLocality() { return this.locality; } /** * Setter for region */ public void setRegion(String region) { this.region = region; } /** * Getter for region */ public String getRegion() { return this.region; } /** * Setter for postalCode */ public void setPostalCode(String postalCode) { this.postalCode = postalCode; } /** * Getter for postalCode */ public String getPostalCode() { return this.postalCode; } /** * Setter for country */ public void setCountry(String country) { this.country = country; } /** * Getter for country */ public String getCountry() { return this.country; } }
3,874
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/openidconnect/Userinfo.java
package com.paypal.api.openidconnect; import com.paypal.base.Constants; import com.paypal.base.rest.APIContext; import com.paypal.base.rest.HttpMethod; import com.paypal.base.rest.PayPalRESTException; import com.paypal.base.rest.PayPalResource; import lombok.Getter; import lombok.Setter; import java.util.HashMap; /** * Class Userinfo * */ @Getter @Setter public class Userinfo extends PayPalResource{ /** * Subject - Identifier for the End-User at the Issuer. */ private String userId; /** * Subject - Identifier for the End-User at the Issuer. */ private String sub; /** * End-User's full name in displayable form including all name parts, possibly including titles and suffixes, ordered according to the End-User's locale and preferences. */ private String name; /** * Given name(s) or first name(s) of the End-User */ private String givenName; /** * Surname(s) or last name(s) of the End-User. */ private String familyName; /** * Middle name(s) of the End-User. */ private String middleName; /** * URL of the End-User's profile picture. */ private String picture; /** * End-User's preferred e-mail address. */ private String email; /** * True if the End-User's e-mail address has been verified; otherwise false. */ private Boolean emailVerified; /** * End-User's gender. */ private String gender; /** * End-User's birthday, represented as an YYYY-MM-DD format. They year MAY be 0000, indicating it is omited. To represent only the year, YYYY format would be used. */ private String birthday; /** * Time zone database representing the End-User's time zone */ private String zoneinfo; /** * End-User's locale. */ private String locale; /** * End-User's preferred telephone number. */ private String phoneNumber; /** * End-User's preferred address. */ private Address address; /** * Verified account status. */ private Boolean verifiedAccount; /** * Account type. */ private String accountType; /** * Account holder age range. */ private String ageRange; /** * Account payer identifier. */ private String payerId; /** * @return End-User's birthday, represented as an YYYY-MM-DD format * * @deprecated PayPal API returns 'birthday', use that instead */ @Deprecated public String getBirthdate() { return this.birthday; } /** * @param birthdate End-User's birthday, represented as an YYYY-MM-DD format * * @deprecated PayPal API returns 'birthday', use that instead */ @Deprecated public void setBirthdate(String birthdate) { this.birthday = birthdate; } /** * Returns user details * @deprecated Please use {@link #getUserinfo(APIContext)} instead. * * @param accessToken * access token * @return Userinfo * @throws PayPalRESTException */ public static Userinfo getUserinfo(String accessToken) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return getUserinfo(apiContext); } /** * Returns user details * * @param apiContext * {@link APIContext} to be used for the call. * @return Userinfo * @throws PayPalRESTException */ public static Userinfo getUserinfo(APIContext apiContext) throws PayPalRESTException { String resourcePath = "v1/identity/openidconnect/userinfo?schema=openid"; String payLoad = ""; String accessToken = apiContext.fetchAccessToken(); HashMap<String, String> httpHeaders = new HashMap<String, String>(); if (!accessToken.startsWith("Bearer ")) { accessToken = "Bearer " + accessToken; } httpHeaders.put(Constants.AUTHORIZATION_HEADER, accessToken); apiContext.addHTTPHeaders(httpHeaders); return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, Userinfo.class); } }
3,875
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/openidconnect/Session.java
package com.paypal.api.openidconnect; import com.paypal.base.ClientCredentials; import com.paypal.base.ConfigManager; import com.paypal.base.Constants; import com.paypal.base.SDKUtil; import com.paypal.base.rest.APIContext; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; import java.util.Map; public final class Session { private Session() { } /** * Returns the PayPal URL to which the user must be redirected to start the * authentication / authorization process. * * @param redirectURI * Uri on merchant website to where the user must be redirected * to post paypal login * * @param scope * The access privilges that you are requesting for from the * user. Pass empty array for all scopes. See * https://developer.paypal * .com/webapps/developer/docs/classic/loginwithpaypal * /ht_OpenIDConnect/#parameters for more information * * @param apiContext * {@link APIContext} to be used for the call. * @return Redirect URL */ public static String getRedirectURL(String redirectURI, List<String> scope, APIContext apiContext) { return getRedirectURL(redirectURI, scope, apiContext, null); } public static String getRedirectURL(String redirectURI, List<String> scope, APIContext apiContext, ClientCredentials clientCredentials) { String redirectURL = null; Map<String, String> configurationMap = null; try { if (apiContext.getConfigurationMap() == null) { configurationMap = SDKUtil.combineDefaultMap(ConfigManager .getInstance().getConfigurationMap()); } else { configurationMap = SDKUtil.combineDefaultMap(apiContext .getConfigurationMap()); } String baseURL = configurationMap .get(Constants.OPENID_REDIRECT_URI); if (baseURL == null || baseURL.trim().length() <= 0) { if (configurationMap.get(Constants.MODE) == null || (!Constants.LIVE.equalsIgnoreCase(configurationMap .get(Constants.MODE)) && !Constants.SANDBOX .equalsIgnoreCase(configurationMap .get(Constants.MODE)))) { throw new RuntimeException( "Mode parameter not set in dynamic configuration map"); } else { if (Constants.LIVE.equalsIgnoreCase(configurationMap .get(Constants.MODE))) { baseURL = Constants.OPENID_REDIRECT_URI_CONSTANT_LIVE; } else if (Constants.SANDBOX .equalsIgnoreCase(configurationMap .get(Constants.MODE))) { baseURL = Constants.OPENID_REDIRECT_URI_CONSTANT_SANDBOX; } } } if (scope == null || scope.size() <= 0) { scope = new ArrayList<String>(); scope.add("openid"); scope.add("profile"); scope.add("address"); scope.add("email"); scope.add("phone"); scope.add("https://uri.paypal.com/services/paypalattributes"); scope.add("https://uri.paypal.com/services/expresscheckout"); } if (!scope.contains("openid")) { scope.add("openid"); } StringBuilder stringBuilder = new StringBuilder(); // TODO revisit method while removing the similar method without // ClientCredentials; ClientID and ClientSecret should not be included // in configuration map - add them to the ClientCredentials class String clientID = null; if (clientCredentials == null) { clientID = configurationMap.get(Constants.CLIENT_ID) != null ? configurationMap .get(Constants.CLIENT_ID) : ""; } else { clientID = clientCredentials.getClientID() != null ? clientCredentials .getClientID() : ""; } stringBuilder .append("client_id=") .append(URLEncoder.encode(clientID, Constants.ENCODING_FORMAT)) .append("&response_type=").append("code").append("&scope="); StringBuilder scpBuilder = new StringBuilder(); for (String str : scope) { scpBuilder.append(str).append(" "); } stringBuilder.append(URLEncoder.encode(scpBuilder.toString(), Constants.ENCODING_FORMAT)); stringBuilder.append("&redirect_uri=").append( URLEncoder.encode(redirectURI, Constants.ENCODING_FORMAT)); redirectURL = baseURL + "/signin/authorize?" + stringBuilder.toString(); } catch (UnsupportedEncodingException exe) { // Ignore } return redirectURL; } /** * Returns the URL to which the user must be redirected to logout from the * OpenID provider (i.e. PayPal) * * @param redirectURI * URI on merchant website to where the user must be redirected * to post logout * @param idToken * id_token from the TokenInfo object * @param apiContext * {@link APIContext} to be used for the call. * @return Logout URL */ public static String getLogoutUrl(String redirectURI, String idToken, APIContext apiContext) { String logoutURL = null; Map<String, String> configurationMap = null; try { if (apiContext.getConfigurationMap() == null) { configurationMap = SDKUtil.combineDefaultMap(ConfigManager .getInstance().getConfigurationMap()); } else { configurationMap = SDKUtil.combineDefaultMap(apiContext .getConfigurationMap()); } String baseURL = configurationMap .get(Constants.OPENID_REDIRECT_URI); if (baseURL == null || baseURL.trim().length() <= 0) { if (configurationMap.get(Constants.MODE) == null || (!Constants.LIVE.equalsIgnoreCase(configurationMap .get(Constants.MODE)) && !Constants.SANDBOX .equalsIgnoreCase(configurationMap .get(Constants.MODE)))) { throw new RuntimeException( "Mode parameter not set in dynamic configuration map"); } else { if (Constants.LIVE.equalsIgnoreCase(configurationMap .get(Constants.MODE))) { baseURL = Constants.OPENID_REDIRECT_URI_CONSTANT_LIVE; } else if (Constants.SANDBOX .equalsIgnoreCase(configurationMap .get(Constants.MODE))) { baseURL = Constants.OPENID_REDIRECT_URI_CONSTANT_SANDBOX; } } } StringBuilder stringBuilder = new StringBuilder(); stringBuilder .append("id_token=") .append(URLEncoder.encode(idToken, Constants.ENCODING_FORMAT)) .append("&redirect_uri=") .append(URLEncoder.encode(redirectURI, Constants.ENCODING_FORMAT)).append("&logout=true"); logoutURL = baseURL + "/webapps/auth/protocol/openidconnect/v1/endsession?" + stringBuilder.toString(); } catch (UnsupportedEncodingException exe) { // Ignore } return logoutURL; } }
3,876
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/openidconnect/CreateFromAuthorizationCodeParameters.java
package com.paypal.api.openidconnect; import com.paypal.base.ClientCredentials; import java.util.HashMap; import java.util.Map; public class CreateFromAuthorizationCodeParameters extends ClientCredentials { /** * Code */ private static final String CODE = "code"; /** * Redirect URI */ private static final String REDIRECTURI = "redirect_uri"; /** * Grant Type */ private static final String GRANTTYPE = "grant_type"; // Map backing QueryParameters intended to processed // by SDK library 'RESTUtil' private Map<String, String> containerMap; public CreateFromAuthorizationCodeParameters() { containerMap = new HashMap<String, String>(); containerMap.put(GRANTTYPE, "authorization_code"); } /** * @return the containerMap */ public Map<String, String> getContainerMap() { return containerMap; } /** * Set the code * * @param code */ public void setCode(String code) { containerMap.put(CODE, code); } /** * Set the redirect URI * * @param redirectURI */ public void setRedirectURI(String redirectURI) { containerMap.put(REDIRECTURI, redirectURI); } /** * Set the Grant Type * * @param grantType */ public void setGrantType(String grantType) { containerMap.put(GRANTTYPE, grantType); } }
3,877
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/openidconnect/Error.java
package com.paypal.api.openidconnect; import com.paypal.base.rest.PayPalModel; public class Error extends PayPalModel { /** * A single ASCII error code from the following enum. */ private String error; /** * A resource ID that indicates the starting resource in the returned results. */ private String errorDescription; /** * A URI identifying a human-readable web page with information about the error, used to provide the client developer with additional information about the error. */ private String errorUri; /** * Default Constructor */ public Error() { } /** * Parameterized Constructor */ public Error(String error) { this.error = error; } /** * Setter for error */ public void setError(String error) { this.error = error; } /** * Getter for error */ public String getError() { return this.error; } /** * Setter for errorDescription */ public void setErrorDescription(String errorDescription) { this.errorDescription = errorDescription; } /** * Getter for errorDescription */ public String getErrorDescription() { return this.errorDescription; } /** * Setter for errorUri */ public void setErrorUri(String errorUri) { this.errorUri = errorUri; } /** * Getter for errorUri */ public String getErrorUri() { return this.errorUri; } }
3,878
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/openidconnect/UserinfoParameters.java
package com.paypal.api.openidconnect; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; /** * Class UserinfoParameters * */ public class UserinfoParameters { /** * Schema */ private static final String SCHEMA = "schema"; /** * Access Token */ private static final String ACCESSTOKEN = "access_token"; // Map backing QueryParameters intended to processed // by SDK library 'RESTUtil' private Map<String, String> containerMap; /** * */ public UserinfoParameters() { containerMap = new HashMap<String, String>(); containerMap.put(SCHEMA, "openid"); } /** * @return the containerMap */ public Map<String, String> getContainerMap() { return containerMap; } /** * Set the accessToken * * @param accessToken */ public void setAccessToken(String accessToken) { try { containerMap.put(ACCESSTOKEN, URLEncoder.encode(accessToken, "UTF-8")); } catch (UnsupportedEncodingException e) { } } }
3,879
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/APICallPreHandler.java
package com.paypal.base; import com.paypal.base.exception.ClientActionRequiredException; import com.paypal.base.exception.OAuthException; import com.paypal.base.rest.OAuthTokenCredential; import java.util.Map; /** * <code>APICallPreHandler</code> defines a high level abstraction for call * specific operations. PayPal REST API is provided by {@link com.paypal.base.rest.RESTAPICallPreHandler} */ public interface APICallPreHandler { /** * Returns headers for HTTP call * * @return Map of headers with name and value * @throws OAuthException */ Map<String, String> getHeaderMap() throws OAuthException; /** * Returns the payload for the API call. The implementation should take care * in formatting the payload appropriately * * @return Payload as String */ String getPayLoad(); /** * Returns the endpoint for the API call. The implementation may calculate * the endpoint depending on parameters set on it. If no endpoint is found * in the passed configuration, then SANDBOX endpoints (hardcoded in * {@link Constants})are taken to be default for the API call. * * @return Endpoint String. */ String getEndPoint(); /** * Returns {@link OAuthTokenCredential} configured for the api call * * @return ICredential object */ OAuthTokenCredential getCredential(); /** * Validates settings and integrity before call * * @throws ClientActionRequiredException */ void validate() throws ClientActionRequiredException; /** * Return configurationMap * * @return configurationMap in this call pre-handler */ public Map<String, String> getConfigurationMap(); }
3,880
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/NVPUtil.java
package com.paypal.base; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; public final class NVPUtil { private NVPUtil() {} /** * Utility method used to decode the nvp response String * * @param nvpString * @return Map * @throws UnsupportedEncodingException */ public static Map<String, String> decode(String nvpString) throws UnsupportedEncodingException { String[] nmValPairs = nvpString.split("&"); Map<String, String> response = new HashMap<String, String>(); // parse the string and load into the object for (String nmVal : nmValPairs) { String[] field = nmVal.split("="); response.put( URLDecoder.decode(field[0], Constants.ENCODING_FORMAT), (field.length > 1) ? URLDecoder.decode(field[1].trim(), Constants.ENCODING_FORMAT) : ""); } return response; } /** * Utility method used to encode the value * * @param value * @return String * @throws UnsupportedEncodingException */ public static String encodeUrl(String value) throws UnsupportedEncodingException { return URLEncoder.encode(value, Constants.ENCODING_FORMAT); } }
3,881
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/HttpStatusCodes.java
package com.paypal.base; public class HttpStatusCodes { public static final int BAD_REQUEST = 400; }
3,882
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/DefaultHttpConnection.java
package com.paypal.base; import com.paypal.base.exception.SSLConfigurationException; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import java.io.IOException; import java.lang.reflect.Field; import java.net.*; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; /** * Wrapper class used for HttpsURLConnection * */ public class DefaultHttpConnection extends HttpConnection { /** * Secure Socket Layer context */ private SSLContext sslContext; public DefaultHttpConnection() { try { sslContext = SSLUtil.getSSLContext(null); } catch (SSLConfigurationException e) { throw new RuntimeException(e); } } public DefaultHttpConnection(SSLContext sslContext) { this.sslContext = sslContext; } @Override public void setupClientSSL(String certPath, String certKey) throws SSLConfigurationException { try { this.sslContext = SSLUtil.setupClientSSL(certPath, certKey); } catch (Exception e) { throw new SSLConfigurationException(e.getMessage(), e); } } @Override public void createAndconfigureHttpConnection( HttpConfiguration clientConfiguration) throws IOException { this.config = clientConfiguration; URL url = new URL(this.config.getEndPointUrl()); Proxy proxy = null; String proxyHost = this.config.getProxyHost(); int proxyPort = this.config.getProxyPort(); if ((proxyHost != null) && (proxyPort > 0)) { SocketAddress addr = new InetSocketAddress(proxyHost, proxyPort); proxy = new Proxy(Proxy.Type.HTTP, addr); } if (proxy != null) { this.connection = (HttpURLConnection) url.openConnection(proxy); } else { this.connection = (HttpURLConnection) url .openConnection(Proxy.NO_PROXY); } if (this.connection instanceof HttpsURLConnection) { ((HttpsURLConnection) this.connection) .setSSLSocketFactory(this.sslContext.getSocketFactory()); } if (this.config.getProxyUserName() != null && this.config.getProxyPassword() != null) { final String username = this.config.getProxyUserName(); final String password = this.config.getProxyPassword(); Authenticator authenticator = new DefaultPasswordAuthenticator( username, password); Authenticator.setDefault(authenticator); } System.setProperty("http.maxConnections", String.valueOf(this.config.getMaxHttpConnection())); System.setProperty("sun.net.http.errorstream.enableBuffering", "true"); this.connection.setDoInput(true); this.connection.setDoOutput(true); setRequestMethodViaJreBugWorkaround(this.connection, config.getHttpMethod()); this.connection.setConnectTimeout(this.config.getConnectionTimeout()); this.connection.setReadTimeout(this.config.getReadTimeout()); switch (config.getInstanceFollowRedirects()) { case NO_DO_NOT_FOLLOW_REDIRECT: connection.setInstanceFollowRedirects(false); break; case YES_FOLLOW_REDIRECT: connection.setInstanceFollowRedirects(true); break; } } /** * Workaround for a bug in {@code HttpURLConnection.setRequestMethod(String)} * The implementation of Sun/Oracle is throwing a {@code ProtocolException} * when the method is other than the HTTP/1.1 default methods. So to use {@code PATCH} * and others, we must apply this workaround. * * See issue http://java.net/jira/browse/JERSEY-639 */ private static void setRequestMethodViaJreBugWorkaround(final HttpURLConnection httpURLConnection, final String method) { try { httpURLConnection.setRequestMethod(method); // Check whether we are running on a buggy JRE } catch (final ProtocolException pe) { try { httpURLConnection.getClass(); AccessController .doPrivileged(new PrivilegedExceptionAction<Object>() { public Object run() throws NoSuchFieldException, IllegalAccessException { try { httpURLConnection.setRequestMethod(method); // Check whether we are running on a buggy // JRE } catch (final ProtocolException pe) { Class<?> connectionClass = httpURLConnection .getClass(); Field delegateField = null; try { delegateField = connectionClass .getDeclaredField("delegate"); delegateField.setAccessible(true); HttpURLConnection delegateConnection = (HttpURLConnection) delegateField .get(httpURLConnection); setRequestMethodViaJreBugWorkaround( delegateConnection, method); } catch (NoSuchFieldException e) { // Ignore for now, keep going } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } try { Field methodField; while (connectionClass != null) { try { methodField = connectionClass .getDeclaredField("method"); } catch (NoSuchFieldException e) { connectionClass = connectionClass .getSuperclass(); continue; } methodField.setAccessible(true); methodField.set(httpURLConnection, method); break; } } catch (final Exception e) { throw new RuntimeException(e); } } return null; } }); } catch (final PrivilegedActionException e) { final Throwable cause = e.getCause(); if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } else { throw new RuntimeException(cause); } } } } /** * Private class for password based authentication * */ private static class DefaultPasswordAuthenticator extends Authenticator { /** * Username */ private String userName; /** * Password */ private String password; public DefaultPasswordAuthenticator(String userName, String password) { this.userName = userName; this.password = password; } public PasswordAuthentication getPasswordAuthentication() { return (new PasswordAuthentication(userName, password.toCharArray())); } } }
3,883
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/GoogleAppEngineHttpConnection.java
package com.paypal.base; import com.paypal.base.exception.SSLConfigurationException; import com.paypal.base.exception.HttpErrorException; import com.paypal.base.exception.InvalidResponseDataException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.InputStream; import java.io.IOException; import java.net.HttpURLConnection; import java.net.Proxy; import java.net.URL; import java.util.Map; import java.util.HashMap; /** * A special HttpConnection for use on Google App Engine. * * In order to activate this feature, set 'http.GoogleAppEngine = true' in the * SDK config file. * */ public class GoogleAppEngineHttpConnection extends HttpConnection { private static final Logger log = LoggerFactory.getLogger(GoogleAppEngineHttpConnection.class); private String requestMethod = null; @Override public void setupClientSSL(String certPath, String certKey) throws SSLConfigurationException { if (certPath != null || certKey != null) { log.warn("The PayPal SDK cannot be used with client SSL on Google App Engine; configure the SDK to use a PayPal API Signature instead"); } } @Override public void createAndconfigureHttpConnection( HttpConfiguration clientConfiguration) throws IOException { this.config = clientConfiguration; URL url = new URL(this.config.getEndPointUrl()); // Google App Engine does not support the // javax.net.ssl.HttpsURLConnection class. // However, one can use use URL.openConnection() with a https:// URL and // it will // return an HttpURLConnection that is capable of retrieving HTTPS data. // see // https://groups.google.com/forum/?fromgroups#!topic/google-appengine-java/ZEskGLwyE_0 // Google App Engine does not require any proxy settings so we can skip // that configuration entirely. // Other Google issues that can be starred to add better support: // http://code.google.com/p/googleappengine/issues/detail?id=1036 this.connection = (HttpURLConnection) url .openConnection(Proxy.NO_PROXY); this.connection.setDoInput(true); this.connection.setDoOutput(true); if ("PATCH".equals(config.getHttpMethod().toUpperCase())) { this.connection.setRequestMethod("POST"); this.requestMethod = "PATCH"; } else { this.connection.setRequestMethod(config.getHttpMethod()); } this.connection.setConnectTimeout(this.config.getConnectionTimeout()); this.connection.setReadTimeout(this.config.getReadTimeout()); switch (config.getInstanceFollowRedirects()) { case NO_DO_NOT_FOLLOW_REDIRECT: connection.setInstanceFollowRedirects(false); break; case YES_FOLLOW_REDIRECT: connection.setInstanceFollowRedirects(true); break; } } @Override public InputStream executeWithStream(String url, String payload, Map<String, String> headers) throws InvalidResponseDataException, IOException, InterruptedException, HttpErrorException { Map<String, String> headersCopy = new HashMap<String, String>(headers); if (requestMethod != null) { headersCopy.put("X-HTTP-Method-Override", requestMethod); } return super.executeWithStream(url, payload, headersCopy); } }
3,884
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/ClientCredentials.java
package com.paypal.base; /** * <code>ClientCredentials</code> holds Client ID and Client Secret */ public class ClientCredentials { /** * Client ID */ private String clientID; /** * Client Secret */ private String clientSecret; public ClientCredentials() { super(); } /** * @return the clientID */ public String getClientID() { return clientID; } /** * @param clientID * the clientID to set */ public void setClientID(String clientID) { this.clientID = clientID; } /** * @return the clientSecret */ public String getClientSecret() { return clientSecret; } /** * @param clientSecret * the clientSecret to set */ public void setClientSecret(String clientSecret) { this.clientSecret = clientSecret; } }
3,885
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/ConfigManager.java
package com.paypal.base; import com.paypal.base.util.ResourceLoader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.security.AccessControlException; import java.util.*; /** * <code>ConfigManager</code> loads configuration from 'sdk_config.properties' * file found in the classpath. There are certain default parameters that the * system chooses to use if not seen a part of the configuration. They are * enumerated below with the defaults is parenthesis * * http.ConnectionTimeOut(5000 ms), http.Retry(2), http.ReadTimeOut(30000 ms), * http.MaxConnections(100), http.IPAddress(127.0.0.1), * http.GoogleAppEngine(false) * */ public final class ConfigManager { private static final Logger log = LoggerFactory.getLogger(ConfigManager.class); /** * Singleton instance variable */ private static ConfigManager conf; /** * Underlying property implementation */ private Properties properties; /** * Initialized notifier */ private boolean propertyLoaded = false; /** * Map View of internal {@link Properties} */ private Map<String, String> mapView = null; /** * Map View of internal Default {@link Properties} */ private static Map<String, String> defaultMapView = null; /** * Default {@link Properties} */ private static final Properties DEFAULT_PROPERTIES; // Initialize DEFAULT_PROPERTIES static { DEFAULT_PROPERTIES = new Properties(); DEFAULT_PROPERTIES.put(Constants.HTTP_CONNECTION_TIMEOUT, "5000"); DEFAULT_PROPERTIES.put(Constants.HTTP_CONNECTION_RETRY, "2"); DEFAULT_PROPERTIES.put(Constants.HTTP_CONNECTION_READ_TIMEOUT, "30000"); DEFAULT_PROPERTIES.put(Constants.HTTP_CONNECTION_MAX_CONNECTION, "100"); DEFAULT_PROPERTIES.put(Constants.DEVICE_IP_ADDRESS, "127.0.0.1"); DEFAULT_PROPERTIES.put(Constants.GOOGLE_APP_ENGINE, "false"); DEFAULT_PROPERTIES.put(Constants.SSLUTIL_JRE, "SunJSSE"); DEFAULT_PROPERTIES.put(Constants.SSLUTIL_PROTOCOL, "TLS"); DEFAULT_PROPERTIES.put(Constants.PAYPAL_TRUST_CERT_URL, "DigiCertSHA2ExtendedValidationServerCA.crt"); DEFAULT_PROPERTIES.put(Constants.PAYPAL_WEBHOOK_CERTIFICATE_AUTHTYPE, "RSA"); defaultMapView = new HashMap<String, String>(); for (Object object : DEFAULT_PROPERTIES.keySet()) { defaultMapView.put(object.toString().trim(), DEFAULT_PROPERTIES .getProperty(object.toString()).trim()); } } /** * Private constructor */ private ConfigManager() { /* * Load configuration for default 'sdk_config.properties' */ ResourceLoader resourceLoader = new ResourceLoader( Constants.DEFAULT_CONFIGURATION_FILE); properties = new Properties(); try { InputStream inputStream = resourceLoader.getInputStream(); properties.load(inputStream); } catch (IOException e) { // We tried reading the config, but it seems like you dont have it. Skipping... log.debug(Constants.DEFAULT_CONFIGURATION_FILE + " not present. Skipping..."); } catch (AccessControlException e) { log.debug("Unable to read " + Constants.DEFAULT_CONFIGURATION_FILE + ". Skipping..."); } finally { setPropertyLoaded(true); } } /** * Singleton accessor method * * @return ConfigManager object */ public static ConfigManager getInstance() { synchronized (ConfigManager.class) { if (conf == null) { conf = new ConfigManager(); } } return conf; } /** * Returns the Default {@link Properties} of System Configuration * * @return Default {@link Properties} */ public static Properties getDefaultProperties() { return DEFAULT_PROPERTIES; } /** * Returns a {@link Map} view of Default {@link Properties} * * @return {@link Map} view of Default {@link Properties} */ public static Map<String, String> getDefaultSDKMap() { return new HashMap<String, String>(defaultMapView); } /** * Combines some {@link Properties} with Default {@link Properties} * * @param receivedProperties * Properties used to combine with Default {@link Properties} * * @return Combined {@link Properties} */ public static Properties combineDefaultProperties( Properties receivedProperties) { Properties combinedProperties = new Properties(getDefaultProperties()); if ((receivedProperties != null) && (receivedProperties.size() > 0)) { ByteArrayOutputStream bos = new ByteArrayOutputStream(1024); try { receivedProperties.store(bos, null); combinedProperties.load(new ByteArrayInputStream(bos .toByteArray())); } catch (IOException e) { // Something failed trying to load the properties. Skipping... } } return combinedProperties; } /** * Loads the internal properties with the passed {@link InputStream} * * @deprecated This code was used for older integrations. Not valid anymore. To be removed in the next major release. * @param is * InputStream * * @throws IOException */ public void load(InputStream is) throws IOException { properties = new Properties(); properties.load(is); if (!propertyLoaded) { setPropertyLoaded(true); } } /** * Initializes the internal properties with the passed {@link Properties} * instance * * @deprecated This code was used for older integrations. Not valid anymore. To be removed in the next major release. * @param properties * Properties instance * */ public void load(Properties properties) { if (properties == null) { throw new IllegalArgumentException( "Initialization properties cannot be null"); } this.properties = properties; if (!propertyLoaded) { setPropertyLoaded(true); } } /** * Constructs a {@link Map} object from the underlying {@link Properties}. * The {@link Properties} object is loaded for 'sdk_config.properties' file * in the classpath * * @return {@link Map} */ public Map<String, String> getConfigurationMap() { if (mapView == null) { synchronized (DEFAULT_PROPERTIES) { mapView = new HashMap<String, String>(); if (properties != null) { for (Object object : properties.keySet()) { mapView.put(object.toString().trim(), properties .getProperty(object.toString()).trim()); } } } } return new HashMap<String, String>(mapView); } /** * Returns a value for the corresponding key * * @deprecated This code was used for older integrations. Not valid anymore. To be removed in the next major release. * * @param key * String key * @return String value */ public String getValue(String key) { return properties.getProperty(key); } /** * Mimics the call to {@link Properties}.getProperty(key, defaultValue) * * @deprecated This code was used for older integrations. Not valid anymore. To be removed in the next major release. * * @param key * String key to search in properties file * @param defaultValue * Default value to be sent in case of a miss * @return String value corresponding to the key or default value */ public String getValueWithDefault(String key, String defaultValue) { return properties.getProperty(key, defaultValue); } /** * Gets all the values in the particular category in configuration (eg: * acct) * * @deprecated This code was used for older integrations. Not valid anymore. To be removed in the next major release. * * @param category * @return Map */ public Map<String, String> getValuesByCategory(String category) { String key; HashMap<String, String> map = new HashMap<String, String>(); for (Object obj : properties.keySet()) { key = (String) obj; if (key.contains(category)) { map.put(key, properties.getProperty(key)); } } return map; } /** * Returns the key prefixes for all configured accounts * * @deprecated This code is not used anymore. This was used for older sdk_config.properties parsing. * * @return {@link Set} of Accounts */ public Set<String> getNumOfAcct() { String key; Set<String> set = new HashSet<String>(); for (Object obj : properties.keySet()) { key = (String) obj; if (key.contains("acct")) { int pos = key.indexOf('.'); String acct = key.substring(0, pos); set.add(acct); } } return set; } /** * @deprecated This code was used for older integrations. Not valid anymore. To be removed in the next major release. * @return boolean */ public boolean isPropertyLoaded() { return propertyLoaded; } private void setPropertyLoaded(boolean propertyLoaded) { this.propertyLoaded = propertyLoaded; } }
3,886
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/APICallPreHandlerFactory.java
package com.paypal.base; /** * APICallPreHandlerFactory factory for returning implementations if * {@link APICallPreHandler} * */ public interface APICallPreHandlerFactory { /** * Creates an instance of {@link APICallPreHandler} * * @return APICallPreHandler */ APICallPreHandler createAPICallPreHandler(); }
3,887
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/SDKUtil.java
package com.paypal.base; import com.paypal.base.rest.PayPalRESTException; import java.util.*; import java.util.Map.Entry; /** * SDKUtil class holds utility methods for processing data transformation * */ public final class SDKUtil { private SDKUtil() { } /** * Constructs a Map<String, String> from a {@link Properties} object by * combining the default values. See {@link ConfigManager} for default * values * * @param properties * Input {@link Properties} * @return Map<String, String> */ public static Map<String, String> constructMap(Properties properties) { Properties combinedProperties = ConfigManager.combineDefaultProperties(properties); Map<String, String> propsMap = new HashMap<String, String>(); // Since the default properties are only searchable Enumeration<?> keys = combinedProperties.propertyNames(); while (keys.hasMoreElements()) { String key = keys.nextElement().toString().trim(); String value = combinedProperties.getProperty(key).trim(); propsMap.put(key, value); } return propsMap; } /** * Combines some {@link Map} with default values. See {@link ConfigManager} * for default values. * * @param receivedMap * {@link Map} used to combine with Default {@link Map} * @return Combined {@link Map} */ public static Map<String, String> combineDefaultMap(Map<String, String> receivedMap) { return combineMap(receivedMap, ConfigManager.getDefaultSDKMap()); } public static Map<String, String> combineMap(Map<String, String> highMap, Map<String, String> lowMap) { lowMap = lowMap != null ? lowMap : new HashMap<String, String>(); highMap = highMap != null ? highMap : new HashMap<String, String>(); lowMap.putAll(highMap); return lowMap; } /** * Utility method to validate if the key exists in the provided map, and * returns string value of the object * * @param map * Map of String based key and values * @param key * object to be found in the key * @return String value of the key * @throws PayPalRESTException */ public static String validateAndGet(Map<String, String> map, String key) throws PayPalRESTException { if (map == null || key == null) { throw new PayPalRESTException("Map or Key cannot be null"); } String value = map.get(key); if (value == null || value.equals("")) { for (Iterator<Entry<String, String>> itemIter = map.entrySet().iterator(); itemIter.hasNext();) { Entry<String, String> entry = itemIter.next(); if (entry.getKey().equalsIgnoreCase(key)) { value = entry.getValue(); break; } } if (value == null || value.equals("")) { throw new PayPalRESTException(key + " cannot be null"); } } return value; } }
3,888
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/ConnectionManager.java
package com.paypal.base; import javax.net.ssl.SSLContext; /** * ConnectionManager acts as a interface to retrieve {@link HttpConnection} * objects used by API service * */ public final class ConnectionManager { /** * Singleton instance */ private static ConnectionManager instance; private SSLContext customSslContext; // Private Constructor private ConnectionManager() { } /** * Singleton accessor method * * @return {@link ConnectionManager} singleton object */ public static ConnectionManager getInstance() { synchronized (ConnectionManager.class) { if (instance == null) { instance = new ConnectionManager(); } } return instance; } /** * @return HttpConnection object */ public HttpConnection getConnection() { if(customSslContext != null) { return new DefaultHttpConnection(customSslContext); } else { return new DefaultHttpConnection(); } } /** * Overloaded method used factory to load GoogleAppEngineSpecific connection * * @param httpConfig * {@link HttpConfiguration} object * @return {@link HttpConnection} object */ public HttpConnection getConnection(HttpConfiguration httpConfig) { if (httpConfig.isGoogleAppEngine()) { return new GoogleAppEngineHttpConnection(); } else { return getConnection(); } } /** * * @param sslContext an custom {@link SSLContext} to set to all new connections. * If null, the default SSLContext will be recovered each new connection.<br> *<pre> * * {@literal // On application startup...} * public static void main({@link String}[] args) { * {@link SSLContext} sslContext = {@link SSLContext}.getDefault(); * {@literal // Or provide your custom context.} * * {@link ConnectionManager}.getInstance().configureCustomSslContext(sslContext); * {@literal // Now all connections will use this ssl context except if the authentication method is with certificate credential.} * } * *</pre> */ public void configureCustomSslContext(SSLContext sslContext) { customSslContext = sslContext; } }
3,889
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/HttpConfiguration.java
package com.paypal.base; /** * * Class contains http specific configuration parameters * */ public class HttpConfiguration { /** * Maximum retries on failure */ private int maxRetry; /** * Use PROXY configuration */ private boolean proxySet; /** * PROXY host */ private String proxyHost; /** * PROXY port */ private int proxyPort; /** * PROXY username */ private String proxyUserName; /** * PROXY password */ private String proxyPassword; /** * Connection read timeout */ private int readTimeout; /** * Connection timeout */ private int connectionTimeout; /** * Maximum HTTP connections */ private int maxHttpConnection; /** * End point URL */ private String endPointUrl; /** * Google App Engine (Use {@link GoogleAppEngineHttpConnection}) */ private boolean googleAppEngine; /** * Delay used for retry mechanism */ private int retryDelay; /** * IP Address */ private String ipAddress; /** * HTTP method, defaulted to HTTP POST */ private String httpMethod; /** * Whether 3xx redirects whould be followed. Default is true to preserve existing behavior */ private FollowRedirect followRedirects = FollowRedirect.DEFAULT; enum FollowRedirect { YES_FOLLOW_REDIRECT, NO_DO_NOT_FOLLOW_REDIRECT, DEFAULT // use whatever was already configured for static followRedirects in HttpURLConnection class } /** * HTTP Content Type value, defaulted to 'application/x-www-form-urlencoded' * @deprecated Set Content-Type in HTTP Headers property of {@link com.paypal.base.rest.APIContext} */ private String contentType; public String getIpAddress() { return ipAddress; } public void setIpAddress(String ipAddress) { this.ipAddress = ipAddress; } public HttpConfiguration() { this.maxRetry = 2; this.proxySet = false; this.proxyHost = null; this.proxyPort = -1; this.proxyUserName = null; this.proxyPassword = null; this.readTimeout = 0; this.connectionTimeout = 0; this.maxHttpConnection = 10; this.endPointUrl = null; this.retryDelay = 1000; this.ipAddress = "127.0.0.1"; this.httpMethod = Constants.HTTP_CONFIG_DEFAULT_HTTP_METHOD; } /** * @return the proxyUserName */ public String getProxyUserName() { return proxyUserName; } /** * Sets the proxyUserName * * @param proxyUserName */ public void setProxyUserName(String proxyUserName) { this.proxyUserName = proxyUserName; } /** * @return the proxyPassword */ public String getProxyPassword() { return proxyPassword; } /** * Sets the proxyPassword * * @param proxyPassword */ public void setProxyPassword(String proxyPassword) { this.proxyPassword = proxyPassword; } /** * @return the maxHttpConnection */ public int getMaxHttpConnection() { return maxHttpConnection; } /** * Sets the maxHttpConnection * * @param maxHttpConnection */ public void setMaxHttpConnection(int maxHttpConnection) { this.maxHttpConnection = maxHttpConnection; } /** * @return the retryDelay */ public int getRetryDelay() { return retryDelay; } /** * Sets the retryDelay * * @param retryDelay */ public void setRetryDelay(int retryDelay) { this.retryDelay = retryDelay; } /** * @return the endPointUrl */ public String getEndPointUrl() { return endPointUrl; } /** * Sets the endPointUrl * * @param endPointUrl */ public void setEndPointUrl(String endPointUrl) { this.endPointUrl = endPointUrl; } /** * @return the maxRetry */ public int getMaxRetry() { return maxRetry; } /** * Sets the maxRetry * * @param maxRetry */ public void setMaxRetry(int maxRetry) { this.maxRetry = maxRetry; } /** * @return the proxyHost */ public String getProxyHost() { return proxyHost; } /** * Sets the proxyHost * * @param proxyHost */ public void setProxyHost(String proxyHost) { this.proxyHost = proxyHost; } /** * @return the proxyPort */ public int getProxyPort() { return proxyPort; } /** * Sets the proxyPort * * @param proxyPort */ public void setProxyPort(int proxyPort) { this.proxyPort = proxyPort; } /** * @return the readTimeout */ public int getReadTimeout() { return readTimeout; } /** * Sets the readTimeout * * @param readTimeout */ public void setReadTimeout(int readTimeout) { this.readTimeout = readTimeout; } /** * @return the connectionTimeout */ public int getConnectionTimeout() { return connectionTimeout; } /** * Sets the connectionTimeout * * @param connectionTimeout */ public void setConnectionTimeout(int connectionTimeout) { this.connectionTimeout = connectionTimeout; } /** * @return the proxySet */ public boolean isProxySet() { return proxySet; } /** * Sets the proxySet * * @param proxySet */ public void setProxySet(boolean proxySet) { this.proxySet = proxySet; } /** * @return the googleAppEngine */ public boolean isGoogleAppEngine() { return googleAppEngine; } /** * Sets the googleAppEngine * * @param googleAppEngine */ public void setGoogleAppEngine(boolean googleAppEngine) { this.googleAppEngine = googleAppEngine; } /** * @return the httpMethod */ public String getHttpMethod() { return httpMethod; } /** * @param httpMethod * the httpMethod to set */ public void setHttpMethod(String httpMethod) { this.httpMethod = httpMethod; } // Gets whether HTTP redirects (requests with response code 3xx) should be automatically followed public FollowRedirect getInstanceFollowRedirects() { return followRedirects; } // Sets whether HTTP redirects (requests with response code 3xx) should be automatically followed public void setInstanceFollowRedirects(FollowRedirect followRedirects) { this.followRedirects = followRedirects; } /** * @deprecated Set/Get Content-Type HTTP Header in {@link com.paypal.base.rest.APIContext} HTTPHeaders parameter * @return the contentType */ public String getContentType() { return contentType; } /** * @deprecated Set/Get Content-Type HTTP Header in {@link com.paypal.base.rest.APIContext} HTTPHeaders parameter * @param contentType * the contentType to set */ public void setContentType(String contentType) { this.contentType = contentType; } }
3,890
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/SSLUtil.java
package com.paypal.base; import com.paypal.base.codec.binary.Base64; import com.paypal.base.exception.SSLConfigurationException; import com.paypal.base.rest.PayPalRESTException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.net.ssl.*; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.URL; import java.security.*; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.util.*; import java.util.zip.CRC32; import java.util.zip.Checksum; /** * Class SSLUtil * */ public abstract class SSLUtil { private static final Logger log = LoggerFactory.getLogger(SSLUtil.class); /** * KeyManagerFactory used for {@link SSLContext} {@link KeyManager} */ private static final KeyManagerFactory KMF; /** * Private {@link Map} used for caching {@link KeyStore}s */ private static final Map<String, KeyStore> STOREMAP; /** * Map used for dynamic configuration */ private static final Map<String, String> CONFIG_MAP; static { try { // Initialize KeyManagerFactory and local KeyStore cache KMF = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); STOREMAP = new HashMap<String, KeyStore>(); CONFIG_MAP = SDKUtil.combineDefaultMap(ConfigManager .getInstance().getConfigurationMap()); } catch (NoSuchAlgorithmException e) { throw new ExceptionInInitializerError(e); } } /** * Returns a SSLContext * * @param keymanagers * KeyManager[] The key managers * @return SSLContext with proper client certificate * @throws SSLConfigurationException */ public static SSLContext getSSLContext(KeyManager[] keymanagers) throws SSLConfigurationException { try { SSLContext ctx = null; String protocol = CONFIG_MAP.get(Constants.SSLUTIL_PROTOCOL); try { ctx = SSLContext.getInstance("TLSv1.2"); } catch (NoSuchAlgorithmException e) { log.warn("WARNING: Your system does not support TLSv1.2. Per PCI Security Council mandate (https://github.com/paypal/TLS-update), you MUST update to latest security library."); ctx = SSLContext.getInstance(protocol); } ctx.init(keymanagers, null, null); return ctx; } catch (Exception e) { throw new SSLConfigurationException(e.getMessage(), e); } } /** * Retrieves keyStore from the cached {@link Map}, if not present loads * certificate into java keyStore and caches it for further references * * @param p12Path * Path to the client certificate * @param password * {@link KeyStore} password * @return keyStore {@link KeyStore} loaded with the certificate * @throws NoSuchProviderException * @throws KeyStoreException * @throws CertificateException * @throws NoSuchAlgorithmException * @throws FileNotFoundException * @throws IOException */ private static KeyStore p12ToKeyStore(String p12Path, String password) throws NoSuchProviderException, KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException { KeyStore keyStore = STOREMAP.get(p12Path); if (keyStore == null) { keyStore = KeyStore.getInstance("PKCS12", CONFIG_MAP.get(Constants.SSLUTIL_JRE)); FileInputStream in = null; try { in = new FileInputStream(p12Path); keyStore.load(in, password.toCharArray()); STOREMAP.put(p12Path, keyStore); } finally { if (in != null) { in.close(); } } } return keyStore; } /** * Create a SSLContext with provided client certificate * * @param certPath * @param certPassword * @return SSLContext * @throws SSLConfigurationException */ public static SSLContext setupClientSSL(String certPath, String certPassword) throws SSLConfigurationException { SSLContext sslContext = null; try { KeyStore ks = p12ToKeyStore(certPath, certPassword); KMF.init(ks, certPassword.toCharArray()); sslContext = getSSLContext(KMF.getKeyManagers()); } catch (NoSuchAlgorithmException e) { throw new SSLConfigurationException(e.getMessage(), e); } catch (KeyStoreException e) { throw new SSLConfigurationException(e.getMessage(), e); } catch (UnrecoverableKeyException e) { throw new SSLConfigurationException(e.getMessage(), e); } catch (CertificateException e) { throw new SSLConfigurationException(e.getMessage(), e); } catch (NoSuchProviderException e) { throw new SSLConfigurationException(e.getMessage(), e); } catch (IOException e) { throw new SSLConfigurationException(e.getMessage(), e); } return sslContext; } /** * Performs Certificate Chain Validation on provided certificates. The method verifies if the client certificates provided are generated from root certificates * trusted by application. * * @param clientCerts Collection of X509Certificates provided in request * @param trustCerts Collection of X509Certificates trusted by application * @param authType Auth Type for Certificate * @return true if client and server are chained together, false otherwise * @throws PayPalRESTException */ public static boolean validateCertificateChain(Collection<X509Certificate> clientCerts, Collection<X509Certificate> trustCerts, String authType) throws PayPalRESTException { TrustManager trustManagers[]; X509Certificate[] clientChain; try { clientChain = clientCerts.toArray(new X509Certificate[0]); List<X509Certificate> list = Arrays.asList(clientChain); clientChain = list.toArray(new X509Certificate[0]); // Create a Keystore and load the Root CA Cert KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); keyStore.load(null, "".toCharArray()); // Iterate through each certificate and add to keystore int i = 0; for (Iterator<X509Certificate> payPalCertificate = trustCerts.iterator(); payPalCertificate.hasNext();) { X509Certificate x509Certificate = (X509Certificate) payPalCertificate.next(); keyStore.setCertificateEntry("paypalCert" + i, x509Certificate); i++; } // Create TrustManager TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(keyStore); trustManagers = trustManagerFactory.getTrustManagers(); } catch (Exception ex) { throw new PayPalRESTException(ex); } // For Each TrustManager of type X509 for(TrustManager trustManager : trustManagers) { if(trustManager instanceof X509TrustManager) { X509TrustManager pkixTrustManager = (X509TrustManager) trustManager; // Check the trust manager if server is trusted try { pkixTrustManager.checkClientTrusted(clientChain, (authType == null || authType == "") ? "RSA" : authType); // Checks that the certificate is currently valid. It is if the current date and time are within the validity period given in the certificate. for (X509Certificate cert : clientChain) { cert.checkValidity(); // Check for CN name matching String dn = cert.getSubjectX500Principal().getName(); String[] tokens = dn.split(","); boolean hasPaypalCn = false; for (String token: tokens) { if (token.startsWith("CN=messageverificationcerts") && token.endsWith(".paypal.com")) { hasPaypalCn = true; } } if (!hasPaypalCn) { throw new PayPalRESTException("CN of client certificate does not match with trusted CN"); } } // If everything looks good, return true return true; } catch (CertificateException e) { throw new PayPalRESTException(e); } } } return false; } /** * Downloads Certificate from URL * @deprecated Please use {@link #downloadCertificateFromPath(String, Map)} instead. * * @param urlPath * @return InputStream containing certificate data * @throws PayPalRESTException */ public static InputStream downloadCertificateFromPath(String urlPath) throws PayPalRESTException { return downloadCertificateFromPath(urlPath, ConfigManager.getDefaultSDKMap()); } /** * Downloads Certificate from URL * * @param urlPath * @param configurations Map of configurations. * @return InputStream containing certificate data * @throws PayPalRESTException */ public static InputStream downloadCertificateFromPath(String urlPath, Map<String, String> configurations) throws PayPalRESTException { if (urlPath == null || urlPath.trim() == "") { throw new PayPalRESTException("Certificate Path cannot be empty"); } try { Map<String, String> headerMap = new HashMap<String, String>(); HttpConfiguration httpConfiguration = generateHttpConfiguration(urlPath, configurations); HttpConnection connection = ConnectionManager.getInstance().getConnection(); connection.createAndconfigureHttpConnection(httpConfiguration); URL url = new URL(urlPath); headerMap.put("Host", url.getHost()); return connection.executeWithStream(url.toString(), "", headerMap); } catch (Exception ex) { throw new PayPalRESTException(ex); } } private static HttpConfiguration generateHttpConfiguration(final String urlPath, final Map<String, String> configurations) { HttpConfiguration httpConfiguration = new HttpConfiguration(); httpConfiguration.setEndPointUrl(urlPath); httpConfiguration.setConnectionTimeout(Integer.parseInt(configurations.get(Constants.HTTP_CONNECTION_TIMEOUT))); httpConfiguration.setMaxRetry(Integer.parseInt(configurations.get(Constants.HTTP_CONNECTION_RETRY))); httpConfiguration.setReadTimeout(Integer.parseInt(configurations.get(Constants.HTTP_CONNECTION_READ_TIMEOUT))); httpConfiguration.setMaxHttpConnection(Integer.parseInt(configurations.get(Constants.HTTP_CONNECTION_MAX_CONNECTION))); httpConfiguration.setHttpMethod("GET"); boolean useProxy = Boolean.parseBoolean(configurations.get(Constants.USE_HTTP_PROXY)); if(useProxy) { httpConfiguration.setProxySet(useProxy); httpConfiguration.setProxyHost(configurations.get(Constants.HTTP_PROXY_HOST)); httpConfiguration.setProxyPort(Integer.parseInt(configurations.get(Constants.HTTP_PROXY_PORT))); String proxyUserName = configurations.get(Constants.HTTP_PROXY_USERNAME); if(proxyUserName != null) { httpConfiguration.setProxyUserName(proxyUserName); httpConfiguration.setProxyPassword(configurations.get(Constants.HTTP_PROXY_PASSWORD)); } } return httpConfiguration; } /** * Generate Collection of Certificate from Input Stream * * @param stream InputStream of Certificate data * @return Collection<X509Certificate> * @throws PayPalRESTException */ @SuppressWarnings("unchecked") public static Collection<X509Certificate> getCertificateFromStream(InputStream stream) throws PayPalRESTException { if (stream == null) { throw new PayPalRESTException("Certificate Not Found"); } Collection<X509Certificate> certs = null; try { // Create a Certificate Factory CertificateFactory cf = CertificateFactory.getInstance("X.509"); // Read the Trust Certs certs = (Collection<X509Certificate>) cf.generateCertificates(stream); } catch (CertificateException ex) { throw new PayPalRESTException(ex); } return certs; } /** * Generates a CRC 32 Value of String passed * * @param data * @return long crc32 value of input. -1 if string is null * @throws RuntimeException if UTF-8 is not a supported character set */ public static long crc32(String data) { if (data == null) { return -1; } try { // get bytes from string byte bytes[] = data.getBytes("UTF-8"); Checksum checksum = new CRC32(); // update the current checksum with the specified array of bytes checksum.update(bytes, 0, bytes.length); // get the current checksum value return checksum.getValue(); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } /** * Validates Webhook Signature validation based on https://developer.paypal.com/docs/integration/direct/rest-webhooks-overview/#event-signature * Returns true if signature is valid * * @param clientCerts Client Certificates * @param algo Algorithm used for signature creation by server * @param actualSignatureEncoded Paypal-Transmission-Sig header value passed by server * @param expectedSignature Signature generated by formatting data with CRC32 value of request body * @param requestBody Request body from server * @param webhookId Id for PayPal Webhook created for receiving the data * @return true if signature is valid, false otherwise * * @throws NoSuchAlgorithmException * @throws SignatureException * @throws InvalidKeyException */ public static Boolean validateData(Collection<X509Certificate> clientCerts, String algo, String actualSignatureEncoded, String expectedSignature, String requestBody, String webhookId) throws NoSuchAlgorithmException, SignatureException, InvalidKeyException { // Get the signatureAlgorithm from the PAYPAL-AUTH-ALGO HTTP header Signature signatureAlgorithm = Signature.getInstance(algo); // Get the certData from the URL provided in the HTTP headers and cache it X509Certificate[] clientChain = clientCerts.toArray(new X509Certificate[0]); signatureAlgorithm.initVerify(clientChain[0].getPublicKey()); signatureAlgorithm.update(expectedSignature.getBytes()); // Actual signature is base 64 encoded and available in the HTTP headers byte[] actualSignature = Base64.decodeBase64(actualSignatureEncoded.getBytes()); boolean isValid = signatureAlgorithm.verify(actualSignature); return isValid; } }
3,891
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/SDKVersion.java
package com.paypal.base; public interface SDKVersion { /** * Returns the SDK Id * @return String */ String getSDKId(); /** * Returns the SDK Version * @return String */ String getSDKVersion(); }
3,892
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/HttpConnection.java
package com.paypal.base; import com.paypal.base.exception.ClientActionRequiredException; import com.paypal.base.exception.HttpErrorException; import com.paypal.base.exception.InvalidResponseDataException; import com.paypal.base.exception.SSLConfigurationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.*; import java.net.HttpURLConnection; import java.nio.charset.Charset; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Map; /** * Base HttpConnection class * */ public abstract class HttpConnection { private static final Logger log = LoggerFactory .getLogger(HttpConnection.class); /** * Subclasses must set the http configuration in the * createAndconfigureHttpConnection() method. */ protected HttpConfiguration config; /** * Subclasses must create and set the connection in the * createAndconfigureHttpConnection() method. */ protected HttpURLConnection connection; public HttpConnection() { } public Map<String, List<String>> getResponseHeaderMap() { return connection.getHeaderFields(); } /** * Executes HTTP request * * @param url * @param payload * @param headers * @return String response * @throws InvalidResponseDataException * @throws IOException * @throws InterruptedException * @throws HttpErrorException * @throws ClientActionRequiredException */ public String execute(String url, String payload, Map<String, String> headers) throws InvalidResponseDataException, IOException, InterruptedException, HttpErrorException { BufferedReader reader; String successResponse; InputStream result = executeWithStream(url, payload, headers); reader = new BufferedReader(new InputStreamReader(result, Constants.ENCODING_FORMAT)); successResponse = read(reader); return successResponse; } /** * Executes HTTP request * * @param url URL for the connection * @param payload Request payload * @param headers Headers map * @return String response * @throws InvalidResponseDataException * @throws IOException * @throws InterruptedException * @throws HttpErrorException * @throws ClientActionRequiredException */ public InputStream executeWithStream(String url, String payload, Map<String, String> headers) throws InvalidResponseDataException, IOException, InterruptedException, HttpErrorException { InputStream successResponse = null; String errorResponse = null; int responseCode = -1; BufferedReader reader = null; OutputStreamWriter writer = null; connection.setRequestProperty("Content-Length", String.valueOf(payload.trim().length())); try { setHttpHeaders(headers); String mode = ConfigManager.getInstance().getConfigurationMap() .get(Constants.MODE); // Print if on live if (!Constants.LIVE.equalsIgnoreCase(mode)) { logCurlRequest(payload, headers); } // This exception is used to make final log more explicit Exception lastException = null; int retry = 0; retryLoop: do { try { if (Arrays.asList("POST", "PUT", "PATCH").contains(connection.getRequestMethod().toUpperCase())) { writer = new OutputStreamWriter( this.connection.getOutputStream(), Charset.forName(Constants.ENCODING_FORMAT)); writer.write(payload); writer.flush(); } responseCode = connection.getResponseCode(); // SUCCESS if (responseCode >= 200 && responseCode < 300) { try { successResponse = connection.getInputStream(); } catch (IOException e) { successResponse = connection.getErrorStream(); } break retryLoop; } // FAILURE InputStream responseStream = null; if (responseCode >= 400) { responseStream = connection.getErrorStream(); } else if (responseCode >= 200 && responseCode < 400) { responseStream = connection.getInputStream(); } if (responseStream != null) { reader = new BufferedReader(new InputStreamReader( responseStream, Constants.ENCODING_FORMAT)); errorResponse = read(reader); } String msg = "Response code: " + responseCode + "\tError response: " + errorResponse; if (responseCode >= 300 && responseCode < 500) { // CLIENT SIDE EXCEPTION throw new ClientActionRequiredException(responseCode, errorResponse, msg, new IOException(msg)); } else if (responseCode >= 500) { // SERVER SIDE EXCEPTION throw new HttpErrorException(responseCode, errorResponse, msg, new IOException(msg)); } } catch (IOException e) { lastException = e; try { // responseCode = connection.getResponseCode(); responseCode = -1; if (connection.getErrorStream() != null) { reader = new BufferedReader(new InputStreamReader( connection.getErrorStream(), Constants.ENCODING_FORMAT)); errorResponse = read(reader); log.error("Response code: " + responseCode + "\tError response: " + errorResponse); } if ((errorResponse == null) || (errorResponse.length() == 0)) { errorResponse = e.getMessage(); } if (responseCode <= 500) { String msg = "Response code: " + responseCode + "\tError response: " + errorResponse; throw new HttpErrorException(responseCode, errorResponse, msg, e); } } catch (HttpErrorException ex) { throw ex; } catch (Exception ex) { lastException = ex; log.error( "Caught exception while handling error response", ex); } } // RETRY LOGIC retry++; if (retry > 0) { log.error(" Retry No : " + retry + "..."); Thread.sleep(this.config.getRetryDelay()); } } while (retry < this.config.getMaxRetry()); if (successResponse == null || (successResponse.available() <= 0 && !(responseCode >= 200 && responseCode < 300))) { throw new HttpErrorException( "retry fails.. check log for more information", lastException); } } finally { try { if (reader != null) { reader.close(); } if (writer != null) { writer.close(); } } finally { reader = null; writer = null; } } return successResponse; } /** * Logs the curl format based request, which could be helpful for debugging purposes. * * @param payload Payload Data * @param headers Headers Map */ private void logCurlRequest(String payload, Map<String, String> headers) { StringBuilder cmdBuilder = new StringBuilder("curl command: \n"); cmdBuilder.append("curl --verbose"); cmdBuilder.append(" --request ").append(connection.getRequestMethod().toUpperCase()); cmdBuilder.append(" '").append(connection.getURL().toString()).append("'"); if (headers != null) { for (String key : headers.keySet()) { String value = headers.get(key); cmdBuilder.append(String.format(" \\\n --header \"%s:%s\"", key, value)); } } cmdBuilder.append(String.format(" \\\n --data '%s'", payload)); log.debug(cmdBuilder.toString()); } /** * Set ssl parameters for client authentication * * @param certPath * @param certKey * @throws SSLConfigurationException */ public abstract void setupClientSSL(String certPath, String certKey) throws SSLConfigurationException; /** * create and configure HttpsURLConnection object * * @param clientConfiguration * @throws IOException */ public abstract void createAndconfigureHttpConnection( HttpConfiguration clientConfiguration) throws IOException; protected String read(BufferedReader reader) throws IOException { String inputLine; StringBuilder response = new StringBuilder(); while ((inputLine = reader.readLine()) != null) { response.append(inputLine); } return response.toString(); } /** * Set headers for HttpsURLConnection object * * @param headers */ protected void setHttpHeaders(Map<String, String> headers) { if (headers != null && !headers.isEmpty()) { Iterator<Map.Entry<String, String>> itr = headers.entrySet().iterator(); while (itr.hasNext()) { Map.Entry<String, String> pairs = itr.next(); String key = pairs.getKey(); String value = pairs.getValue(); this.connection.setRequestProperty(key, value); } } } }
3,893
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/ReflectionUtil.java
package com.paypal.base; import java.lang.reflect.AccessibleObject; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; public final class ReflectionUtil { private ReflectionUtil() {} public static Map<String, String> decodeResponseObject(Object responseType, String prefix) { Map<String, String> returnMap = new HashMap<String, String>(); Map<String, Object> rMap = ReflectionUtil.generateMapFromResponse( responseType, ""); if (rMap != null && rMap.size() > 0) { for (Entry<String, Object> entry : rMap.entrySet()) { returnMap.put(entry.getKey(), entry.toString()); } } return returnMap; } public static Map<String, Object> generateMapFromResponse( Object responseType, String prefix) { if (responseType == null) { return null; } Map<String, Object> responseMap = new HashMap<String, Object>(); // To check return types Map<String, Object> returnMap; Object returnObject; try { Class<?> klazz = responseType.getClass(); Method[] methods = klazz.getMethods(); Package packageName; String propertyName; AccessibleObject.setAccessible(methods, true); for (Method m : methods) { if (m.getName().startsWith("get") && !m.getName().equalsIgnoreCase("getClass")) { packageName = m.getReturnType().getPackage(); try { if (prefix != null && prefix.length() != 0) { propertyName = prefix + "." + m.getName().substring(3, 4).toLowerCase(Locale.US) + m.getName().substring(4); } else { propertyName = m.getName().substring(3, 4) .toLowerCase(Locale.US) + m.getName().substring(4); } if (packageName != null) { if (!packageName.getName().contains("com.paypal")) { returnObject = m.invoke(responseType); if (returnObject != null && List.class.isAssignableFrom(m .getReturnType())) { List listObj = (List) returnObject; int i = 0; for (Object o : listObj) { if (o.getClass().getPackage().getName() .contains("com.paypal")) { responseMap .putAll(generateMapFromResponse( o, propertyName + "(" + i + ")")); } else { responseMap.put(propertyName + "(" + i + ")", o); } i++; } } else if (returnObject != null) { if (responseType.getClass().getSimpleName() .equalsIgnoreCase("ErrorParameter") && propertyName.endsWith("value")) { propertyName = propertyName.substring( 0, propertyName.lastIndexOf('.')); } responseMap.put(propertyName, returnObject); } } else { returnObject = m.invoke(responseType); if (returnObject != null && m.getReturnType().isEnum()) { responseMap .put(propertyName, returnObject .getClass() .getMethod("getValue") .invoke(returnObject)); } else if (returnObject != null) { returnMap = generateMapFromResponse( returnObject, propertyName); if (returnMap != null && returnMap.size() > 0) { responseMap.putAll(returnMap); } } } } else { responseMap.put(propertyName, m.invoke(klazz.newInstance())); } } catch (IllegalAccessException e) { } catch (IllegalArgumentException e) { } catch (InvocationTargetException e) { } catch (InstantiationException e) { } } } } catch (Exception e) { return null; } return responseMap; } }
3,894
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/Constants.java
package com.paypal.base; public final class Constants { private Constants() {} // General Constants // UTF-8 Encoding format public static final String ENCODING_FORMAT = "UTF-8"; // Empty String public static final String EMPTY_STRING = ""; // Account prefix used in config properties file public static final String ACCOUNT_PREFIX = "acct"; // SOAP Payload format public static final String PAYLOAD_FORMAT_SOAP = "SOAP"; // NVP Payload format public static final String PAYLOAD_FORMAT_NVP = "NV"; // Default SDK configuration file name public static final String DEFAULT_CONFIGURATION_FILE = "sdk_config.properties"; // HTTP Header Constants // HTTP Content-Type Header public static final String HTTP_CONTENT_TYPE_HEADER = "Content-Type"; // HTTP Accept Header public static final String HTTP_ACCEPT_HEADER = "Accept"; // PayPal Security UserId Header public static final String PAYPAL_SECURITY_USERID_HEADER = "X-PAYPAL-SECURITY-USERID"; // PayPal Security Password Header public static final String PAYPAL_SECURITY_PASSWORD_HEADER = "X-PAYPAL-SECURITY-PASSWORD"; // PayPal Security Signature Header public static final String PAYPAL_SECURITY_SIGNATURE_HEADER = "X-PAYPAL-SECURITY-SIGNATURE"; // PayPal Platform Authorization Header public static final String PAYPAL_AUTHORIZATION_PLATFORM_HEADER = "X-PAYPAL-AUTHORIZATION"; // PayPal Merchant Authorization Header public static final String PAYPAL_AUTHORIZATION_MERCHANT_HEADER = "X-PP-AUTHORIZATION"; // PayPal Application ID Header public static final String PAYPAL_APPLICATION_ID_HEADER = "X-PAYPAL-APPLICATION-ID"; // PayPal Request Data Header public static final String PAYPAL_REQUEST_DATA_FORMAT_HEADER = "X-PAYPAL-REQUEST-DATA-FORMAT"; // PayPal Request Data Header public static final String PAYPAL_RESPONSE_DATA_FORMAT_HEADER = "X-PAYPAL-RESPONSE-DATA-FORMAT"; // PayPal Request Source Header public static final String PAYPAL_REQUEST_SOURCE_HEADER = "X-PAYPAL-REQUEST-SOURCE"; // PayPal Device IP Address Header public static final String PAYPAL_DEVICE_IPADDRESS_HEADER = "X-PAYPAL-DEVICE-IPADDRESS"; // User Agent Header public static final String USER_AGENT_HEADER = "User-Agent"; // PayPal Request ID Header public static final String PAYPAL_REQUEST_ID_HEADER = "PayPal-Request-Id"; // Authorization Header public static final String AUTHORIZATION_HEADER = "Authorization"; // PayPal Sandbox Email Address for AA Header public static final String PAYPAL_SANDBOX_EMAIL_ADDRESS_HEADER = "X-PAYPAL-SANDBOX-EMAIL-ADDRESS"; // Constants key defined for configuration options in application properties // End point public static final String ENDPOINT = "service.EndPoint"; // OAuth End point public static final String OAUTH_ENDPOINT = "oauth.EndPoint"; // Service Redirect Endpoint public static final String SERVICE_REDIRECT_ENDPOINT = "service.RedirectURL"; // Service DevCentral Endpoint public static final String SERVICE_DEVCENTRAL_ENDPOINT = "service.DevCentralURL"; // Use Google App Engine public static final String GOOGLE_APP_ENGINE = "http.GoogleAppEngine"; // Use HTTP Proxy public static final String USE_HTTP_PROXY = "http.UseProxy"; // HTTP Proxy host public static final String HTTP_PROXY_HOST = "http.ProxyHost"; // HTTP Proxy port public static final String HTTP_PROXY_PORT = "http.ProxyPort"; // HTTP Proxy username public static final String HTTP_PROXY_USERNAME = "http.ProxyUserName"; // HTTP Proxy password public static final String HTTP_PROXY_PASSWORD = "http.ProxyPassword"; // HTTP Connection Timeout public static final String HTTP_CONNECTION_TIMEOUT = "http.ConnectionTimeOut"; // HTTP Connection Retry public static final String HTTP_CONNECTION_RETRY = "http.Retry"; // HTTP Read timeout public static final String HTTP_CONNECTION_READ_TIMEOUT = "http.ReadTimeOut"; // HTTP Max Connections public static final String HTTP_CONNECTION_MAX_CONNECTION = "http.MaxConnection"; // HTTP Device IP Address Key public static final String DEVICE_IP_ADDRESS = "http.IPAddress"; // Credential Username suffix public static final String CREDENTIAL_USERNAME_SUFFIX = ".UserName"; // Credential Password suffix public static final String CREDENTIAL_PASSWORD_SUFFIX = ".Password"; // Credential Application ID public static final String CREDENTIAL_APPLICATIONID_SUFFIX = ".AppId"; // Credential Subject public static final String CREDENTIAL_SUBJECT_SUFFIX = ".Subject"; // Credential Signature public static final String CREDENTIAL_SIGNATURE_SUFFIX = ".Signature"; // Credential Certificate Path public static final String CREDENTIAL_CERTPATH_SUFFIX = ".CertPath"; // Credential Certificate Key public static final String CREDENTIAL_CERTKEY_SUFFIX = ".CertKey"; // Sandbox Email Address Key public static final String SANDBOX_EMAIL_ADDRESS = "sandbox.EmailAddress"; // HTTP Configurations Defaults // HTTP Method Default public static final String HTTP_CONFIG_DEFAULT_HTTP_METHOD = "POST"; // HTTP Content Type Default public static final String HTTP_CONFIG_DEFAULT_CONTENT_TYPE = "application/x-www-form-urlencoded"; // HTTP Content Type JSON public static final String HTTP_CONTENT_TYPE_JSON = "application/json"; // HTTP Content Type Patch JSON public static final String HTTP_CONTENT_TYPE_PATCH_JSON = "application/json-patch+json"; public static final String HTTP_CONTENT_TYPE_XML = "text/xml"; // IPN endpoint property name public static final String IPN_ENDPOINT = "service.IPNEndpoint"; // Platform Sandbox Endpoint public static final String PLATFORM_SANDBOX_ENDPOINT = "https://svcs.sandbox.paypal.com/"; // Platform Live Endpoint public static final String PLATFORM_LIVE_ENDPOINT = "https://svcs.paypal.com/"; // IPN Sandbox Endpoint public static final String IPN_SANDBOX_ENDPOINT = "https://www.sandbox.paypal.com/cgi-bin/webscr"; // IPN Live Endpoint public static final String IPN_LIVE_ENDPOINT = "https://www.paypal.com/cgi-bin/webscr"; // Merchant Sandbox Endpoint Signature public static final String MERCHANT_SANDBOX_SIGNATURE_ENDPOINT = "https://api-3t.sandbox.paypal.com/2.0"; // Merchant Live Endpoint Signature public static final String MERCHANT_LIVE_SIGNATURE_ENDPOINT = "https://api-3t.paypal.com/2.0"; // Merchant Sandbox Endpoint Certificate public static final String MERCHANT_SANDBOX_CERTIFICATE_ENDPOINT = "https://api.sandbox.paypal.com/2.0"; // Merchant Live Endpoint Certificate public static final String MERCHANT_LIVE_CERTIFICATE_ENDPOINT = "https://api.paypal.com/2.0"; // REST Sandbox Endpoint public static final String REST_SANDBOX_ENDPOINT = "https://api.sandbox.paypal.com/"; // REST Live Endpoint public static final String REST_LIVE_ENDPOINT = "https://api.paypal.com/"; // Mode(sandbox/live) public static final String MODE = "mode"; // SANDBOX Mode public static final String SANDBOX = "sandbox"; // LIVE Mode public static final String LIVE = "live"; // Open Id redirect URI public static final String OPENID_REDIRECT_URI = "openid.RedirectUri"; // Open Id redirect URI Constant Live public static final String OPENID_REDIRECT_URI_CONSTANT_LIVE = "https://www.paypal.com"; // Open Id redirect URI Constant Sandbox public static final String OPENID_REDIRECT_URI_CONSTANT_SANDBOX = "https://www.sandbox.paypal.com"; // Client ID public static final String CLIENT_ID = "clientId"; // Client Secret public static final String CLIENT_SECRET = "clientSecret"; // SSLUtil JRE public static final String SSLUTIL_JRE = "sslutil.jre"; // SSLUtil Protocol public static final String SSLUTIL_PROTOCOL = "sslutil.protocol"; // PayPal webhook transmission ID HTTP request header public static final String PAYPAL_HEADER_TRANSMISSION_ID = "PAYPAL-TRANSMISSION-ID"; // PayPal webhook transmission time HTTP request header public static final String PAYPAL_HEADER_TRANSMISSION_TIME = "PAYPAL-TRANSMISSION-TIME"; // PayPal webhook transmission signature HTTP request header public static final String PAYPAL_HEADER_TRANSMISSION_SIG = "PAYPAL-TRANSMISSION-SIG"; // PayPal webhook certificate URL HTTP request header public static final String PAYPAL_HEADER_CERT_URL = "PAYPAL-CERT-URL"; // PayPal webhook authentication algorithm HTTP request header public static final String PAYPAL_HEADER_AUTH_ALGO = "PAYPAL-AUTH-ALGO"; // Trust Certificate Location to be used to validate webhook certificates public static final String PAYPAL_TRUST_CERT_URL = "webhook.trustCert"; // Default Trust Certificate that comes packaged with SDK. public static final String PAYPAL_TRUST_DEFAULT_CERT = "DigiCertSHA2ExtendedValidationServerCA.crt"; // Webhook Id to be set for validation purposes public static final String PAYPAL_WEBHOOK_ID = "webhook.id"; // Webhook Id to be set for validation purposes public static final String PAYPAL_WEBHOOK_CERTIFICATE_AUTHTYPE = "webhook.authType"; }
3,895
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/credential/TokenAuthorization.java
package com.paypal.base.credential; /** * TokenAuthorization encapsulates third party token authorization. Used for * MERCHANT or PLATFORM APIs */ public class TokenAuthorization { /** * Access token */ private String accessToken; /** * Token secret */ private String tokenSecret; /** * Token based third party authorization used in MERCHANT or PLATFORM APIs * * @param accessToken * Access Token * @param tokenSecret * Token Secret */ public TokenAuthorization(String accessToken, String tokenSecret) { super(); if (accessToken == null || accessToken.trim().length() == 0 || tokenSecret == null || tokenSecret.trim().length() == 0) { throw new IllegalArgumentException( "TokenAuthorization arguments cannot be empty or null"); } this.accessToken = accessToken; this.tokenSecret = tokenSecret; } /** * @return the accessToken */ public String getAccessToken() { return accessToken; } /** * @return the tokenSecret */ public String getTokenSecret() { return tokenSecret; } }
3,896
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/util/UserAgentHeader.java
package com.paypal.base.util; import com.paypal.base.Constants; import java.util.HashMap; import java.util.Map; public class UserAgentHeader { /** * Product Id */ private String productId; /** * Product Version */ private String productVersion; /** * UserAgentHeader * * @param productId * Product Id: Defaults to empty string if null or empty * @param productVersion * Product Version : Defaults to empty string if null or empty */ public UserAgentHeader(String productId, String productVersion) { super(); this.productId = productId != null && productId.trim().length() > 0 ? productId : ""; this.productVersion = productVersion != null && productVersion.trim().length() > 0 ? productVersion : ""; } /** * Java Version and bit header computed during construction */ private static final String JAVAHEADER; /** * OS Version and bit header computed during construction */ private static final String OSHEADER; static { // Java Version computed statically StringBuilder javaVersion = new StringBuilder(); if (System.getProperty("java.version") != null && System.getProperty("java.version").length() > 0) { javaVersion.append("v=") .append(System.getProperty("java.version")); } if (System.getProperty("java.vendor") != null && System.getProperty("java.vendor").length() > 0) { javaVersion.append("; vendor=" + System.getProperty("java.vendor")); } if (System.getProperty("java.vm.name") != null && System.getProperty("java.vm.name").length() > 0) { javaVersion.append("; bit="); if (System.getProperty("java.vm.name").contains("Client")) { javaVersion.append("32"); } else { javaVersion.append("64"); } } JAVAHEADER = javaVersion.toString(); // OS Version Header StringBuilder osVersion = new StringBuilder(); if (System.getProperty("os.name") != null && System.getProperty("os.name").length() > 0) { osVersion.append("os="); osVersion.append(System.getProperty("os.name").replace(' ', '_')); } else { osVersion.append("os="); } if (System.getProperty("os.version") != null && System.getProperty("os.version").length() > 0) { osVersion.append(" " + System.getProperty("os.version").replace(' ', '_')); } OSHEADER = osVersion.toString(); } public Map<String, String> getHeader() { Map<String, String> userAgentMap = new HashMap<String, String>(); userAgentMap.put(Constants.USER_AGENT_HEADER, formUserAgentHeader()); return userAgentMap; } /** * Returns User-Agent header * * @return */ private String formUserAgentHeader() { String header = null; StringBuilder stringBuilder = new StringBuilder("PayPalSDK/" + productId + " " + productVersion + " "); stringBuilder.append("(").append(JAVAHEADER); String osVersion = OSHEADER; if (osVersion.length() > 0) { stringBuilder.append("; ").append(osVersion); } stringBuilder.append(")"); header = stringBuilder.toString(); return header; } }
3,897
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/util/ResourceLoader.java
package com.paypal.base.util; import java.io.*; import java.net.URISyntaxException; import java.net.URL; /** * A class to locate resources and retrieve their contents. To find the resource * the class searches the CLASSPATH first, then Resource.class.getResource("/" + * name). If the Resource finds a "file:" URL, the file path will be treated as * a file. Otherwise, the path is treated as a URL. */ public class ResourceLoader { // Java classpath system property private static final String CLASSPATH = "java.class.path"; // file scheme private static final String FILESCHEME = "file:"; // InputStream private InputStream inputStream; // Resource Name private String name; // File private File file; // URL private URL url; /** * ResourceLoader to load the resource specified by name * * @param name * Name of the resource to load */ public ResourceLoader(String name) { this.name = name; } // Returns an input stream to read the resource contents public InputStream getInputStream() throws IOException { if (inputStream == null) { if (!searchClasspath(name) && !searchResourcepath(name)) { throw new IOException("Resource '" + name + "' could not be found"); } if (file != null) { inputStream = new BufferedInputStream(new FileInputStream(file)); } else if (url != null) { inputStream = new BufferedInputStream(url.openStream()); } } return inputStream; } // Returns true if found private boolean searchClasspath(String filename) { String classpath = System.getProperty(CLASSPATH, ""); String[] paths = classpath.split(File.pathSeparator); file = searchDirectories(paths, filename); return (file != null); } // Search the paths for the specified file private static File searchDirectories(String[] paths, String filename) { for (String path : paths) { File file = new File(path, filename); if (file.exists() && !file.isDirectory()) { return file; } } return null; } // Returns true if found private boolean searchResourcepath(String name) { String rootName = "/" + name; URL res = ResourceLoader.class.getResource(rootName); if (res == null) { return false; } // Try converting from a URL to a File. File resFile = urlToFile(res); if (resFile != null) { file = resFile; } else { url = res; } return true; } // Returns a File object if the URL has a file scheme private static File urlToFile(URL res) { String externalForm = res.toExternalForm(); if (externalForm.startsWith(FILESCHEME)) { try { return new File(res.toURI()); } catch (URISyntaxException e) { return new File(externalForm.substring(5)); } } return null; } }
3,898
0
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/base/util/PayPalURLEncoder.java
package com.paypal.base.util; import java.io.UnsupportedEncodingException; public final class PayPalURLEncoder { static final String DIGITS = "0123456789abcdef"; /** * Prevents this class from being instantiated. */ private PayPalURLEncoder() { } /** * Encodes the given string {@code s} in a x-www-form-urlencoded string * using the specified encoding scheme {@code enc}. * <p> * All characters except letters ('a'..'z', 'A'..'Z') and numbers ('0'..'9') * and characters '_' are converted into their hexadecimal * value prepended by '%'. For example: '#' -> %23. In addition, spaces are * substituted by '+' * * @param s * the string to be encoded. * @param enc * the encoding scheme to be used. * @return the encoded string. */ public static String encode(String s, String enc) throws UnsupportedEncodingException { if (s == null || enc == null) { throw new NullPointerException(); } // Guess a bit bigger for encoded form StringBuffer buf = new StringBuffer(s.length() + 16); int start = -1; for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || " _".indexOf(ch) > -1) { //removed "." and "-" and "*" if (start >= 0) { convert(s.substring(start, i), buf, enc); start = -1; } if (ch != ' ') { buf.append(ch); } else { buf.append('+'); } } else { if (start < 0) { start = i; } } } if (start >= 0) { convert(s.substring(start, s.length()), buf, enc); } return buf.toString(); } private static void convert(String s, StringBuffer buf, String enc) throws UnsupportedEncodingException { byte[] bytes = s.getBytes(enc); for (int j = 0; j < bytes.length; j++) { buf.append('%'); buf.append(DIGITS.charAt((bytes[j] & 0xf0) >> 4)); buf.append(DIGITS.charAt(bytes[j] & 0xf)); } } }
3,899