Bulk Deleting Customers from Stripe using API

Hello everyone, my name is Dennis and I work as an automation expert at autosend. Today, I want to share an automation I built for a client facing an issue with their Stripe account.

Backstory

Their website was hacked some time ago, and the hackers gained access to the client’s API key. They attempted to test out credit cards and billing information, resulting in numerous fake customers being created in the client’s Stripe database.

To resolve this, we needed to remove all these fake customers from their Stripe account. However, Stripe’s front-end user interface only allows deleting 15 users at a time. With over 89,000 fake customers, manually deleting them would have taken an extraordinarily long time.

To tackle this efficiently, we utilized Stripe’s API and called the “delete customer” API endpoint. First, we exported the list of customers we wanted to delete into a Google Sheet. Then, we created a second Google Sheet called “delete customer.”

The Challenge

We set up an automation that would cut 100 customer records every 2 minutes from the original sheet and paste them into the “delete customer” sheet. This pacing was necessary due to limits on the number of API calls we could send to Stripe per minute.

By automating this process using a tool like Pipedream or Zapier, we could handle this repetitive task seamlessly. If done manually through the front-end interface, it would have taken months. Instead, we were able to clean out the database of bad customers within just 3 days.

If you ever face a similar issue with large-scale data manipulation on other platforms, consider leveraging automation tools like Pipedream or Zapier. They can be incredibly powerful for streamlining such repetitive tasks.

The Solution

Here is a step-by-step guide for automating the deletion of Stripe customers using Google Sheets and Pipedream:

  1. Set up a trigger in Pipedream to run every 2 minutes. This will control how frequently the automation runs to avoid hitting Stripe API limits.
  2. Configure the trigger to retrieve a range of values from a Google Sheet named “Stripe customers”. This sheet contains the full list of customer IDs that need to be deleted. The “get_values_in_range” step retrieves a subset of those IDs, in this case rows 1-100.
  3. Add a step to add multiple rows to a second Google Sheet called “delete_rows”. This step takes the 100 customer IDs retrieved in the previous step and appends them as new rows in the “delete_rows” sheet.
  4. The “delete_rows” step then iterates through each customer ID that was added to its sheet. For each one, it makes a call to the Stripe API to delete that specific customer using their unique ID.
  5. The workflow is triggered each time a new row is added to the “delete_rows” Google Sheet by the “add_multiple_rows” step. This allows it to process the deletion of customers in batches of 100 every 2 minutes.
  6. The end result is that customer IDs are gradually cut in batches from the main “Stripe customers” sheet and pasted into the “delete_rows” sheet. The deletion workflow is triggered on each new batch, deleting those 100 customers via the API. This continues until all 89,000 customers are processed.

By architecting the automation this way, it works around Stripe’s rate limits while still enabling mass deletion of customers that would be impractical to do manually through the Stripe UI. Leveraging Google Sheets as an intermediary data store and Pipedream for the API integration and scheduling enabled this complex workflow to be built without code. The client’s hacked customer database was cleaned up in a matter of days rather than months of manual effort.

Walkthrough

Share:

Facebook
Twitter
Pinterest
LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents

On Key

Related Posts