Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Merge pull request #2650 from sap-labs-france/HOTFIX-PreventUserDelet…
Browse files Browse the repository at this point in the history
…ionInStripe

billing - prevent STRIPE customers deletion
  • Loading branch information
LucasBrazi06 authored Jul 8, 2021
2 parents 33e1669 + 24877f8 commit 892621a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/integration/billing/stripe/StripeBillingIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1396,13 +1396,16 @@ export default class StripeBillingIntegration extends BillingIntegration {
}

public async deleteUser(user: User): Promise<void> {
if (FeatureToggles.isFeatureActive(Feature.BILLING_PREVENT_CUSTOMER_DELETION)) {
// To be on the SAFE side - we preserve the customer on the STRIPE side
return Promise.resolve();
}
// Check Stripe
await this.checkConnection();
// const customer = await this.getCustomerByEmail(user.email);
const customerID = user.billingData?.customerID;
const customer = await this.getStripeCustomer(customerID);
if (customer && customer.id) {
// TODO - ro be clarified - is this allowed when the user has some invoices
await this.stripe.customers.del(
customer.id
);
Expand Down
2 changes: 2 additions & 0 deletions src/utils/FeatureToggles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum Feature {
BILLING_ITEM_WITH_PARKING_TIME,
BILLING_ITEM_WITH_START_DATE,
BILLING_CHECK_THRESHOLD_ON_STOP,
BILLING_PREVENT_CUSTOMER_DELETION,
}

export default class FeatureToggles {
Expand All @@ -18,6 +19,7 @@ export default class FeatureToggles {
// Feature.BILLING_ITEM_WITH_PARKING_TIME,
Feature.BILLING_ITEM_WITH_START_DATE,
Feature.BILLING_CHECK_THRESHOLD_ON_STOP,
Feature.BILLING_PREVENT_CUSTOMER_DELETION,
];

// Check whether the feature is active or not!
Expand Down

0 comments on commit 892621a

Please sign in to comment.