Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

JSON Parse exception on Java SDK Error handling #339

Closed
leandrohsilveira opened this issue Jan 29, 2018 · 12 comments
Closed

JSON Parse exception on Java SDK Error handling #339

leandrohsilveira opened this issue Jan 29, 2018 · 12 comments

Comments

@leandrohsilveira
Copy link
Contributor

General information

  • SDK/Library version: 1.14.0
  • Environment: sandbox
  • PayPal-Debug-ID values: It's a client-side error
  • Language, language version, and OS: Java 1.7.0_51 on Windows 10

Issue description

My current task is to improve the application Payment error handling.
Currently the application is simply catching all exceptions, logging and redirecting to a generic error page.
Now i need to catch the REST API error message to handle it properly.
So, i'm trying the negative testing (https://developer.paypal.com/docs/api/nt-rest/) to validate my error handling implementation, but i'm unable to reach the response error message due to a JSON Parse error.

I've implemented a simple proof of concept, the craziest JUnit i ever wrote, it will reproduce my issue almost automaticly:

proof-of-concept.zip

@xiaoleih41
Copy link

Can you please put the code on a test repo instead? Also, what's your client Id so that we may be able to do more researching from the backend.

@leandrohsilveira
Copy link
Contributor Author

@leandrohsilveira
Copy link
Contributor Author

The clientID "AdJbvXS9rxpE0RpKbyDNWgdMuUFzzQGqagF6iyAz9nx8zNaG_SH2rnMHU53RQNJrF3c-DrCBEO6w1LHX"

@leandrohsilveira
Copy link
Contributor Author

I noticed something:
The WebService JSON Response is:

{
    "name": "AMOUNT_MISMATCH",
    "message": "The totals of the cart item amounts do not match sale amounts.",
    "information_link": "https://developer.paypal.com/docs/api/payments/#errors",
    "details": "The amount total does not match the item amount totals."
}

But, the Error class is:

public class Error extends PayPalModel {

	private String name;

	private String message;

	private List<ErrorDetails> details;

	private String informationLink;

	private String debugId;

	private List<DefinitionsLinkdescription> links;

        [...]
}

The "details" property between JSON and Java model are inconsistent.
The JSON parser fail to parse the JSON property "details" from string to List<ErrorDetails> of Java model.

@xiaoleih41
Copy link

Do you have a debug ID for it?

@leandrohsilveira
Copy link
Contributor Author

leandrohsilveira commented Feb 1, 2018

No, because the server responded appropriately.
The SDK who failed to parse the server response.

@leandrohsilveira
Copy link
Contributor Author

There is the client-side log with DEBUG level:

2018-01-29 17:04:53,268 DEBUG com.paypal.base.ConfigManager:95: sdk_config.properties not present. Skipping...
2018-01-29 17:04:53,505 DEBUG com.paypal.base.rest.OAuthTokenCredential:378: request header: {Authorization=Basic QWRKYnZYUzlyeHBFMFJwS2J5RE5XZ2RNdVVGenpRR3FhZ0Y2aXlBejlueDh6TmFHX1NIMnJuTUhVNTNSUU5KckYzYy1EckNCRU82dzFMSFg6RU9KMHhHVXVQN0ZoQm1Vc1BfY0RPT2hyS3g2U3JrTVhaWFNjc2xJM21BaEpvdXhwb3Y4X1pEVU93eEtBcVhQN09YSGVXUnp6UWdHZUZ6SFY=, User-Agent=PayPalSDK/PayPal-Java-SDK 1.14.0 (v=1.7.0_51; vendor=Oracle Corporation; bit=64; os=Windows_8 6.2), Accept=application/json, Content-Type=application/x-www-form-urlencoded}
2018-01-29 17:04:53,505 DEBUG com.paypal.base.rest.OAuthTokenCredential:379: request body: grant_type=client_credentials
2018-01-29 17:04:53,505 DEBUG com.paypal.base.HttpConnection:225: curl command: 
curl --verbose --request POST 'https://api.sandbox.paypal.com/v1/oauth2/token' \
  --header "Authorization:Basic QWRKYnZYUzlyeHBFMFJwS2J5RE5XZ2RNdVVGenpRR3FhZ0Y2aXlBejlueDh6TmFHX1NIMnJuTUhVNTNSUU5KckYzYy1EckNCRU82dzFMSFg6RU9KMHhHVXVQN0ZoQm1Vc1BfY0RPT2hyS3g2U3JrTVhaWFNjc2xJM21BaEpvdXhwb3Y4X1pEVU93eEtBcVhQN09YSGVXUnp6UWdHZUZ6SFY=" \
  --header "User-Agent:PayPalSDK/PayPal-Java-SDK 1.14.0 (v=1.7.0_51; vendor=Oracle Corporation; bit=64; os=Windows_8 6.2)" \
  --header "Accept:application/json" \
  --header "Content-Type:application/x-www-form-urlencoded" \
  --data 'grant_type=client_credentials'
