-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
need model howto #8
Comments
Hey Mixmastamyk, You shouldn't have to add any fields directly - just use the models as mixins to your profile, and you should be set. (ie. have Agree that we need better docs on this though, leaving this issue open until we have them. -S |
Thanks, interesting design. I chose this app over django-stripe because it had some documentation. Do I need to make a plan model? Hmmm. |
Hey, Yeah, the mixin/subclass is pretty standard, and a nice pattern. You don't need to have a plan model, unless you want to do something with it within your app. In short, I'd figure out your data needs, and see what you need to store locally. Then, use the mixins to get the functionality you need. Also, since it is open source, more/better doc pull requests are always appreciated. :) |
Sorry, I know this isn't a chat client, but what is user.stripe_id ? It seems to come out of nowhere in the view. Later on customer(Profile).stripe_customer_id is set. Are they the same thing? Is there a typo? I made a profile model so I wouldn't have to hack on the Django user so would rather not save things to user. |
Absolutely put it on your profile. And stripe_customer_id is the field you want. I think it's a typo. I'll double-check, then fix it up real quick. |
Thanks again, and for the quick response. |
Yup, and fixed up now. Will look at your pull request a bit later this week when I do my code reviews for all the projects I'm maintaining. |
Thanks. I added StripeCustomer mixin to my profile (had to go before Model). However, it doesn't have the last_4_digits field. I don't see the field in mixins.py or models.py. I guess this code hasn't actually been run? hehe. Also the form code assumes the customer was already created, but I've got it handled now. |
Parts of the code have been run, but as a part of a bigger app. The rest is (and was intended to be) pseudocode. I need to make the docs better. The It's the developer's decision on whether or not they need last_4, or any of the stripe data to be cached locally. Creating the customer's up to you, unless you have Clearly, the docs could use some cleanup. :) |
Ok, thanks. I missed that the id was in the StripeCustomer and not the StripeMixin. I found the auto-create code. Hopefully last question, :) ... what is the difference between saving the customer_id in the user profile vs saving it in the Customer table that the app created on install? |
No real difference - it's all in where you want to keep it. We designed zebra to be really, really flexible, since it often has to fit into existing billing models. (I moved mine over from chargify to stripe.) There's not really a "right" way to do it, just a lot of options of which hopefully one fits you well. :) |
curious, why wouldn't StripeCustomer use a foreign key relationship to User? |
@tomstrummer - because that's not always what someone's schema needs. In my case, my stripe accounts are tied to organizations, which have several users. For other people, it's profiles (one-to-one with user), for others, it's none of the above, and has nothing to do with users. Leaving it as a mixin is a more flexible way to solve the problem. Also, for cases where what you want is a FK to User, the recommended way is to subclass your Profile class with StripeCustomer, to keep django happy, and keep things DRY. |
Have installed the app and it is almost working correctly, however its not clear from the docs or sample app what fields I should add to my user profiles?
From the form blurb I see:
user.stripe_id, profile.last_4_digits, profile.stripe_customer_id
Would appreciate some guidance on where these come from and how to define these.
The text was updated successfully, but these errors were encountered: