Giter VIP home page Giter VIP logo

paypal-java-sdk's Introduction

Deprecation Notice:

This SDK is deprecated. You can continue to use it, but no new features or support requests will be accepted. For alternatives, please visit the current SDK homepage on the PayPal Developer Portal

PayPal REST API Java SDK Build Status

Home Image

This repository contains Java SDK and samples for REST API. For PayPal mobile(Android) SDK, please go to PayPal Android SDK

Please Note

The Payment Card Industry (PCI) Council has mandated that early versions of TLS be retired from service. All organizations that handle credit card information are required to comply with this standard. As part of this obligation, PayPal is updating its services to require TLS 1.2 for all HTTPS connections. At this time, PayPal will also require HTTP/1.1 for all connections. Click here for more information. Connections to the sandbox environment use only TLS 1.2.

Direct Credit Card Support

Important: The PayPal REST API no longer supports new direct credit card integrations. Please instead consider Braintree Direct; which is, PayPal's preferred integration solution for accepting direct credit card payments in your mobile app or website. Braintree, a PayPal service, is the easiest way to accept credit cards, PayPal, and many other payment methods.

PayPal Checkout v2

Please note that if you are integrating with PayPal Checkout, this SDK and corresponding API v1/payments are in the process of being deprecated.

We recommend that you integrate with API v2/checkout/orders and v2/payments. Please refer to the Checkout Java SDK to continue with the integration.

2.0 Release Candidate!

We're releasing a brand new version of our SDK! 2.0 is currently at release candidate status, and represents a full refactor, with the goal of making all of our APIs extremely easy to use. 2.0 includes all of the existing APIs (except payouts), and includes the new Orders API (disputes and Marketplace coming soon). Check out the FAQ and migration guide, and let us know if you have any suggestions or issues!

Prerequisites

  • Java JDK 6 or higher
  • An environment which supports TLS 1.2 (see the TLS-update site for more information)

Integration

Gradle

repositories {
	mavenCentral()
}
dependencies {
	compile 'com.paypal.sdk:rest-api-sdk:+'
}

Others

Get Started

License

Code released under SDK LICENSE

Contributions

Pull requests and new issues are welcome. See CONTRIBUTING.md for details.

paypal-java-sdk's People

Contributors

agebhar1 avatar avidas avatar aydiv avatar bluk avatar braebot avatar braintreeps avatar ersimont avatar franatique avatar gazzonyx avatar jaypatel512 avatar juwlee avatar krico avatar kumaravel-jayakumar avatar lathavairamani avatar leandrohsilveira avatar lmarkus avatar lvairamani avatar mortonl avatar mslawin avatar pmanesh avatar prannamalai avatar radistao avatar rdbasu avatar richardrega avatar sankarbhavanib avatar shiva-kalgudi avatar siddick avatar sucithrashanu avatar vasujain avatar wojciechzankowski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

paypal-java-sdk's Issues

SDK Support for UnionPay Card

It is documented below that UnionPay Card is supported by PayPal
https://www.paypal.com/c2/webapps/mpp/faqs-china-unionpay-payments

However, I found that in the current Java SDK, the card type has to be "visa", "mastercard", "amex", or "discover", whereas UnionPay and other cards are not in the list. It looks that the error message is returned by the RESTFul service rather than generated by the SDK, so it might be a system wide issue. Fell free to criticize me if I were wrong.

Does the PayPal development team has a plan to support more types of cards including UnionPay? If so, I'd personally be happy to contribute if that may help.

One trouble with the UnionPay card is that not all of them have cvv2 numbers at the back, and hence may be handled slightly differently.

Cheers
Jiansen

Resource 'sdk_config.properties' could not be found

Issue : We are able to set config file from custom location....when we try to create instance for OAuthTokenCredential providing clientid & clientsecret..it gives exception "Resource 'sdk_config.properties' could not be found"

Description:
//below code init resource properly
InputStream is = MyPaypalAuth.class.getResourceAsStream("/myresource/sdk_config.properties");
PayPalResource.initConfig(is);

//below line raise exception
String accessToken = new OAuthTokenCredential(clientID, clientSecret).getAccessToken();