2018-01-29 17:04:54,824 DEBUG com.paypal.base.rest.OAuthTokenCredential:385: response header: {null=[HTTP/1.1 200 OK], X-PAYPAL-TOKEN-SERVICE=[IAAS], Vary=[Authorization], Date=[Mon, 29 Jan 2018 19:04:58 GMT], Content-Length=[710], Paypal-Debug-Id=[67c6013788d90], Set-Cookie=[X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT, X-PP-SILOVER=name%3DSANDBOX3.API.1%26silo_version%3D1880%26app%3Dapiplatformproxyserv%26TIME%3D1517317978%26HTTP_X_PP_AZ_LOCATOR%3Dsandbox.slc; Expires=Mon, 29 Jan 2018 19:34:58 GMT; domain=.paypal.com; path=/; Secure; HttpOnly], Content-Type=[application/json], Connection=[close], HTTP_X_PP_AZ_LOCATOR=[sandbox.slc], paypal-debug-id=[67c6013788d90], Server=[Apache]}
2018-01-29 17:04:54,824 DEBUG com.paypal.base.rest.OAuthTokenCredential:386: response: {"scope":"https://uri.paypal.com/services/disputes/read-seller https://uri.paypal.com/services/subscriptions https://api.paypal.com/v1/payments/.* https://uri.paypal.com/services/disputes/read-buyer https://api.paypal.com/v1/vault/credit-card https://uri.paypal.com/services/applications/webhooks openid https://uri.paypal.com/payments/payouts https://uri.paypal.com/services/disputes/update-seller https://api.paypal.com/v1/vault/credit-card/.*","nonce":"2018-01-29T19:04:58ZxLOmREfbczJWOQPBg9F9KNgnBlSculMhEnlKYLDV2zA","access_token":"A21AAG1Ev_JgNtsL4-o9w77X7AgGoGIr3eKwNxFLiXyyNyvsCNp-kkL3db8kLTJuuoEu3qlRsURqxMRjU1rEERrJx5NjGMqmA","token_type":"Bearer","app_id":"APP-80W284485P519543T","expires_in":32400}
2018-01-29 17:04:54,840 DEBUG com.paypal.base.rest.PayPalResource:412: request header: {Authorization=Bearer A21AAG1Ev_JgNtsL4-o9w77X7AgGoGIr3eKwNxFLiXyyNyvsCNp-kkL3db8kLTJuuoEu3qlRsURqxMRjU1rEERrJx5NjGMqmA, PayPal-Request-Id=e6d4e4c5-da7a-468e-8a9f-3295432f78c9, User-Agent=PayPalSDK/  (v=1.7.0_51; vendor=Oracle Corporation; bit=64; os=Windows_8 6.2), Content-Type=application/json, Accept=application/json}
2018-01-29 17:04:54,840 DEBUG com.paypal.base.rest.PayPalResource:413: request body: {
  "intent": "sale",
  "payer": {
    "payment_method": "paypal"
  },
  "transactions": [
    {
      "amount": {
        "currency": "BRL",
        "total": "25.00"
      },
      "description": "Test checkout.",
      "item_list": {
        "items": [
          {
            "name": "Test item",
            "quantity": "1",
            "price": "25.00",
            "currency": "BRL"
          }
        ]
      }
    }
  ],
  "redirect_urls": {
    "return_url": "http://localhost:8001",
    "cancel_url": "http://localhost:8001"
  }
}
2018-01-29 17:04:54,841 DEBUG com.paypal.base.HttpConnection:225: curl command: 
curl --verbose --request POST 'https://api.sandbox.paypal.com/v1/payments/payment' \
  --header "Authorization:Bearer A21AAG1Ev_JgNtsL4-o9w77X7AgGoGIr3eKwNxFLiXyyNyvsCNp-kkL3db8kLTJuuoEu3qlRsURqxMRjU1rEERrJx5NjGMqmA" \
  --header "PayPal-Request-Id:e6d4e4c5-da7a-468e-8a9f-3295432f78c9" \
  --header "User-Agent:PayPalSDK/  (v=1.7.0_51; vendor=Oracle Corporation; bit=64; os=Windows_8 6.2)" \
  --header "Content-Type:application/json" \
  --header "Accept:application/json" \
  --data '{
  "intent": "sale",
  "payer": {
    "payment_method": "paypal"
  },
  "transactions": [
    {
      "amount": {
        "currency": "BRL",
        "total": "25.00"
      },
      "description": "Test checkout.",
      "item_list": {
        "items": [
          {
            "name": "Test item",
            "quantity": "1",
            "price": "25.00",
            "currency": "BRL"
          }
        ]
      }
    }
  ],
  "redirect_urls": {
    "return_url": "http://localhost:8001",
    "cancel_url": "http://localhost:8001"
  }
}'
2018-01-29 17:04:56,069 DEBUG com.paypal.base.rest.PayPalResource:423: response: {"id":"PAY-4Y939080DF027712BLJXXAWY","intent":"sale","state":"created","payer":{"payment_method":"paypal"},"transactions":[{"amount":{"total":"25.00","currency":"BRL"},"description":"Test checkout.","item_list":{"items":[{"name":"Test item","price":"25.00","currency":"BRL","quantity":1}]},"related_resources":[]}],"create_time":"2018-01-29T19:04:59Z","links":[{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-4Y939080DF027712BLJXXAWY","rel":"self","method":"GET"},{"href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-35V70233H2912670U","rel":"approval_url","method":"REDIRECT"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-4Y939080DF027712BLJXXAWY/execute","rel":"execute","method":"POST"}]}
2018-01-29 17:05:20,336 DEBUG com.paypal.base.rest.PayPalResource:412: request header: {Authorization=Bearer A21AAG1Ev_JgNtsL4-o9w77X7AgGoGIr3eKwNxFLiXyyNyvsCNp-kkL3db8kLTJuuoEu3qlRsURqxMRjU1rEERrJx5NjGMqmA, PayPal-Mock-Response={"mock_application_codes":"AMOUNT_MISMATCH"}, User-Agent=PayPalSDK/  (v=1.7.0_51; vendor=Oracle Corporation; bit=64; os=Windows_8 6.2), PayPal-Request-Id=508258ff-1a63-4d2c-9f90-96f4eaea6299, Content-Type=application/json}
2018-01-29 17:05:20,336 DEBUG com.paypal.base.rest.PayPalResource:413: request body: {
  "payer_id": "BF898XQFFAQWA"
}
2018-01-29 17:05:20,337 DEBUG com.paypal.base.HttpConnection:225: curl command: 
curl --verbose --request POST 'https://api.sandbox.paypal.com/v1/payments/payment/PAY-4Y939080DF027712BLJXXAWY/execute' \
  --header "Authorization:Bearer A21AAG1Ev_JgNtsL4-o9w77X7AgGoGIr3eKwNxFLiXyyNyvsCNp-kkL3db8kLTJuuoEu3qlRsURqxMRjU1rEERrJx5NjGMqmA" \
  --header "PayPal-Mock-Response:{"mock_application_codes":"AMOUNT_MISMATCH"}" \
  --header "User-Agent:PayPalSDK/  (v=1.7.0_51; vendor=Oracle Corporation; bit=64; os=Windows_8 6.2)" \
  --header "PayPal-Request-Id:508258ff-1a63-4d2c-9f90-96f4eaea6299" \
  --header "Content-Type:application/json" \
  --data '{
  "payer_id": "BF898XQFFAQWA"
}'
2018-01-29 17:05:21,293 ERROR com.paypal.base.HttpConnection:153: Response code: 400	Error response: {    "name": "AMOUNT_MISMATCH",    "message": "The totals of the cart item amounts do not match sale amounts.",    "information_link": "https://developer.paypal.com/docs/api/payments/#errors",    "details": "The amount total does not match the item amount totals."}
2018-01-29 17:05:21,295 ERROR com.paypal.base.rest.PayPalRESTException:79: Exception thrown while parsing error response: {    "name": "AMOUNT_MISMATCH",    "message": "The totals of the cart item amounts do not match sale amounts.",    "information_link": "https://developer.paypal.com/docs/api/payments/#errors",    "details": "The amount total does not match the item amount totals."}
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 265
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176) ~[gson-2.2.2.jar:?]
	at com.google.gson.Gson.fromJson(Gson.java:795) ~[gson-2.2.2.jar:?]
	at com.google.gson.Gson.fromJson(Gson.java:761) ~[gson-2.2.2.jar:?]
	at com.google.gson.Gson.fromJson(Gson.java:710) ~[gson-2.2.2.jar:?]
	at com.google.gson.Gson.fromJson(Gson.java:682) ~[gson-2.2.2.jar:?]
	at com.paypal.base.rest.JSONFormatter.fromJSON(JSONFormatter.java:75) ~[rest-api-sdk-1.14.0.jar:?]
	at com.paypal.base.rest.PayPalRESTException.createFromHttpErrorException(PayPalRESTException.java:76) [rest-api-sdk-1.14.0.jar:?]
	at com.paypal.base.rest.PayPalResource.execute(PayPalResource.java:431) [rest-api-sdk-1.14.0.jar:?]
	at com.paypal.base.rest.PayPalResource.configureAndExecute(PayPalResource.java:295) [rest-api-sdk-1.14.0.jar:?]
	at com.paypal.base.rest.PayPalResource.configureAndExecute(PayPalResource.java:228) [rest-api-sdk-1.14.0.jar:?]
	at com.paypal.api.payments.Payment.execute(Payment.java:226) [rest-api-sdk-1.14.0.jar:?]
	at com.paypal.concept.test.PayPalPaymentTest.paymentNegativeTest(PayPalPaymentTest.java:83) [test-classes/:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_51]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_51]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_51]
	at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_51]
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) [junit-4.12.jar:4.12]
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) [junit-4.12.jar:4.12]
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) [junit-4.12.jar:4.12]
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) [junit-4.12.jar:4.12]
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) [.cp/:?]
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) [.cp/:?]
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538) [.cp/:?]
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) [.cp/:?]
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) [.cp/:?]
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206) [.cp/:?]
Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 265
	at com.google.gson.stream.JsonReader.expect(JsonReader.java:339) ~[gson-2.2.2.jar:?]
	at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:306) ~[gson-2.2.2.jar:?]
	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:79) ~[gson-2.2.2.jar:?]
	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:60) ~[gson-2.2.2.jar:?]
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93) ~[gson-2.2.2.jar:?]
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172) ~[gson-2.2.2.jar:?]
	... 34 more
