You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug StripeBaseModel.sync_from_stripe_data seems to be to intended for synchronously updating a given DJ stripe model in the database from a Stripe API response (VS relying on the webhooks to asyncronously update the database).
To Reproduce
This looks to be working fine if you use this method for a brand new model instance (since a get_or_create_from_stripe_object is used), but does not persist changes if you are updating an existing instance.
# invoice is persisted to the database if a brand new object is created
invoice_obj = Invoice._api_create(...)
invoice = Invoice.sync_from_stripe_data(invoice_obj)
# updated to paid_invoice are NOT persisted to the database
paid_invoice_obj = invoice.api_retrieve().pay()
paid_invoice = Invoice.sync_from_stripe_data(paid_invoice_obj)
# This will persist the changes
paid_invoice.save()
I believe if you add an instance.save() call here that will fix things.
Software versions
Dj-Stripe version:
Python version:
Django version:
Stripe API version:
Database type and version:
The text was updated successfully, but these errors were encountered:
MattTheRed
changed the title
Invoice.sync_from_stripe_data only persists data if its a new instance
StripeBaseModel.sync_from_stripe_data only persists data if its a new instance
Mar 11, 2024
MattTheRed
changed the title
StripeBaseModel.sync_from_stripe_data only persists data if its a new instance
StripeBaseModel.sync_from_stripe_data only persists data if its a new instance, but won't update an existing instance
Mar 11, 2024
Describe the bug
StripeBaseModel.sync_from_stripe_data seems to be to intended for synchronously updating a given DJ stripe model in the database from a Stripe API response (VS relying on the webhooks to asyncronously update the database).
To Reproduce
This looks to be working fine if you use this method for a brand new model instance (since a
get_or_create_from_stripe_object
is used), but does not persist changes if you are updating an existing instance.I believe if you add an
instance.save()
call here that will fix things.Software versions
The text was updated successfully, but these errors were encountered: