Trigger script to get the newly created customers.
by adam186 · 12/22/2022
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