2018-01-29 17:05:21,300 ERROR com.paypal.concept.test.PayPalPaymentTest:87: Response code: 400	Error response: {    "name": "AMOUNT_MISMATCH",    "message": "The totals of the cart item amounts do not match sale amounts.",    "information_link": "https://developer.paypal.com/docs/api/payments/#errors",    "details": "The amount total does not match the item amount totals."}
com.paypal.base.rest.PayPalRESTException: Response code: 400	Error response: {    "name": "AMOUNT_MISMATCH",    "message": "The totals of the cart item amounts do not match sale amounts.",    "information_link": "https://developer.paypal.com/docs/api/payments/#errors",    "details": "The amount total does not match the item amount totals."}
	at com.paypal.base.rest.PayPalRESTException.createFromHttpErrorException(PayPalRESTException.java:72) ~[rest-api-sdk-1.14.0.jar:?]
	at com.paypal.base.rest.PayPalResource.execute(PayPalResource.java:431) ~[rest-api-sdk-1.14.0.jar:?]
	at com.paypal.base.rest.PayPalResource.configureAndExecute(PayPalResource.java:295) ~[rest-api-sdk-1.14.0.jar:?]
	at com.paypal.base.rest.PayPalResource.configureAndExecute(PayPalResource.java:228) ~[rest-api-sdk-1.14.0.jar:?]
	at com.paypal.api.payments.Payment.execute(Payment.java:226) ~[rest-api-sdk-1.14.0.jar:?]
	at com.paypal.concept.test.PayPalPaymentTest.paymentNegativeTest(PayPalPaymentTest.java:83) [test-classes/:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_51]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_51]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_51]
	at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_51]
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) [junit-4.12.jar:4.12]
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) [junit-4.12.jar:4.12]
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) [junit-4.12.jar:4.12]
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) [junit-4.12.jar:4.12]
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) [.cp/:?]
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) [.cp/:?]
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538) [.cp/:?]
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) [.cp/:?]
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) [.cp/:?]
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206) [.cp/:?]
Caused by: com.paypal.base.exception.HttpErrorException: Response code: 400	Error response: {    "name": "AMOUNT_MISMATCH",    "message": "The totals of the cart item amounts do not match sale amounts.",    "information_link": "https://developer.paypal.com/docs/api/payments/#errors",    "details": "The amount total does not match the item amount totals."}
	at com.paypal.base.HttpConnection.executeWithStream(HttpConnection.java:162) ~[rest-api-sdk-1.14.0.jar:?]
	at com.paypal.base.HttpConnection.execute(HttpConnection.java:65) ~[rest-api-sdk-1.14.0.jar:?]
	at com.paypal.base.rest.PayPalResource.execute(PayPalResource.java:417) ~[rest-api-sdk-1.14.0.jar:?]
	... 27 more
Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://api.sandbox.paypal.com/v1/payments/payment/PAY-4Y939080DF027712BLJXXAWY/execute
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.7.0_51]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) ~[?:1.7.0_51]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.7.0_51]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[?:1.7.0_51]
	at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1675) ~[?:1.7.0_51]
	at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1673) ~[?:1.7.0_51]
	at java.security.AccessController.doPrivileged(Native Method) ~[?:1.7.0_51]
	at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1671) ~[?:1.7.0_51]
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1244) ~[?:1.7.0_51]
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254) ~[?:1.7.0_51]
	at com.paypal.base.HttpConnection.executeWithStream(HttpConnection.java:132) ~[rest-api-sdk-1.14.0.jar:?]
	at com.paypal.base.HttpConnection.execute(HttpConnection.java:65) ~[rest-api-sdk-1.14.0.jar:?]
	at com.paypal.base.rest.PayPalResource.execute(PayPalResource.java:417) ~[rest-api-sdk-1.14.0.jar:?]
	... 27 more
Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://api.sandbox.paypal.com/v1/payments/payment/PAY-4Y939080DF027712BLJXXAWY/execute
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1626) ~[?:1.7.0_51]
	at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468) ~[?:1.7.0_51]
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338) ~[?:1.7.0_51]
	at com.paypal.base.HttpConnection.executeWithStream(HttpConnection.java:117) ~[rest-api-sdk-1.14.0.jar:?]
	at com.paypal.base.HttpConnection.execute(HttpConnection.java:65) ~[rest-api-sdk-1.14.0.jar:?]
	at com.paypal.base.rest.PayPalResource.execute(PayPalResource.java:417) ~[rest-api-sdk-1.14.0.jar:?]
	... 27 more

