{"action":"created","issue":{"url":"https://api.github.com/repos/paypal/PayPal-Java-SDK/issues/194","repository_url":"https://api.github.com/repos/paypal/PayPal-Java-SDK","labels_url":"https://api.github.com/repos/paypal/PayPal-Java-SDK/issues/194/labels{/name}","comments_url":"https://api.github.com/repos/paypal/PayPal-Java-SDK/issues/194/comments","events_url":"https://api.github.com/repos/paypal/PayPal-Java-SDK/issues/194/events","html_url":"https://github.com/paypal/PayPal-Java-SDK/issues/194","id":161549678,"number":194,"title":"Getting UNKNOWN_ERROR on Authorization and Sale attempt","user":{"login":"jamesmjones00123","id":5638917,"avatar_url":"https://avatars.githubusercontent.com/u/5638917?v=3","gravatar_id":"","url":"https://api.github.com/users/jamesmjones00123","html_url":"https://github.com/jamesmjones00123","followers_url":"https://api.github.com/users/jamesmjones00123/followers","following_url":"https://api.github.com/users/jamesmjones00123/following{/other_user}","gists_url":"https://api.github.com/users/jamesmjones00123/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesmjones00123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesmjones00123/subscriptions","organizations_url":"https://api.github.com/users/jamesmjones00123/orgs","repos_url":"https://api.github.com/users/jamesmjones00123/repos","events_url":"https://api.github.com/users/jamesmjones00123/events{/privacy}","received_events_url":"https://api.github.com/users/jamesmjones00123/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/paypal/PayPal-Java-SDK/labels/api-bug","name":"api-bug","color":"fbca04"},{"url":"https://api.github.com/repos/paypal/PayPal-Java-SDK/labels/api-payments","name":"api-payments","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-06-21T21:59:35Z","updated_at":"2016-06-22T19:54:21Z","closed_at":null,"body":"This is in Sandbox. When I try a sale or authorization with a VALID CC number I get:\r\n\r\n```\r\nresponse-code: 400\tdetails: name: UNKNOWN_ERROR\tmessage: An unknown error has occurred\tdetails: null\tdebug-id: e5f28243a9d0a\tinformation-link: https://developer.paypal.com/webapps/developer/docs/api/#UNKNOWN_ERROR\r\n\tat com.paypal.base.rest.PayPalRESTException.createFromHttpErrorException(PayPalRESTException.java:73)\r\n\tat com.paypal.base.rest.PayPalResource.execute(PayPalResource.java:441)\r\n\tat com.paypal.base.rest.PayPalResource.configureAndExecute(PayPalResource.java:269)\r\n\tat com.paypal.api.payments.Payment.create(Payment.java:484)\r\n\tat com.serviceproviders.Paypal.processAuthorization(Paypal.java:235)\r\n\tat com.objects.Billing.processAuthorization(Billing.java:83)\r\n\tat com.test.TestHarness.main(TestHarness.java:34)\r\nCaused by: com.paypal.base.exception.HttpErrorException: Error code : 400 with response : {\"name\":\"UNKNOWN_ERROR\",\"message\":\"An unknown error has occurred\",\"information_link\":\"https://developer.paypal.com/webapps/developer/docs/api/#UNKNOWN_ERROR\",\"debug_id\":\"e5f28243a9d0a\"}\r\n\tat com.paypal.base.HttpConnection.executeWithStream(HttpConnection.java:174)\r\n\tat com.paypal.base.HttpConnection.execute(HttpConnection.java:67)\r\n\tat com.paypal.base.rest.PayPalResource.execute(PayPalResource.java:427)\r\n\t... 5 more\r\nCaused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://api.sandbox.paypal.com/v1/payments/payment\r\n```\r\nBut what is interesting is that if I make the CC number incorrect it fails and gives me a correct error message: \r\n\r\n```\r\nresponse-code: 400\tdetails: name: VALIDATION_ERROR\tmessage: Invalid request - see details\tdetails: [{\r\n  \"field\": \"payer.funding_instruments[0].credit_card.number\",\r\n  \"issue\": \"Value is invalid\"\r\n}]\r\n```\r\n\r\nSo I am talking to the back end OK it appears. Environment is as follows:\r\n\r\n```\r\n\t\t<dependency>\r\n\t\t\t<groupId>com.paypal.sdk</groupId>\r\n\t\t\t<artifactId>rest-api-sdk</artifactId>\r\n\t\t\t<version>1.6.0</version>\r\n\t\t</dependency>\r\n```\r\n\r\n```\r\n# Connection Information\r\nhttp.ConnectionTimeOut=5000\r\nhttp.Retry=1\r\nhttp.ReadTimeOut=30000\r\nhttp.MaxConnection=100\r\n\r\n# HTTP Proxy configuration\r\n# If you are using proxy set http.UseProxy to true and replace the following values with your proxy parameters\r\nhttp.ProxyPort=8080\r\nhttp.ProxyHost=127.0.0.1\r\nhttp.UseProxy=false\r\nhttp.ProxyUserName=null\r\nhttp.ProxyPassword=null\r\n\r\n#Set this property to true if you are using the PayPal SDK within a Google App Engine java app\r\nhttp.GoogleAppEngine = false\r\n\r\n# Service Configuration\r\nservice.EndPoint=https://api.sandbox.paypal.com\r\n# Live EndPoint\r\n# service.EndPoint=https://api.paypal.com\r\n\r\n# Credentials\r\nclientId=AcD8V2s............removed.............................................................\r\nclientSecret=EBpT...........removed.............................................................\r\n\r\n# Webhook Validation\r\n#webhook.trustCert=DigiCertSHA2ExtendedValidationServerCA.crt\r\n```\r\n\r\n```\r\n\tpublic static String processAuthorization(Billing b, String amountToCharge) {\r\n\t\tPayment createdPayment = null;\r\n\t\ttry {\r\n\t\t\tOAuthTokenCredential tokenCredential = Payment.initConfig(new File(\"src/paypal.properties\"));\r\n\t\t\tString accessToken = tokenCredential.getAccessToken();\t\t\r\n\t\t\t// ###Address\r\n\t\t\t// Base Address object used as shipping or billing\r\n\t\t\t// address in a payment. [Optional]\r\n\t\t\tAddress billingAddress = new Address();\r\n\t\t\tbillingAddress.setCity(b.getCreditCardCity());\r\n\t\t\tbillingAddress.setCountryCode(\"US\");\r\n\t\t\tbillingAddress.setLine1(b.getCreditCardStreetAddress1());\r\n\t\t\tbillingAddress.setLine2(b.getCreditCardStreetAddress2());\r\n\t\t\tbillingAddress.setPostalCode(b.getCreditCardZip());\r\n\t\t\tbillingAddress.setState(b.getCreditCardState());\r\n\r\n\t\t\t// ###CreditCard\r\n\t\t\t// A resource representing a credit card that can be\r\n\t\t\t// used to fund a payment.\r\n\t\t\tCreditCard creditCard = new CreditCard();\r\n\t\t\tcreditCard.setBillingAddress(billingAddress);\r\n\t\t\tcreditCard.setCvv2(Integer.parseInt(b.getCreditCardCVV()));\r\n\t\t\tcreditCard.setExpireMonth(Integer.parseInt(b.getCreditCardExpirationMonth()));\r\n\t\t\tcreditCard.setExpireYear(Integer.parseInt(b.getCreditCardExpirationYear()));\r\n\t\t\tcreditCard.setFirstName(b.getCreditCardFirstName());\r\n\t\t\tcreditCard.setLastName(b.getCreditCardLastName());\r\n\t\t\tcreditCard.setNumber(b.getCreditCardNumber());\r\n\t\t\tcreditCard.setType(b.getCreditCardType());\r\n\r\n\t\t\t// ###Details\r\n\t\t\t// Let's you specify details of a payment amount.\r\n\t\t\t//Details details = new Details();\r\n\t\t\t//details.setShipping(\"1\");\r\n\t\t\t//details.setSubtotal(\"5\");\r\n\t\t\t//details.setTax(\"1\");\r\n\r\n\t\t\t// ###Amount\r\n\t\t\t// Let's you specify a payment amount.\r\n\t\t\tAmount amount = new Amount();\r\n\t\t\tamount.setCurrency(\"USD\");\r\n\t\t\t// Total must be equal to sum of shipping, tax and subtotal.\r\n\t\t\tamount.setTotal(amountToCharge);\r\n\t\t\t//amount.setDetails(details);\r\n\r\n\t\t\t// ###Transaction\r\n\t\t\t// A transaction defines the contract of a\r\n\t\t\t// payment - what is the payment for and who\r\n\t\t\t// is fulfilling it. Transaction is created with\r\n\t\t\t// a `Payee` and `Amount` types\r\n\t\t\tTransaction transaction = new Transaction();\r\n\t\t\ttransaction.setAmount(amount);\r\n\t\t\ttransaction.setDescription(\"PhoneCall.com\");\r\n\r\n\t\t\t// The Payment creation API requires a list of\r\n\t\t\t// Transaction; add the created `Transaction`\r\n\t\t\t// to a List\r\n\t\t\tList<Transaction> transactions = new ArrayList<Transaction>();\r\n\t\t\ttransactions.add(transaction);\r\n\r\n\t\t\t// ###FundingInstrument\r\n\t\t\t// A resource representing a Payeer's funding instrument.\r\n\t\t\t// Use a Payer ID (A unique identifier of the payer generated\r\n\t\t\t// and provided by the facilitator. This is required when\r\n\t\t\t// creating or using a tokenized funding instrument)\r\n\t\t\t// and the `CreditCardDetails`\r\n\t\t\tFundingInstrument fundingInstrument = new FundingInstrument();\r\n\t\t\tfundingInstrument.setCreditCard(creditCard);\r\n\r\n\t\t\t// The Payment creation API requires a list of\r\n\t\t\t// FundingInstrument; add the created `FundingInstrument`\r\n\t\t\t// to a List\r\n\t\t\tList<FundingInstrument> fundingInstrumentList = new ArrayList<FundingInstrument>();\r\n\t\t\tfundingInstrumentList.add(fundingInstrument);\r\n\r\n\t\t\t// ###Payer\r\n\t\t\t// A resource representing a Payer that funds a payment\r\n\t\t\t// Use the List of `FundingInstrument` and the Payment Method\r\n\t\t\t// as 'credit_card'\r\n\t\t\tPayer payer = new Payer();\r\n\t\t\tpayer.setFundingInstruments(fundingInstrumentList);\r\n\t\t\tpayer.setPaymentMethod(\"credit_card\");\r\n\r\n\t\t\t// ###Payment\r\n\t\t\t// A Payment Resource; create one using\r\n\t\t\t// the above types and intent as 'sale'\r\n\t\t\tPayment payment = new Payment();\r\n\t\t\tpayment.setIntent(\"authorize\");\r\n\t\t\tpayment.setPayer(payer);\r\n\t\t\tpayment.setTransactions(transactions);\r\n\t\t\t\r\n\r\n\t\t\t// ###AccessToken\r\n\t\t\t// Retrieve the access token from\r\n\t\t\t// OAuthTokenCredential by passing in\r\n\t\t\t// ClientID and ClientSecret\r\n\t\t\t// It is not mandatory to generate Access Token on a per call basis.\r\n\t\t\t// Typically the access token can be generated once and\r\n\t\t\t// reused within the expiry window\r\n\r\n\t\t\t// JMJ accessToken = GenerateAccessToken.getAccessToken();\r\n\r\n\t\t\t// ### Api Context\r\n\t\t\t// Pass in a `ApiContext` object to authenticate\r\n\t\t\t// the call and to send a unique request id\r\n\t\t\t// (that ensures idempotency). The SDK generates\r\n\t\t\t// a request id if you do not pass one explicitly.\r\n\t\t\tAPIContext apiContext = new APIContext(accessToken);\r\n\t\t\t// Use this variant if you want to pass in a request id\r\n\t\t\t// that is meaningful in your application, ideally\r\n\t\t\t// a order id.\r\n\t\t\t/*\r\n\t\t\t * String requestId = Long.toString(System.nanoTime(); APIContext\r\n\t\t\t * apiContext = new APIContext(accessToken, requestId ));\r\n\t\t\t */\r\n\r\n\t\t\t// Create a payment by posting to the APIService\r\n\t\t\t// using a valid AccessToken\r\n\t\t\t// The return object contains the status;\r\n\t\t\tcreatedPayment = payment.create(apiContext);\r\n\r\n\t\t\t//LOGGER.info(\"Created payment with id = \" + createdPayment.getId()\r\n\t\t\t//\t\t+ \" and status = \" + createdPayment.getState());\r\n\t\t\t//ResultPrinter.addResult(req, resp, \"Payment with Credit Card\",\r\n\t\t\t//\t\tPayment.getLastRequest(), Payment.getLastResponse(), null);\r\n\t\t} catch (PayPalRESTException e) {\r\n\t\t\te.printStackTrace();\r\n\t\t\t//ResultPrinter.addResult(req, resp, \"Payment with Credit Card\",\r\n\t\t\t//Payment.getLastRequest(), null, e.getMessage());\r\n\t\t}\r\n\t\treturn createdPayment.getState();\r\n\r\n\t}\r\n```\r\n\r\n```\r\n\t\t\tBilling b = new Billing();\r\n\t\t\tb.setUser(u);\r\n\t\t\tb.setCreditCardFirstName(\"James\");\r\n\t\t\tb.setCreditCardLastName(\"James\");\r\n\t\t\tb.setCreditCardStreetAddress1(\"123 Main St\");\r\n\t\t\tb.setCreditCardCity(\"St Petersburg\");\r\n\t\t\tb.setCreditCardState(\"FL\");\r\n\t\t\tb.setCreditCardZip(\"33701\");\r\n\t\t\tb.setCreditCardNumber(\"4147xxxxxxxxxxxx\");\r\n\t\t\tb.setCreditCardExpirationMonth(\"12\");\r\n\t\t\tb.setCreditCardExpirationYear(\"2019\");\r\n\t\t\tb.setCreditCardCVV(\"186\");\r\n\t\t\tb.setCreditCardType(\"visa\");\r\n\t\t\tString out = b.processAuthorization(\"1\");\r\n```\r\n\r\nThanks for the help, really need to get this working!"},"comment":{"url":"https://api.github.com/repos/paypal/PayPal-Java-SDK/issues/comments/227857708","html_url":"https://github.com/paypal/PayPal-Java-SDK/issues/194#issuecomment-227857708","issue_url":"https://api.github.com/repos/paypal/PayPal-Java-SDK/issues/194","id":227857708,"user":{"login":"pp-randy","id":6819909,"avatar_url":"https://avatars.githubusercontent.com/u/6819909?v=3","gravatar_id":"","url":"https://api.github.com/users/pp-randy","html_url":"https://github.com/pp-randy","followers_url":"https://api.github.com/users/pp-randy/followers","following_url":"https://api.github.com/users/pp-randy/following{/other_user}","gists_url":"https://api.github.com/users/pp-randy/gists{/gist_id}","starred_url":"https://api.github.com/users/pp-randy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pp-randy/subscriptions","organizations_url":"https://api.github.com/users/pp-randy/orgs","repos_url":"https://api.github.com/users/pp-randy/repos","events_url":"https://api.github.com/users/pp-randy/events{/privacy}","received_events_url":"https://api.github.com/users/pp-randy/received_events","type":"User","site_admin":false},"created_at":"2016-06-22T19:54:21Z","updated_at":"2016-06-22T19:54:21Z","body":"I think I see the issue and it appear to be a problem with the business account postal address; this wouldn't happen on live and I apologize it happened in the sandbox. \r\n\r\nCan you generate a new sandbox business account, leaving the default address? Then you would need a new REST App. "}}
{"actor":{"display_login":"pp-randy"}}