Code Monkey home page Code Monkey logo

Comments (7)

thorsten-stripe avatar thorsten-stripe commented on May 29, 2024 1

This has been added and should roll out with the next release on Thursday. Thanks again for your input! :)

from stripe-firebase-extensions.

JakeMalis avatar JakeMalis commented on May 29, 2024 1

@thorsten-stripe If it cancelled the user subscription when deleting the account that would be amazing. Thank you so much, keep up the amazing stuff!

from stripe-firebase-extensions.

thorsten-stripe avatar thorsten-stripe commented on May 29, 2024

Thanks @JakeMalis for the kind words and the feature request :)

We're hoping to add this as a fast-follow. One important detail is: how do we handle active subscriptions for a user that is being deleted? E.g. would you want us to cancel all their active subscriptions and then delete their customer object?

Would love to hear your thoughts on that!

from stripe-firebase-extensions.

rikelk avatar rikelk commented on May 29, 2024

Maybe something like the cleanUp function here:
https://github.com/firebase/functions-samples/blob/master/stripe/functions/index.js

/**

  • When a user deletes their account, clean up after them
    */
    exports.cleanupUser = functions.auth.user().onDelete(async (user) => {
    const dbRef = admin.firestore().collection('stripe_customers');
    const customer = (await dbRef.doc(user.uid).get()).data();
    await stripe.customers.del(customer.customer_id);
    // Delete the customers payments & payment methods in firestore.
    const snapshot = await dbRef
    .doc(user.uid)
    .collection('payment_methods')
    .get();
    snapshot.forEach((snap) => snap.ref.delete());
    await dbRef.doc(user.uid).delete();
    return;
    });

if i'm right a stripe delete customer automatically deletes customer subscriptions ?

from stripe-firebase-extensions.

thorsten-stripe avatar thorsten-stripe commented on May 29, 2024

Thanks @rikelk. Yes, deleting a customer will cancel all their subscriptions. Yes, I'll add something along the lines. Will need to verify if this works together with the existing Delete User Data extension, that would be ideal.

from stripe-firebase-extensions.

jaytavares avatar jaytavares commented on May 29, 2024

Hi all, I'm going to humbly suggest that this change be backed out. Deletion of customer objects in Stripe is irreversible! Well, at least through their public API--though apparently sometimes permanently ๐Ÿ˜“. It's handled on a case-by-case basis through Stripe Support.

While yes, deletion of an Auth user would suggest a willingness to nuke data (after all, there's no undoing the deletion of the user), there are scenarios where this may happen accidentally. I just added an issue ๐Ÿ‘†with one such example. We were migrating users from one Firebase project to another (as part of a monorepo reorganization). We had previously copied data from production into the new project for testing. The Stripe Firebase extension was enabled during the testing. On cut-over day, we cleared all data from the new Firebase project to have a clean slate to import all of the latest production data. The Auth users in the new project were not production yet, but they were connected to the live Stripe customers through the extension and, upon deletion, all our live Stripe customers were deleted, all their payment methods were deleted, and all their subscriptions were cancelled.

Admittedly, I misstepped by not disabling the Stripe Firebase extension before beginning our cut over; however, that's kind of the point. Accidents happen in real life and it's our responsibility to enable fast recovery when they do. This feature is akin to foregoing database backups. Sure, you shouldn't delete data you still need, but what happens when you do?

For anyone who needs this functionality (GDPR, perhaps?), it is easily added via a short and simple cloud function. If we're using customer deletion for its side-effect of cancelling subscriptions, then I think we should just be cancelling subscriptions. You can always reactivate subscriptions cancelled in error.

from stripe-firebase-extensions.

jaytavares avatar jaytavares commented on May 29, 2024

Correction: Cancelled subscriptions cannot be reactivated.

Fortunately, Stripe Support was able to recover our deleted customers and their payment methods; however, there's no way to "un-cancel" all the subscriptions. So, we'll have to rebuild all of them from scratch. I think this confirms that automatic deletion of Stripe Customers is far too destructive an operation and shouldn't be the default behavior of this extension.

from stripe-firebase-extensions.

Related Issues (20)

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.