@bluk
Copy link
Contributor

bluk commented Feb 2, 2018

Thanks for the details. I've opened https://github.com/paypal/PayPal-REST-API-issues/issues/197 to track this issue as the negative testing API is not returning a standard error response. We cannot change the Error object for backwards compatibility reasons, but the API should be fixed to return a standard response.

@bluk bluk closed this as completed Feb 2, 2018
@leandrohsilveira
Copy link
Contributor Author

So, there's no other way to simulate it?

@bluk
Copy link
Contributor

bluk commented Feb 2, 2018

@leandrohsilveira I don't believe so. The negative test simulation was recently added as a beta. I've opened an internal issue as noted in https://github.com/paypal/PayPal-REST-API-issues/issues/197 to get this fixed.

@leandrohsilveira
Copy link
Contributor Author

Ok, thanks

@lmarkus
Copy link
Contributor

lmarkus commented Mar 28, 2018

Hi all, This just came to my team today. Apologies for the delayed response.
This beta was our first foray into a new method of negative testing simulation, and it was not initially built with SDK support in mind.

However, we are currently building a more comprehensive negative testing framework, and this is definitely something we will be taking into account.

As to the current method, and because of the experimental nature of it, we can't commit to additional development time, or bug fixes at this point.

I would be more than happy to have feedback sessions on what developers are looking for in a negative testing framework from PayPal. Please hit me up on twitter @LennyMarkus

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants