Comments (13)
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 MyProfileModel
inherit StripeCustomer
, MyPlanModel
inherit StripePlan
, etc.
Agree that we need better docs on this though, leaving this issue open until we have them.
-S
from django-zebra.
Thanks, interesting design. I chose this app over django-stripe because it had some documentation.
Do I need to make a plan model? Hmmm.
from django-zebra.
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. :)
from django-zebra.
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.
from django-zebra.
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.
from django-zebra.
Thanks again, and for the quick response.
from django-zebra.
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.
from django-zebra.
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.
from django-zebra.
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 last_4_digits
field is supposed to show an example of storing some data locally, to cache it for speedier access, etc.
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 ZEBRA_AUTO_CREATE_STRIPE_CUSTOMERS
set to True. Then, one would be auto-created on the first stripe_customer access.
Clearly, the docs could use some cleanup. :)
from django-zebra.
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?
from django-zebra.
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. :)
from django-zebra.
curious, why wouldn't StripeCustomer use a foreign key relationship to User?
from django-zebra.
@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.
from django-zebra.
Related Issues (17)
- Update the version on PyPi HOT 2
- Validate webhooks are actually from stripe HOT 1
- Missing semicolons in javascript HOT 1
- audit_customer_subscription fails when subscription == null HOT 4
- This project is dead HOT 8
- rvnkfjldndchbtctfb
- Upgrade Stripe.js to Ver 2
- Webhooks broken in Django 1.6 HOT 1
- Transfer Webhooks like transfer.paid and transfer.updated
- Custom User Model Breaking Profile Functionality HOT 11
- Order won't submit on Mobile Safari
- zebra not syncing with database on makemigrations?
- Add test coverage HOT 2
- Getting error when initialising django-zebra HOT 2
- Convert docs to sphinx and put on RTFD.org HOT 2
- 'User' object has no attribute 'stripe_id' HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-zebra.