{"action":"created","issue":{"url":"https://api.github.com/repos/stripe/stripe-ruby/issues/406","repository_url":"https://api.github.com/repos/stripe/stripe-ruby","labels_url":"https://api.github.com/repos/stripe/stripe-ruby/issues/406/labels{/name}","comments_url":"https://api.github.com/repos/stripe/stripe-ruby/issues/406/comments","events_url":"https://api.github.com/repos/stripe/stripe-ruby/issues/406/events","html_url":"https://github.com/stripe/stripe-ruby/issues/406","id":145123803,"number":406,"title":"1.36.2 breaks customer update","user":{"login":"alexmamonchik","id":1104799,"avatar_url":"https://avatars.githubusercontent.com/u/1104799?v=3","gravatar_id":"","url":"https://api.github.com/users/alexmamonchik","html_url":"https://github.com/alexmamonchik","followers_url":"https://api.github.com/users/alexmamonchik/followers","following_url":"https://api.github.com/users/alexmamonchik/following{/other_user}","gists_url":"https://api.github.com/users/alexmamonchik/gists{/gist_id}","starred_url":"https://api.github.com/users/alexmamonchik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexmamonchik/subscriptions","organizations_url":"https://api.github.com/users/alexmamonchik/orgs","repos_url":"https://api.github.com/users/alexmamonchik/repos","events_url":"https://api.github.com/users/alexmamonchik/events{/privacy}","received_events_url":"https://api.github.com/users/alexmamonchik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-01T08:52:41Z","updated_at":"2016-04-01T14:54:47Z","closed_at":null,"body":"Commit f7230802209bce15870ef7d840a599bcd609db7b breaks the code:\r\n\r\n```ruby\r\n  original = Stripe::Customer.create( source: 'token')\r\n  original.source = {\r\n    object: 'card',\r\n    number: '4012888888881881',\r\n    exp_year: 2018,\r\n    exp_month: 12,\r\n    cvc: 666\r\n  }\r\n  original.save\r\n```\r\n\r\nbut it works with token:\r\n```ruby\r\n  original = Stripe::Customer.create( source: 'token')\r\n  original.source = ''one_more_token\r\n  original.save\r\n```\r\n\r\nit happens in next versions of stripe too. Can you help me with that?"},"comment":{"url":"https://api.github.com/repos/stripe/stripe-ruby/issues/comments/204427675","html_url":"https://github.com/stripe/stripe-ruby/issues/406#issuecomment-204427675","issue_url":"https://api.github.com/repos/stripe/stripe-ruby/issues/406","id":204427675,"user":{"login":"alexmamonchik","id":1104799,"avatar_url":"https://avatars.githubusercontent.com/u/1104799?v=3","gravatar_id":"","url":"https://api.github.com/users/alexmamonchik","html_url":"https://github.com/alexmamonchik","followers_url":"https://api.github.com/users/alexmamonchik/followers","following_url":"https://api.github.com/users/alexmamonchik/following{/other_user}","gists_url":"https://api.github.com/users/alexmamonchik/gists{/gist_id}","starred_url":"https://api.github.com/users/alexmamonchik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexmamonchik/subscriptions","organizations_url":"https://api.github.com/users/alexmamonchik/orgs","repos_url":"https://api.github.com/users/alexmamonchik/repos","events_url":"https://api.github.com/users/alexmamonchik/events{/privacy}","received_events_url":"https://api.github.com/users/alexmamonchik/received_events","type":"User","site_admin":false},"created_at":"2016-04-01T14:54:46Z","updated_at":"2016-04-01T14:54:46Z","body":"sure!\r\n```ruby\r\nirb(main):005:0> token1 = Stripe::Token.create(:card => {:number => \"4242424242424242\", :exp_month => 4, :exp_year => 2017, :cvc => \"314\"})\r\n=> #<Stripe::Token:0x3ffe4d96ee80 id=tok_17vTRj2eZvKYlo2Cb4MaJLev> JSON: {\r\n  \"id\": \"tok_17vTRj2eZvKYlo2Cb4MaJLev\",\r\n  \"object\": \"token\",\r\n  \"card\": {\"id\":\"card_17vTRj2eZvKYlo2CH2XBEgAG\",\"object\":\"card\",\"address_city\":null,\"address_country\":null,\"address_line1\":null,\"address_line1_check\":null,\"address_line2\":null,\"address_state\":null,\"address_zip\":null,\"address_zip_check\":null,\"brand\":\"Visa\",\"country\":\"US\",\"cvc_check\":\"unchecked\",\"dynamic_last4\":null,\"exp_month\":4,\"exp_year\":2017,\"fingerprint\":\"Xt5EWLLDS7FJjR1c\",\"funding\":\"credit\",\"last4\":\"4242\",\"metadata\":{},\"name\":null,\"tokenization_method\":null},\r\n  \"client_ip\": \"46.241.7.115\",\r\n  \"created\": 1459521623,\r\n  \"livemode\": false,\r\n  \"type\": \"card\",\r\n  \"used\": false\r\n}\r\nirb(main):006:0> cus = Stripe::Customer.create(:description => \"Customer for test@example.com\", :source => token1.id)\r\n=> #<Stripe::Customer:0x3ffe4d9ce9ac id=cus_8BrBUHN1qKuoFG> JSON: {\r\n  \"id\": \"cus_8BrBUHN1qKuoFG\",\r\n  \"object\": \"customer\",\r\n  \"account_balance\": 0,\r\n  \"created\": 1459521683,\r\n  \"currency\": null,\r\n  \"default_source\": \"card_17vTRj2eZvKYlo2CH2XBEgAG\",\r\n  \"delinquent\": false,\r\n  \"description\": \"Customer for test@example.com\",\r\n  \"discount\": null,\r\n  \"email\": null,\r\n  \"livemode\": false,\r\n  \"metadata\": {},\r\n  \"shipping\": null,\r\n  \"sources\": {\"object\":\"list\",\"data\":[{\"id\":\"card_17vTRj2eZvKYlo2CH2XBEgAG\",\"object\":\"card\",\"address_city\":null,\"address_country\":null,\"address_line1\":null,\"address_line1_check\":null,\"address_line2\":null,\"address_state\":null,\"address_zip\":null,\"address_zip_check\":null,\"brand\":\"Visa\",\"country\":\"US\",\"customer\":\"cus_8BrBUHN1qKuoFG\",\"cvc_check\":\"pass\",\"dynamic_last4\":null,\"exp_month\":4,\"exp_year\":2017,\"fingerprint\":\"Xt5EWLLDS7FJjR1c\",\"funding\":\"credit\",\"last4\":\"4242\",\"metadata\":{},\"name\":null,\"tokenization_method\":null}],\"has_more\":false,\"total_count\":1,\"url\":\"/v1/customers/cus_8BrBUHN1qKuoFG/sources\"},\r\n  \"subscriptions\": {\"object\":\"list\",\"data\":[],\"has_more\":false,\"total_count\":0,\"url\":\"/v1/customers/cus_8BrBUHN1qKuoFG/subscriptions\"}\r\n}\r\n```\r\ncard_id for customer is **card_17vTRj2eZvKYlo2CH2XBEgAG**. Let's update card:\r\n```ruby\r\ncus.source = {object: 'card', number: '4012888888881881', exp_year: 2018, exp_month: 12, cvc: 666}\r\n=> {:object=>\"card\", :number=>\"4012888888881881\", :exp_year=>2018, :exp_month=>12, :cvc=>666}\r\nirb(main):008:0> cus.save\r\n=> #<Stripe::Customer:0x3ffe4d9ce9ac id=cus_8BrBUHN1qKuoFG> JSON: {\r\n  \"id\": \"cus_8BrBUHN1qKuoFG\",\r\n  \"object\": \"customer\",\r\n  \"account_balance\": 0,\r\n  \"created\": 1459521683,\r\n  \"currency\": null,\r\n  \"default_source\": \"card_17vTRj2eZvKYlo2CH2XBEgAG\",\r\n  \"delinquent\": false,\r\n  \"description\": \"Customer for test@example.com\",\r\n  \"discount\": null,\r\n  \"email\": null,\r\n  \"livemode\": false,\r\n  \"metadata\": {},\r\n  \"shipping\": null,\r\n  \"sources\": {\"object\":\"list\",\"data\":[{\"id\":\"card_17vTRj2eZvKYlo2CH2XBEgAG\",\"object\":\"card\",\"address_city\":null,\"address_country\":null,\"address_line1\":null,\"address_line1_check\":null,\"address_line2\":null,\"address_state\":null,\"address_zip\":null,\"address_zip_check\":null,\"brand\":\"Visa\",\"country\":\"US\",\"customer\":\"cus_8BrBUHN1qKuoFG\",\"cvc_check\":\"pass\",\"dynamic_last4\":null,\"exp_month\":4,\"exp_year\":2017,\"fingerprint\":\"Xt5EWLLDS7FJjR1c\",\"funding\":\"credit\",\"last4\":\"4242\",\"metadata\":{},\"name\":null,\"tokenization_method\":null}],\"has_more\":false,\"total_count\":1,\"url\":\"/v1/customers/cus_8BrBUHN1qKuoFG/sources\"},\r\n  \"subscriptions\": {\"object\":\"list\",\"data\":[],\"has_more\":false,\"total_count\":0,\"url\":\"/v1/customers/cus_8BrBUHN1qKuoFG/subscriptions\"}\r\n}\r\n```\r\nno changes. Let's use token:\r\n```ruby\r\ntoken2 = Stripe::Token.create(:card => {:number => \"4012888888881881\", :exp_month => 4, :exp_year => 2017, :cvc => \"314\"})\r\n=> #<Stripe::Token:0x3ffe4da508a8 id=tok_17vTVz2eZvKYlo2CCvAF3Kkt> JSON: {\r\n  \"id\": \"tok_17vTVz2eZvKYlo2CCvAF3Kkt\",\r\n  \"object\": \"token\",\r\n  \"card\": {\"id\":\"card_17vTVy2eZvKYlo2CNz0aUWcb\",\"object\":\"card\",\"address_city\":null,\"address_country\":null,\"address_line1\":null,\"address_line1_check\":null,\"address_line2\":null,\"address_state\":null,\"address_zip\":null,\"address_zip_check\":null,\"brand\":\"Visa\",\"country\":\"US\",\"cvc_check\":\"unchecked\",\"dynamic_last4\":null,\"exp_month\":4,\"exp_year\":2017,\"fingerprint\":\"CzzwE1ax7qiHgw16\",\"funding\":\"credit\",\"last4\":\"1881\",\"metadata\":{},\"name\":null,\"tokenization_method\":null},\r\n  \"client_ip\": \"46.241.7.115\",\r\n  \"created\": 1459521887,\r\n  \"livemode\": false,\r\n  \"type\": \"card\",\r\n  \"used\": false\r\n}\r\nirb(main):012:0> cus.source = token2.id\r\n=> \"tok_17vTVz2eZvKYlo2CCvAF3Kkt\"\r\nirb(main):013:0> cus.save\r\n=> #<Stripe::Customer:0x3ffe4d9ce9ac id=cus_8BrBUHN1qKuoFG> JSON: {\r\n  \"id\": \"cus_8BrBUHN1qKuoFG\",\r\n  \"object\": \"customer\",\r\n  \"account_balance\": 0,\r\n  \"created\": 1459521683,\r\n  \"currency\": null,\r\n  \"default_source\": \"card_17vTVy2eZvKYlo2CNz0aUWcb\",\r\n  \"delinquent\": false,\r\n  \"description\": \"Customer for test@example.com\",\r\n  \"discount\": null,\r\n  \"email\": null,\r\n  \"livemode\": false,\r\n  \"metadata\": {},\r\n  \"shipping\": null,\r\n  \"sources\": {\"object\":\"list\",\"data\":[{\"id\":\"card_17vTVy2eZvKYlo2CNz0aUWcb\",\"object\":\"card\",\"address_city\":null,\"address_country\":null,\"address_line1\":null,\"address_line1_check\":null,\"address_line2\":null,\"address_state\":null,\"address_zip\":null,\"address_zip_check\":null,\"brand\":\"Visa\",\"country\":\"US\",\"customer\":\"cus_8BrBUHN1qKuoFG\",\"cvc_check\":\"pass\",\"dynamic_last4\":null,\"exp_month\":4,\"exp_year\":2017,\"fingerprint\":\"CzzwE1ax7qiHgw16\",\"funding\":\"credit\",\"last4\":\"1881\",\"metadata\":{},\"name\":null,\"tokenization_method\":null}],\"has_more\":false,\"total_count\":1,\"url\":\"/v1/customers/cus_8BrBUHN1qKuoFG/sources\"},\r\n  \"subscriptions\": {\"object\":\"list\",\"data\":[],\"has_more\":false,\"total_count\":0,\"url\":\"/v1/customers/cus_8BrBUHN1qKuoFG/subscriptions\"}\r\n}\r\n```\r\nand now we see new card id: **card_17vTVy2eZvKYlo2CNz0aUWcb**\r\n\r\nNew serialize method removes `source` param if it contains a hash.\r\n\r\nthanks. Let me know if I can help you with something. I'm working on https://github.com/rebelidealist/stripe-ruby-mock and stripe 1.36.2 breaks few places. Thanks"}}