{"action":"created","issue":{"url":"https://api.github.com/repos/jaymedavis/stripe.net/issues/905","repository_url":"https://api.github.com/repos/jaymedavis/stripe.net","labels_url":"https://api.github.com/repos/jaymedavis/stripe.net/issues/905/labels{/name}","comments_url":"https://api.github.com/repos/jaymedavis/stripe.net/issues/905/comments","events_url":"https://api.github.com/repos/jaymedavis/stripe.net/issues/905/events","html_url":"https://github.com/jaymedavis/stripe.net/pull/905","id":232422407,"number":905,"title":"Fixed bug: NullReferenceException in SourceConverter.ReadJson","user":{"login":"carlosboeing","id":3394597,"avatar_url":"https://avatars0.githubusercontent.com/u/3394597?v=3","gravatar_id":"","url":"https://api.github.com/users/carlosboeing","html_url":"https://github.com/carlosboeing","followers_url":"https://api.github.com/users/carlosboeing/followers","following_url":"https://api.github.com/users/carlosboeing/following{/other_user}","gists_url":"https://api.github.com/users/carlosboeing/gists{/gist_id}","starred_url":"https://api.github.com/users/carlosboeing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carlosboeing/subscriptions","organizations_url":"https://api.github.com/users/carlosboeing/orgs","repos_url":"https://api.github.com/users/carlosboeing/repos","events_url":"https://api.github.com/users/carlosboeing/events{/privacy}","received_events_url":"https://api.github.com/users/carlosboeing/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-05-31T00:45:43Z","updated_at":"2017-05-31T01:42:58Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/jaymedavis/stripe.net/pulls/905","html_url":"https://github.com/jaymedavis/stripe.net/pull/905","diff_url":"https://github.com/jaymedavis/stripe.net/pull/905.diff","patch_url":"https://github.com/jaymedavis/stripe.net/pull/905.patch"},"body":"It happens when Source has been deleted (e.g: payout with deleted bank account) as there's no \"object\" attribute present.\r\n\r\nFor instance, in a payout with a bank account the destination object should be something like this (this could also be a card, therefore we use Source):\r\n\r\n```\r\n\"destination\": {\r\n    \"id\": \"ba_xxxxxx\",\r\n    \"object\": \"bank_account\",\r\n    \"account\": \"acct_xxxxxxxx\",\r\n    \"account_holder_name\": null,\r\n    \"account_holder_type\": null,\r\n    \"bank_name\": \"BANK NAME\",\r\n    \"country\": \"US\",\r\n    \"currency\": \"usd\",\r\n    \"default_for_currency\": true,\r\n    \"fingerprint\": \"xxxxxxxxxx\",\r\n    \"last4\": \"6789\",\r\n    \"metadata\": {},\r\n    \"routing_number\": \"110000000\",\r\n    \"status\": \"new\"\r\n  }\r\n```\r\n\r\nNow the issue is that Stripe is returning a completely different payload when destination (bank account or card) associated to the payout has been deleted:\r\n\r\n```\r\n\"destination\": {\r\n    \"deleted\": true,\r\n    \"id\": \"ba_xxxxxx\",\r\n    \"currency\": \"usd\"\r\n  }\r\n```\r\n\r\nThis was throwing a null reference exception during deserialization in the SourceConverter.\r\n"},"comment":{"url":"https://api.github.com/repos/jaymedavis/stripe.net/issues/comments/305058078","html_url":"https://github.com/jaymedavis/stripe.net/pull/905#issuecomment-305058078","issue_url":"https://api.github.com/repos/jaymedavis/stripe.net/issues/905","id":305058078,"user":{"login":"jaymedavis","id":171522,"avatar_url":"https://avatars1.githubusercontent.com/u/171522?v=3","gravatar_id":"","url":"https://api.github.com/users/jaymedavis","html_url":"https://github.com/jaymedavis","followers_url":"https://api.github.com/users/jaymedavis/followers","following_url":"https://api.github.com/users/jaymedavis/following{/other_user}","gists_url":"https://api.github.com/users/jaymedavis/gists{/gist_id}","starred_url":"https://api.github.com/users/jaymedavis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaymedavis/subscriptions","organizations_url":"https://api.github.com/users/jaymedavis/orgs","repos_url":"https://api.github.com/users/jaymedavis/repos","events_url":"https://api.github.com/users/jaymedavis/events{/privacy}","received_events_url":"https://api.github.com/users/jaymedavis/received_events","type":"User","site_admin":false},"created_at":"2017-05-31T01:42:58Z","updated_at":"2017-05-31T01:42:58Z","body":"nice catch. I wonder if it might make sense to add a StripeDeleted reference to Source, and then check to see if deleted is present and populate that object. Would this be useful in your implementation, or is it easy enough to just say it's null and carry on?\r\n\r\nJust a thought - this doesn't need to block the PR."}}
{"actor":{"display_login":"jaymedavis"}}