1

Get recently added customers

by
Published Dec 22, 2022

Trigger script to get the newly created customers.

Scriptยท trigger stripe Verified

The script

Submitted by hugo989 Bun
Verified 14 days ago
1
import {
2
  getState,
3
  setState,
4
} from "windmill-client@1";
5
import StripeClient from "[email protected]";
6

7
type Stripe = {
8
  token: string;
9
};
10
export async function main(auth: Stripe) {
11
  const stripe = new StripeClient(auth.token, {
12
    httpClient: StripeClient.createFetchHttpClient(),
13
  });
14
  const lastCheck = (await getState()) || 0;
15
  await setState(Date.now());
16
  const customers = await stripe.customers.list({
17
    created: { gt: lastCheck },
18
  });
19
  return customers.data;
20
}
21

Other submissions
  • Submitted by adam186 Deno
    Created 406 days ago
    1
    import {
    2
      getState,
    3
      setState,
    4
    } from "https://deno.land/x/[email protected]/mod.ts";
    5
    import Stripe from "https://esm.sh/[email protected]?target=deno";
    6
    
    
    7
    type Stripe = {
    8
      token: string;
    9
    };
    10
    export async function main(auth: Stripe) {
    11
      const stripe = new Stripe(auth.token, {
    12
        httpClient: Stripe.createFetchHttpClient(),
    13
      });
    14
      const lastCheck = (await getState()) || 0;
    15
      await setState(Date.now());
    16
      const customers = await stripe.customers.list({
    17
        created: { gt: lastCheck },
    18
      });
    19
      return customers.data;
    20
    }
    21