{"action":"created","issue":{"url":"https://api.github.com/repos/paypal/PayPal-PHP-SDK/issues/402","labels_url":"https://api.github.com/repos/paypal/PayPal-PHP-SDK/issues/402/labels{/name}","comments_url":"https://api.github.com/repos/paypal/PayPal-PHP-SDK/issues/402/comments","events_url":"https://api.github.com/repos/paypal/PayPal-PHP-SDK/issues/402/events","html_url":"https://github.com/paypal/PayPal-PHP-SDK/issues/402","id":107629804,"number":402,"title":"500 Error return for Invalid Payment Term instead of Validation Error","user":{"login":"onlyyou2323","id":5053486,"avatar_url":"https://avatars.githubusercontent.com/u/5053486?v=3","gravatar_id":"","url":"https://api.github.com/users/onlyyou2323","html_url":"https://github.com/onlyyou2323","followers_url":"https://api.github.com/users/onlyyou2323/followers","following_url":"https://api.github.com/users/onlyyou2323/following{/other_user}","gists_url":"https://api.github.com/users/onlyyou2323/gists{/gist_id}","starred_url":"https://api.github.com/users/onlyyou2323/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onlyyou2323/subscriptions","organizations_url":"https://api.github.com/users/onlyyou2323/orgs","repos_url":"https://api.github.com/users/onlyyou2323/repos","events_url":"https://api.github.com/users/onlyyou2323/events{/privacy}","received_events_url":"https://api.github.com/users/onlyyou2323/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/paypal/PayPal-PHP-SDK/labels/api-bug","name":"api-bug","color":"e11d21"},{"url":"https://api.github.com/repos/paypal/PayPal-PHP-SDK/labels/api-payments","name":"api-payments","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-09-22T01:25:55Z","updated_at":"2015-10-28T18:22:43Z","closed_at":null,"body":" I know this not an SDK related issue, but just to save anyone else the time I spent debugging just to realise I was passing an invalid value. And the API team might can get notified about it as well.\r\n\r\n On passing the invalid value to Payment Term  in the invoice object to create a new Invoice , a 500 response is generated instead of a 400. \r\n\r\n The method I used is Set in [PaymentTerm.php](https://github.com/paypal/PayPal-PHP-SDK/blob/master/lib/PayPal/Api/PaymentTerm.php#L19-L31). Found it the hard way. \r\n"},"comment":{"url":"https://api.github.com/repos/paypal/PayPal-PHP-SDK/issues/comments/151941174","html_url":"https://github.com/paypal/PayPal-PHP-SDK/issues/402#issuecomment-151941174","issue_url":"https://api.github.com/repos/paypal/PayPal-PHP-SDK/issues/402","id":151941174,"user":{"login":"mattgrosse","id":293231,"avatar_url":"https://avatars.githubusercontent.com/u/293231?v=3","gravatar_id":"","url":"https://api.github.com/users/mattgrosse","html_url":"https://github.com/mattgrosse","followers_url":"https://api.github.com/users/mattgrosse/followers","following_url":"https://api.github.com/users/mattgrosse/following{/other_user}","gists_url":"https://api.github.com/users/mattgrosse/gists{/gist_id}","starred_url":"https://api.github.com/users/mattgrosse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattgrosse/subscriptions","organizations_url":"https://api.github.com/users/mattgrosse/orgs","repos_url":"https://api.github.com/users/mattgrosse/repos","events_url":"https://api.github.com/users/mattgrosse/events{/privacy}","received_events_url":"https://api.github.com/users/mattgrosse/received_events","type":"User","site_admin":false},"created_at":"2015-10-28T18:22:43Z","updated_at":"2015-10-28T18:22:43Z","body":"I've noticed that 500s are returned, rather than validation errors, for the following as well:\r\n\r\n* setting the MerchantInfo->email to an email address not related to the merchant\r\n* setting the Invoice Number to a non-unique value\r\n\r\n`$invoice->getMerchantInfo()->setEmail(\"not-the-facilitator@gmail.com\");`\r\n`$invoice->setNumber('something-already-used');`\r\n\r\nI ran into both of these during my sandbox testing and it was very confusing to get back this 500 response:\r\n\r\n`Got Http response code 500 when accessing https:\\\\api.sandbox.paypal.com\\v1\\invoicing\\invoices.`"}}