invertase / stripe-firebase-extensions

Repository of Firebase Extensions built by Stripe.
https://firebase.google.com/products/extensions
Apache License 2.0
435 stars 164 forks source link

Firestore Product Data overwritten when product updated on Stripe Dashboard #169

Closed DCSnip3r closed 3 years ago

DCSnip3r commented 3 years ago

Bug report

Describe the bug

Updating product details on the stripe dashboard, such as adding an image to a product, will overwrite the current firestore product document and will erase any custom fields. This is perhaps due to the webhooks using .set() without {merge : true}, or not using .update()

To Reproduce

  1. Create a product in stripe
  2. Add new fields and data to the document that is created in firestore console
  3. Upload an image or edit product data on the stripe dashboard. The sync will overwrite your fields

Expected behavior

This extension should not overwrite any user-defined fields

System information

n/a

thorsten-stripe commented 3 years ago

The source of truth for the product data is meant to be in Stripe. In order to keep things properly in sync we make sure we always mirror the product data from Stripe to Cloud Firestore. Is there any reason why you can't use the metadata on the Stripe objects for your custom data?

DCSnip3r commented 3 years ago

There are two main problems with having Stripe being the full source of truth:

1) Stripe metadata does not support all Firestore data types, such as Geopoint and Reference. 2) The prefix 'stripemetatadata' that is applied to each user-defined field is cumbersome and makes reading & de-structuring Firestore documents more bulky and difficult

thorsten-stripe commented 3 years ago

Fair. This has been changed as of version 0.1.12: https://github.com/stripe/stripe-firebase-extensions/blob/next/firestore-stripe-subscriptions/CHANGELOG.md#version-0112---2021-04-29

You can update the extension in your Firebase console to enable this.