| no such source when creating a subscription to a paid plan | Raphael B | 11/28/16 12:46 PM | I am using stripe gem v 1.57.0, Ruby 2.3.0, Stripe API version 2016-07-06 on Ubuntu 16. I have a paid-plan called "small" and I run the following in stripe-console: and i get: Stripe::InvalidRequestError: (Status 400) (Request req_9eDifdeAcouHxI) No such source: tok_19KvD.... I thought I understood how things were supposed to work: you get a token for the card and pass that token and a plan name when creating a customer with a subscription. What am I missing? |
| Re: [stripe-api-discuss] no such source when creating a subscription to a paid plan | Remi J. | 11/28/16 12:49 PM | Hey Raphael, The issue here is that you're not using the proper parameter. You're trying to create a customer with a source so the token id (tok_XXX) needs to be passed in the `source` parameter and not in the `default_source` parameter. The latter is used to set a specific source as the new default instead once it's already been saved on the customer. For example if that customer has 3 cards and you want to change the default to a new one, you'd use the Update Customer API [1] and pass that card's id (card_XXXX) in `default_source`. Your code should be: Stripe::Customer.create(plan:"small", email:"u...@example.com", source: st.id) Hope this helps! Remi -- |
| Re: [stripe-api-discuss] no such source when creating a subscription to a paid plan | Raphael B | 11/29/16 12:42 PM | Yup, that did it. Thanks! |