Update a Customer

Update a customer. [See the docs](https://stripe.com/docs/api/customers/update) for more information

Script stripe Verified

by rossmccrann ยท 8/25/2022

The script

Submitted by hugo989 Bun
Verified 6 days ago
1
import StripeClient from "stripe@11";
2

3
type Stripe = {
4
  token: string;
5
};
6
export async function main(
7
  stripe_con: Stripe,
8
  customer_id: string,
9
  order_id: string
10
) {
11
  const token = stripe_con["token"];
12
  const stripe = StripeClient(`${token}`, {
13
    httpClient: StripeClient.createFetchHttpClient(),
14
  });
15

16
  const customer = await stripe.customers.update(`${customer_id}`, {
17
    metadata: { order_id: order_id },
18
  });
19

20
  return await customer.json();
21
}
22

Other submissions
  • Submitted by rossmccrann Deno
    Created 398 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(
    7
      stripe_con: Stripe,
    8
      customer_id: string,
    9
      order_id: string
    10
    ) {
    11
      const token = stripe_con["token"];
    12
      const stripe = Stripe(`${token}`, {
    13
        httpClient: Stripe.createFetchHttpClient(),
    14
      });
    15
    
    
    16
      const customer = await stripe.customers.update(`${customer_id}`, {
    17
        metadata: { order_id: order_id },
    18
      });
    19
    
    
    20
      return await customer.json();
    21
    }
    22