1

Delete Customer

by
Published Aug 25, 2022

Permanently delete a customer and cancel its active subscriptions.

Script stripe Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 2 hours ago
1
//native
2

3
/**
4
 * Delete Customer
5
 * Permanently delete a customer and cancel its active subscriptions.
6
 */
7
export async function main(auth: RT.Stripe, customer_id: string) {
8
  const response = await fetch(
9
    `https://api.stripe.com/v1/customers/${customer_id}`,
10
    {
11
      method: "DELETE",
12
      headers: {
13
        Authorization: `Bearer ${auth.token}`,
14
        Accept: "application/json",
15
        "Stripe-Version": "2025-03-31.basil",
16
      },
17
    }
18
  )
19

20
  if (!response.ok) {
21
    throw new Error(`${response.status} ${await response.text()}`)
22
  }
23

24
  return await response.json()
25
}
26

Other submissions
  • Submitted by rossmccrann Deno
    Created 528 days ago
    1
    import Stripe from "https://esm.sh/stripe?target=deno";
    2
    
    
    3
    type Stripe = {
    4
      token: string;
    5
    };
    6
    export async function main(stripe_con: Stripe, customer_id: string) {
    7
      const token = stripe_con["token"];
    8
      const stripe = Stripe(`${token}`, {
    9
        httpClient: Stripe.createFetchHttpClient(),
    10
      });
    11
    
    
    12
      const deleted = await stripe.customers.del(`${customer_id}`);
    13
    
    
    14
      return await deleted.json();
    15
    }
    16
    
    
  • Submitted by hugo989 Bun
    Created 136 days ago
    1
    import StripeClient from "stripe@11";
    2
    
    
    3
    type Stripe = {
    4
      token: string;
    5
    };
    6
    export async function main(stripe_con: Stripe, customer_id: string) {
    7
      const token = stripe_con["token"];
    8
      const stripe = StripeClient(`${token}`, {
    9
        httpClient: StripeClient.createFetchHttpClient(),
    10
      });
    11
    
    
    12
      const deleted = await stripe.customers.del(`${customer_id}`);
    13
    
    
    14
      return await deleted.json();
    15
    }
    16