Giter Club home page Giter Club logo

Comments (13)

skoczen avatar skoczen commented on July 28, 2024

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.

mixmastamyk avatar mixmastamyk commented on July 28, 2024

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.

skoczen avatar skoczen commented on July 28, 2024

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.

mixmastamyk avatar mixmastamyk commented on July 28, 2024

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.

skoczen avatar skoczen commented on July 28, 2024

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.

mixmastamyk avatar mixmastamyk commented on July 28, 2024

Thanks again, and for the quick response.

from django-zebra.

skoczen avatar skoczen commented on July 28, 2024

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.

mixmastamyk avatar mixmastamyk commented on July 28, 2024

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.

skoczen avatar skoczen commented on July 28, 2024

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.

mixmastamyk avatar mixmastamyk commented on July 28, 2024

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.

skoczen avatar skoczen commented on July 28, 2024

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.

thom-nic avatar thom-nic commented on July 28, 2024

curious, why wouldn't StripeCustomer use a foreign key relationship to User?

from django-zebra.

skoczen avatar skoczen commented on July 28, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.