Extra/Empty Customer Instance Created During Checkout
See original GitHub issueDescribe the bug
DJ-stripe is creating an additional customer object for each of my real Stripe customers upon creation. This extra (blank) customer is the one that is related to my User model, so when I try to access Stripe Customer data via the authenticated User on my site, the data comes back empty. The original Stripe Customer object (with all of the correct data) still lives in my database but is not related to a User.
I don’t know if this is a bug or an implementation issue on my end, but if this rings a bell for anyone I’d appreciate your help. I am 99% finished with my integration, but I am unable to ship the Stripe Customer Portal because it is using the blank/extra Stripe Customer and therefore does not display any data as it should.
Software versions
- dj-stripe version: 2.5
- Python version: 3.8.0
- Django version: 3.2
- Stripe API version: 2020-08-27
- Database type and version: psql (PostgreSQL) 13.2
Steps To Reproduce
This is my local configuration - to reproduce the issue your environment should match up with:
STRIPE_TEST_SECRET_KEY = reach out to dev team for this STRIPE_TEST_PUBLIC_KEY = reach out to dev team for this DJSTRIPE_WEBHOOK_SECRET = reach out to dev team for this DJSTRIPE_WEBHOOK_VALIDATION = "verify_signature" DJSTRIPE_USE_NATIVE_JSONFIELD = True DJSTRIPE_FOREIGN_KEY_TO_FIELD = "djstripe_id" DJSTRIPE_SUBSCRIBER_MODEL = "myApp.User" DJSTRIPE_SUBSCRIBER_CUSTOMER_KEY = "djstripe_subscriber" DJSTRIPE_WEBHOOK_URL=r"^stripe/\$"
If you have a matching backend configuration and a frontend which allows you to complete the Stripe checkout process, you can reproduce the issue. Simply go through the standard Stripe checkout flow and then check your database to see if two records were created instead of one. One should have the full data that you entered in Checkout (credit card number, subscription, etc.) and the other one should simply have the name and email address.
Better yet, if you have the Stripe Customer Portal integrated on your frontend you may be able to see what I mean when the empty/inactive/extra Stripe Customer ID is presented instead of the one that maps to the request user.
Can you reproduce the issue with the latest version of master?
I believe so
Expected Behavior
I expect DJ-stripe to relate the request User with the corresponding Stripe Customer instance so that I can query and access this data on my frontend and allow users to interact with the Stripe Customer Portal to manage their membership.
Actual Behavior
There should be two database records and two Stripe customers viewable in your Stripe dashboard with the same email address. One of them will also have customer data such as payment method. The other one will be empty beyond email/name. The empty one will be related to an instance of <yourApp>.User.
Issue Analytics
- State:
- Created 2 years ago
- Comments:52 (24 by maintainers)
Top GitHub Comments
Hi @Hafnernuss,
Yes that’s the plan.
@arnav13081994 Excellent! I’ll be traveling today but I’ll let you know as soon as I’m able to look it over and implement it.