Exception:
java.io.IOException: Resource 'sdk_config.properties' could not be found
com.paypal.base.util.ResourceLoader.getInputStream(ResourceLoader.java:50)
com.paypal.base.ConfigManager.(ConfigManager.java:85)
com.paypal.base.ConfigManager.getInstance(ConfigManager.java:102)
com.paypal.base.rest.OAuthTokenCredential.(OAuthTokenCredential.java:97)

Automatic activation of Maven profile 'coverage' results in conflicting dependencies and inconsistent build behavior in applications

The following pom.xml in rest-api-sdk 0.9.2 is problematic:

    <profile>
        <id>coverage</id>
        <activation>
            <!-- Jenkins -->
            <property>
                <name>env.BUILD_NUMBER</name>
            </property>
        </activation>
        <dependencies>
            <dependency>
                <groupId>net.sourceforge.cobertura</groupId>
                <artifactId>cobertura</artifactId>
                <version>1.9.4.1</version>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>cobertura-maven-plugin</artifactId>
                    <version>2.5.1</version>
                    <configuration>
                        <formats>
                            <format>html</format>
                            <format>xml</format>
                        </formats>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>cobertura</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>

The problem is when building an application (not PayPal's rest-api-sdk) using Jenkins, the above profile is automatically activated, which adds unintended (transitive) dependencies (and in our case, conflicting dependencies) and plugin configuration.

Simply put, the applications build behavior differs unintentionally when it's built using Maven command line and using Jenkins.

In our application, the dependency tree becomes:

[INFO] +- id.co.bippo.commerce:id.co.bippo.payment:jar:6.1.0-SNAPSHOT:compile
[INFO] |  +- com.paypal.sdk:rest-api-sdk:jar:0.9.2:compile
[INFO] |  |  +- com.paypal.sdk:paypal-core:jar:1.6.2:compile
[INFO] |  |  \- net.sourceforge.cobertura:cobertura:jar:1.9.4.1:compile
[INFO] |  |     +- oro:oro:jar:2.0.8:compile
[INFO] |  |     +- asm:asm:jar:3.0:compile
[INFO] |  |     +- asm:asm-tree:jar:3.0:compile
[INFO] |  |     +- log4j:log4j:jar:1.2.9:compile
[INFO] |  |     \- org.apache.ant:ant:jar:1.7.0:compile
[INFO] |  |        \- org.apache.ant:ant-launcher:jar:1.7.0:compile
[INFO] |  +- com.stripe:stripe-java:jar:1.18.0:compile
[INFO] |  +- org.springframework:spring-tx:jar:4.1.0.RELEASE:compile
[INFO] |  +- org.eclipse.emf:org.eclipse.emf.texo:jar:0.1.0-v201310021216:compile
[INFO] |  \- org.eclipse.emf:org.eclipse.emf.texo.server:jar:0.1.0-v201310021216:compile

Specifically:

  1. The transitive dependency of log4j is problematic, as we use log4j-over-slf4j combined with logback-classic
  2. The transitive dependency of asm-* 3.0 is problematic, as we use asm 4.2
  3. The rest of the dependencies are not harmful, but slow build time and consume unnecessary space in the final application

So the coverage profile should not be activated automatically, i.e. these lines should be deleted:

        <activation>
            <!-- Jenkins -->
            <property>
                <name>env.BUILD_NUMBER</name>
            </property>
        </activation>

While automatic profile activation works well for applications, this feature shouldn't be used for libraries such as PayPal Java SDK.

Tag @ceefour

Unable to get note to payee

If a user make a note to a payment during the payment process, where do I find this note vit the rest API?

Payment method is "paypal". Payment intent is "sale".

The note to payee in the transactions is always empty.

Very bad config design

1.The properties file path field is declared as final, why do not allow user change it
2. Payment.init(config) is useless becase other classes like AccessAuthToken do not use the config, and they use the hard coded one while you cant change it

SDK Properties

Relying on a properties file in the classpath is not ideal for many. Can you please make it optional such that we can explicity pass in the required properties? We maintain a namespace with our properties to avoid collision (and central location) ...even if I pass in a constructed Properties() the OAuth still expects to find a specifically named prop file ...

Plan update not working

The update function of Plan object does not work. It takes a PatchRequest as parameter. Here is the code from Plan class which sends the Patch request:

public void update(APIContext apiContext, PatchRequest patchRequest) throws PayPalRESTException {
        if (apiContext == null) {
            throw new IllegalArgumentException("APIContext cannot be null");
        }
        if (apiContext.getAccessToken() == null || apiContext.getAccessToken().trim().length() <= 0) {
            throw new IllegalArgumentException("AccessToken cannot be null or empty");
        }
        if (apiContext.getHTTPHeaders() == null) {
            apiContext.setHTTPHeaders(new HashMap<String, String>());
        }
        apiContext.getHTTPHeaders().put(Constants.HTTP_CONTENT_TYPE_HEADER, Constants.HTTP_CONTENT_TYPE_JSON);
        apiContext.setSdkVersion(new SDKVersionImpl());
        if (this.getId() == null) {
            throw new IllegalArgumentException("Id cannot be null");
        }
        if (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 = patchRequest.toJSON();
        PayPalResource.configureAndExecute(apiContext, HttpMethod.PATCH, resourcePath, payLoad, null);
        return;
    }

So, only JSON representation of PatchRequest is sent as PayLoad. But the REST API accepts the following:

[
    {
        "path": "/",
        "value": {
            "state": "ACTIVE"
        },
        "op": "replace"
    }
]

So, it's raising a malformed request exception.

Maven profile `coverage` activation under jenkins may lead to unexpected behaviour

Hi,

we are using jenkins for CI with our project that use this rest-api-sdk-java.

I've lost a few hours struggling to understand why under jenkins our build keeps on failing since a log4j dependency got introduced in the classpath and our hibernate was using it instead of our slf4j api.

The problem is that this sdk contains a coverage profile that get activated under ALL jenkins and not only on your one, based on the $BUILD_NUMBER presence.
The coverage profile includes a dependency on net.sourceforge.cobertura:cobertura:jar:1.9.4.1, that has a dependency on log4j:log4j:jar:1.2.9:compile.

Please, please, please, use a more robust activation method for your build process of this open-source library that will not mess with other build environments similar to yours.

How to submit live payment without cvv2

I read here that "Card Verification Value, version 2. Your Merchant Account settings determine whether this field is required."

I want to disable cvv2 and I don't want it to be required for making a call. Please guide me where I can find this setting because if I don't pass it the transaction is not made.

Please add some kind of tutorial.

Hi, I'm looking to implement a simple use case.

I want to create a one time payment transaction.... I could only got so far because what you are offering looks not that much like what the actual rest use case looks like.

https://developer.paypal.com/webapps/developer/docs/classic/express-checkout/ht_ec-singleItemPayment-curl-etc/

Or maybe I'm not understanding how to match things up :(

I tried to implement my method based on the FuturePayment example... but I can't realize where are the extra steps for confirmation and so on. Could you please provide me an example. Thank you!

Brazil Currency - Direct Payment

Hi,

I want to know why I can't make a direct payment from PayPal Rest Cliente using "BRL" as currency.
My application is looking for this feature. Can PayPal help me?

Thanks,

Transfer money from business acoount to personal account

In my application I am using paypal for money transaction. In my application when any customer buy something money goes to their personal account to business account. But now I also want to transfer money from business account to customer personal accounts in some cases. How to do that thing?

Invoice creation is broken

When I create an Invoice I have this error:
18:00:33.009 [main] ERROR c.l.c.cmw.utils.PaypalPaymentGateway - Paypal error: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 307

This because in the Address class, included in MerchantInfo class, in Invoice I have the following "phone":

/**
 * Phone number in E.123 format.
 */
private String phone; 

while paypal's sandbox returns:
... "address":{"phone":{"country_code":"39","national_number":"05021313"}}} ...

Verifying Payment

i am trying to verify a paypal payment by using
Payment payment = Payment.get(accessToken, paymentID);

but i get a connection reset error could you please help me fix this problem

Error when querying payment information of a stored credit card transaction

When querying payment information of a transaction made with a stored credit card, I get the following errors in the PayPal response:

name: "INVALID_RESOURCE_ID"
message: "The requested resource ID was not found"

This does NOT happen for a credit card not stored in the vault, only when the credit card is remembered. The transaction is made on an iOS device using the official PayPal iOS SDK, when selecting the "remember credit card" option.

I found a similar issue on stackoverflow, that is probably related (http://stackoverflow.com/questions/19773755/keep-receiving-404-error-with-rest-api-when-doing-a-capture/19793587#19793587) but could not find any update anywhere about the status of this issue.

Failed to query some properties from Agreement

I get the following by querying the Agreement:

{
  "id": "I-S2C790WFJVSS",
  "description": "Agreement Desc goes herere",
  "start_date": "2015-03-04T05:00:00Z",
  "plan": {
    "payment_definitions": [
      {
        "type": "TRIAL",
        "frequency_interval": "3",
        "frequency": "Month",
        "cycles": "1",
        "amount": {
          "currency": "CAD",
          "value": "900.00"
        },
        "charge_models": [
          {
            "type": "TAX",
            "amount": {
              "currency": "CAD",
              "value": "11.11"
            }
          },
          {
            "type": "SHIPPING",
            "amount": {
              "currency": "CAD",
              "value": "0.00"
            }
          }
        ]
      },
      {
        "type": "REGULAR",
        "frequency_interval": "1",
        "frequency": "Month",
        "cycles": "0",
        "amount": {
          "currency": "CAD",
          "value": "300.00"
        },
        "charge_models": [
          {
            "type": "TAX",
            "amount": {
              "currency": "CAD",
              "value": "22.22"
            }
          },
          {
            "type": "SHIPPING",
            "amount": {
              "currency": "CAD",
              "value": "0.00"
            }
          }
        ]
      }
    ],
    "merchant_preferences": {
      "setup_fee": {
        "currency": "CAD",
        "value": "0.00"
      },
      "max_fail_attempts": "0",
      "auto_bill_amount": "YES"
    }
  },
  "links": [
    {
      "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-S2C790WFJVSS/suspend",
      "rel": "suspend",
      "method": "POST"
    },
    {
      "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-S2C790WFJVSS/re-activate",
      "rel": "re_activate",
      "method": "POST"
    },
    {
      "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-S2C790WFJVSS/cancel",
      "rel": "cancel",
      "method": "POST"
    },
    {
      "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-S2C790WFJVSS/bill-balance",
      "rel": "self",
      "method": "POST"
    },
    {
      "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-S2C790WFJVSS/set-balance",
      "rel": "self",
      "method": "POST"
    }
  ]
}

Missing the following:

"state": "Pending",
...
"start_date": "2015-02-19T08:00:00Z",
  "agreement_details": {
    "outstanding_balance": {
      "currency": "USD",
      "value": "0.00"
    },
    "cycles_remaining": "12",
    "cycles_completed": "0",
    "final_payment_date": "2016-12-19T10:00:00Z",
    "failed_payment_count": "0"
  }

A side question: Why the Plan does not have it's name? If this is not a bug, how would I retrieve my Plan's name from a paid Agreement?

Thank you

PaymentExecution does not return state

After I run PaymentExecution the state is null. It should have some value. "created" for successful completion I believe. I can look on the sandbox account and see the transaction completed.

The PayerInfo is also null.

FuturePayment#create Javadoc issue

The Javadoc of method FuturePayment#create says:

[...]
* @param authorizationCode an authorization code
* @param refreshToken a refresh token
[...]

but the method's signature is:

public Payment create(String accessToken, String correlationId)

In fact, I would like to call a method which creates a Payment with the refreshToken by getting the accessToken internally. Is that possible?

how to verify the payment was successful

Sorry, I'm new to paypal

  1. User filled a form on my website and submitted
  2. I made a checkout url using the code written in PaymentWithPaypalServlet.java else section
  3. Website then redirected the user automatically to paypal
  4. After the transaction the user is redirected back to cancel/return URL (both same in my case)
  5. We then get the payerId from the request and execute the PaymentExecution using execute() of Payment.
  6. But in the response there is no success or failure, all that information that comes up is already known. Is that what was supposed to come on success ? What shall come on failure then ?

RelatedResources doesn't have an Order transaction?

https://github.com/paypal/PayPal-Java-SDK/blob/master/rest-api-sdk/src/main/java/com/paypal/api/payments/RelatedResources.java

/**
 * An order transaction
 */
private Authorization authorization;

https://developer.paypal.com/docs/integration/direct/create-process-order/#create-the-order
"Executing an order results in an Order ID (in the related_resources container)."

I can see this transaction id in my raw JSON response, but my Java code doesn't have it by the time it gets to my application?

All I see is an empty relatedResources inside my transactions inside my Payment object.

I want to implement payment gateway in my GAE application.

When i run this without GAE then its work fine, but when i integrate this all servlet and all realated pages in my current project where actually i want to implemet all this, there it ConfigManager.getInstance().getValue("clientID"); this line causing me access denied exception. Is am missing somthing??

UNAUTHORIZED_PAYMENT

Hello,
In the sandbox, the successful use of a credit card payment paypal official account given. In the live environment can pay using PayPal Account successful, but the use of credit card payments appear:
com.paypal.core.rest.PayPalRESTException: Error code : 401 with response : {"name":"UNAUTHORIZED_PAYMENT","message":"Unauthorized payment","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#UNAUTHORIZED_PAYMENT","debug_id":"2b9e8cb3a811f"}
My Accounts receivable certified.

Error in App Engine after introduce log4j2

Hi,

0.12.2 version of PayPal-java-SDK was working fine. Since 1.0.0 version the following error occurs in App Engine deployed application (local development [dev server] works fine) when calling OAuthTokenCredential.generateOAuthToken():

java.lang.NoClassDefFoundError: Could not initialize class com.paypal.base.DefaultHttpConnection

Regards,
Markenson

Invoice item discount json conversion error

During invoice creation the REST api will allow for line item discounts by either percent or amount. However with the current implementation in the sdk this is not possible. When creating a line item discount using amount the SDK will fail to create the invoice due to "percent" being defined in the JSON request regardless of being set.

Percent is being created in the JSON request due to Gson forcing a value for the primitive type float in Cost.java. Changing the field percent (along with the getters and setters) to type Float fixes the problem. This allows Gson to skip defining the "percent" in the JSON request if amount is being used.

SDK Properties File Name

In ConfigManager.java on line 74 the DEFAULT_CONFIGURATION_FILE is loaded, and there appears to be no way to change the name of this file, even though when I invoke the initConfig I can pass it an arbitrarily named resource like shown below.

PayPalResource.initConfig(this.getClass().getResourceAsStream("/paypal.properties"));

I don't mind the sdk_config.properties file being in my classpath, but I mind the fact that it's named "sdk_config.properties" which is unhelpfully generic. Which sdk does this apply to? Which version of the sdk did I write these properties for? Some of these things I could store in comments in the properties file, but I'd much rather have it encoded in the file name. When a developer is using an IDE, or looking at the file structure, it'd be a lot more helpful if the name could be "paypal_sdk_configuration.properties".

The problem is that the sdk_configuration.properties file is named from the perspective of the developers on the Paypal project, not from the perspective of the developers consuming the SDK which may be one of many.

private ConfigManager() {
    ResourceLoader resourceLoader = new ResourceLoader(
            Constants.DEFAULT_CONFIGURATION_FILE);
    try {
        InputStream inputStream = resourceLoader.getInputStream();
        properties = new Properties();
        properties.load(inputStream);
        setPropertyLoaded(true);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

Missing property 'value' in PatchRequest.java

Currently, only 2 properties are available: op and path.

This means I cannot form the PatchRequest object properly and I cannot update a created plan to the active state:

plan.update(apiContext, patchRequest);

Proposed solution:

Add property 'value' with getter and setter.

API v1.0: custom loggers not available on Google App Engine

Hello!

i could not use the official Java PayPal API in the past, because unfortunately the loading of the configuration properties file failed on GAE (on v0.12.2). This has been solved in your recent release v1.0.

Unfortunately, you introduced log4j. GAE does not support custom loggers; for reference please have a look here:

https://code.google.com/p/googleappengine/issues/detail?id=11499&q=log4j&colspec=ID%20Type%20Component%20Status%20Stars%20Summary%20Language%20Priority%20Owner%20Log

Could you please provide a solution to this problem that allows us to use the API in v1.0 on GAE, thus providing a method to disable log4j support?

Thank you very much!
Nikolas

REST API SDK jar file

Hi,
Where could I get a jar file for this SDK to be included in my application?

Thanks

Please improve the README

The README is really weak and does not help to get started.

It seems that clientID and clientSecret are stored in the properties file and can be loaded like this:

Payment.initConfig(new File("../sdk_config.properties"));

Right after this part in the README it says that you have to create the OAuth token like this:

String accessToken = new OAuthTokenCredential(clientID,   clientSecret).getAccessToken();

Why do I have to specify clientID and clientSecret here again when I already loaded the config file? Why are these credentials in the config file then?

Also why should somebody add jars locally? You should only add the ONE dependency to your maven dependency file (Build.scala for example) and that's it, that is the idea of maven usage after all.

The version in the README is 0.8.0, there is however already a 0.9.0 tagged version.

Payouts API

There's no API for Payouts. Any word on when this can be included?

getValue deprecated

GenerateAccessToken has two variables that are being set using ConfigManager.getInstance().getValue()

What method is replacing it?

Cannot Retrieve existing payments with Rest SDK

I'm writing a java application to do automated donor acknowledgment and I am trying to retrieve all existing payments for a specific time period. Can I do this with the Rest API or do I have to use the Classic API's? I saw this thread and wanted to confirm if it's true (http://stackoverflow.com/questions/18138224/downloading-existing-paypal-payments-with-rest-api). If it is, it seems like a big shortcoming to limit the Rest API's this way.

The response I get when I query for Payments
PaymentHistory paymentHistory = Payment.get(accessToken, queryParameters);

is { "count": 0 }

Any help would be greatly appreciated.

URL problem on OSX machine

Hello guys,

I'm just starting with the paypal api and I faced a problem on loading the default config file. I realized the problem was ocurring because my FILE url was being encoded by the url encoder because of the empty spaces I had on my folders.
In my case, it was:
/Users/user/Desktop/Eclipse Workspaces/workspace vs-players/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/rest-api-sample

But the API when calling
private static File urlToFile(URL res) {
try {
String externalForm = res.toExternalForm();

The external form method used to return the url encoded as
/Users/user/Desktop/Eclipse%20Workspaces/workspace%20vs-players/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/rest-api-sample

So I had to override the com.paypal.sdk.util.ResourceLoader class on my project and just change to this:

private static File urlToFile(URL res) {
try {
String externalForm = res.toExternalForm();
externalForm = java.net.URLDecoder.decode(externalForm, "UTF-8");
if (externalForm.startsWith(FILESCHEME)) {
return new File(externalForm.substring(5));
}
} catch (Exception ex) {
ex.printStackTrace();
}

    return null;
}

It worked well, but I wonder if the URL won't need to be called further by any service and it should be encoded as it was.

TestNG dependency in wrong scope

The TestNG dependency should be specified as scope "test" instead of scope "compile" in the POM. Otherwise, it may be necessary for clients to add an exclusion for TestNG when using rest-api-sdk-java.

REST JAVA API - IE dnserror

REST JAVA API SAMPLE fails with some IE installations. IE browser get lost when redirected to last page (response.jsp ) and reports a dnserror (dnserror.htm "This page can’t be displayed"). Failure happens with some API Samples (Payment with a credit card, Get Authorization, Capture Authorization, Void Authorization, Get Capture and Refund Capture) but it does not happen with other API Samples (Payment with a PayPal Account, Payment with saved credit card, Reuthorization) that end the process at response.jsp as expected.
In our case the issue was present using IE10 and IE11 running on windows 7. But is not present using IE 9 in another computer running windows Vista. Both were tested on Tomcat 7 running on Windows and Linux. API Samples on other browsers (Chrome, Firefox and Safari) perform as expected.
Any recommendation o clue about what may be happening with the IE 10/11 Windows 7 that cause the failure?

PayPalRESTException - Provide easier way to intercept message

Currently exception details are coming as string containing error code and json message. It will be nice if details can be exposed as separate properties, that will help SDK user to intercept the details without having to write custom error message parser.

Error Example - Error code : 400 with response : {"name":"VALIDATION_ERROR","details":[{"field":"number","issue":"Value is invalid"}],"message":"Invalid request - see details","information_link":"https://developer.paypal.com/docs/api/#VALIDATION_ERROR","debug_id":"5c16c7e108c14"}

This message content can be split to represent field for error code, error type, details, message and other fields..

static plans method not working

The static method plans in Plan.java is not working:

public static PlanList plans(APIContext apiContext, Map<String, String> containerMap) throws PayPalRESTException {
        if (apiContext == null) {
            throw new IllegalArgumentException("APIContext cannot be null");
        }
        if (apiContext.getAccessToken() == null || apiContext.getAccessToken().trim().length() <= 0) {
            throw new IllegalArgumentException("AccessToken cannot be null or empty");
        }
        if (apiContext.getHTTPHeaders() == null) {
            apiContext.setHTTPHeaders(new HashMap<String, String>());
        }
        apiContext.getHTTPHeaders().put(Constants.HTTP_CONTENT_TYPE_HEADER, Constants.HTTP_CONTENT_TYPE_JSON);
        apiContext.setSdkVersion(new SDKVersionImpl());
        if (containerMap == null) {
            throw new IllegalArgumentException("containerMap cannot be null");
        }
        Object[] parameters = new Object[] {containerMap};
        String pattern = "v1/plans/billing-plans?start_id={0}&sort_order={1}&status={2}";
        String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
        String payLoad = "";
        return PayPalResource.configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, PlanList.class);
    }

Proposed solution:

Change String pattern to be = "v1/payments/billing-plans?start_id={0}&sort_order={1}&status={2}";

PAYPAL REST API does not always work on Android

We are trying to make a refund from an Android app, since the mobile sdk does not support refunds we started using the Paypal Rest Api.

We are able to use the Paypal Rest Api on Android with many of the Api functions, we can execute a sale along with many other functions.

The problem comes when we need to get the Payment Object in order to get the sale id needed to execute the refund. We always get 405 error. (Error 405 happens because the function Paygment.get should use GET method and not POST method)

We are sure our code does not tell the Api to use POST method at any moment. This are the only for lines of code we write in order to get the payment:

String clientID = ConfigManager.getInstance().getValue("clientID");
String clientSecret = ConfigManager.getInstance().getValue("clientSecret");
String accessToken = new OAuthTokenCredential(clientID, clientSecret).getAccessToken();
Payment payment = Payment.get(accessToken, "PAY-0BP012443G262425JKNKQVVY");

If you execute this four lines in an Java Project it will work without any problem. If you execute this on an Android project it will return the 405 Error. Remember that this only happening with the Payment.get() others method work well.

in a nutshell: We have discover that Paypal Rest Api is not working properly on Android. It works for some methods but it does not work properly with other.

Failed to query Payer from Agreement

I want to query for Payer's information from an executed Agreement. According to API, I should be able to accomplish this by doing:

Agreement.get(apiContext, "I-XXXXXXX").getPayer();

but it returned null.

For your information, the executed agreement object

Agreement.get(apiContext, "I-XXXXXXX"); returned the following:

{
  "id": "I-xxxxxxxxx",
  "description": "Agreement Description blabla",
  "start_date": "2014-11-26T05:00:00Z",
  "plan": {
    "payment_definitions": [
      {
        "type": "REGULAR",
        "frequency_interval": "1",
        "frequency": "Day",
        "cycles": "0",
        "amount": {
          "currency": "CAD",
          "value": "12.34"
        },
        "charge_models": [
          {
            "type": "TAX",
            "amount": {
              "currency": "CAD",
              "value": "0.00"
            }
          },
          {
            "type": "SHIPPING",
            "amount": {
              "currency": "CAD",
              "value": "0.00"
            }
          }
        ]
      }
    ],
    "merchant_preferences": {
      "setup_fee": {
        "currency": "CAD",
        "value": "0.00"
      },
      "max_fail_attempts": "0",
      "auto_bill_amount": "YES"
    }
  },
  "links": [
    {
      "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-xxxxxx/suspend",
      "rel": "suspend",
      "method": "POST"
    },
    {
      "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-xxxxx/re-activate",
      "rel": "re_activate",
      "method": "POST"
    },
    {
      "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-xxxx/cancel",
      "rel": "cancel",
      "method": "POST"
    },
    {
      "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-xxxxxx/bill-balance",
      "rel": "self",
      "method": "POST"
    },
    {
      "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-xxxx/set-balance",
      "rel": "self",
      "method": "POST"
    }
  ]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.