Skip to content

Commit 3f80739

Browse files
chitalianJustin Torre
andauthored
added stripe sync tables and webhook to ingest (#4717)
* added stripe sync tables and webhook to ingest * oops leaked test key * update deps --------- Co-authored-by: Justin Torre <justin@helicone.ai>
1 parent 91ffd21 commit 3f80739

39 files changed

+948
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
select 1;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
create schema if not exists "stripe";
2+
REVOKE ALL PRIVILEGES ON SCHEMA "stripe"
3+
FROM public,
4+
authenticated,
5+
service_role;
6+
create table if not exists "stripe"."products" (
7+
"id" text primary key,
8+
"object" text,
9+
"active" boolean,
10+
"description" text,
11+
"metadata" jsonb,
12+
"name" text,
13+
"created" integer,
14+
"images" jsonb,
15+
"livemode" boolean,
16+
"package_dimensions" jsonb,
17+
"shippable" boolean,
18+
"statement_descriptor" text,
19+
"unit_label" text,
20+
"updated" integer,
21+
"url" text
22+
);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
create table if not exists "stripe"."customers" (
2+
"id" text primary key,
3+
"object" text,
4+
"address" jsonb,
5+
"description" text,
6+
"email" text,
7+
"metadata" jsonb,
8+
"name" text,
9+
"phone" text,
10+
"shipping" jsonb,
11+
"balance" integer,
12+
"created" integer,
13+
"currency" text,
14+
"default_source" text,
15+
"delinquent" boolean,
16+
"discount" jsonb,
17+
"invoice_prefix" text,
18+
"invoice_settings" jsonb,
19+
"livemode" boolean,
20+
"next_invoice_sequence" integer,
21+
"preferred_locales" jsonb,
22+
"tax_exempt" text
23+
);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
DO $$
2+
BEGIN
3+
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'pricing_type') THEN
4+
create type "stripe"."pricing_type" as enum ('one_time', 'recurring');
5+
END IF;
6+
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'pricing_tiers') THEN
7+
create type "stripe"."pricing_tiers" as enum ('graduated', 'volume');
8+
END IF;
9+
--more types here...
10+
END
11+
$$;
12+
13+
14+
create table if not exists "stripe"."prices" (
15+
"id" text primary key,
16+
"object" text,
17+
"active" boolean,
18+
"currency" text,
19+
"metadata" jsonb,
20+
"nickname" text,
21+
"recurring" jsonb,
22+
"type" stripe.pricing_type,
23+
"unit_amount" integer,
24+
"billing_scheme" text,
25+
"created" integer,
26+
"livemode" boolean,
27+
"lookup_key" text,
28+
"tiers_mode" stripe.pricing_tiers,
29+
"transform_quantity" jsonb,
30+
"unit_amount_decimal" text,
31+
32+
"product" text references stripe.products
33+
);
34+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
DO $$
3+
BEGIN
4+
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'subscription_status') THEN
5+
create type "stripe"."subscription_status" as enum (
6+
'trialing',
7+
'active',
8+
'canceled',
9+
'incomplete',
10+
'incomplete_expired',
11+
'past_due',
12+
'unpaid'
13+
);
14+
END IF;
15+
END
16+
$$;
17+
18+
create table if not exists "stripe"."subscriptions" (
19+
"id" text primary key,
20+
"object" text,
21+
"cancel_at_period_end" boolean,
22+
"current_period_end" integer,
23+
"current_period_start" integer,
24+
"default_payment_method" text,
25+
"items" jsonb,
26+
"metadata" jsonb,
27+
"pending_setup_intent" text,
28+
"pending_update" jsonb,
29+
"status" "stripe"."subscription_status",
30+
"application_fee_percent" double precision,
31+
"billing_cycle_anchor" integer,
32+
"billing_thresholds" jsonb,
33+
"cancel_at" integer,
34+
"canceled_at" integer,
35+
"collection_method" text,
36+
"created" integer,
37+
"days_until_due" integer,
38+
"default_source" text,
39+
"default_tax_rates" jsonb,
40+
"discount" jsonb,
41+
"ended_at" integer,
42+
"livemode" boolean,
43+
"next_pending_invoice_item_invoice" integer,
44+
"pause_collection" jsonb,
45+
"pending_invoice_item_interval" jsonb,
46+
"start_date" integer,
47+
"transfer_data" jsonb,
48+
"trial_end" jsonb,
49+
"trial_start" jsonb,
50+
51+
"schedule" text,
52+
"customer" text references "stripe"."customers",
53+
"latest_invoice" text, -- not yet joined
54+
"plan" text -- not yet joined
55+
);
56+
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
2+
DO $$
3+
BEGIN
4+
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'invoice_status') THEN
5+
create type "stripe"."invoice_status" as enum ('draft', 'open', 'paid', 'uncollectible', 'void');
6+
END IF;
7+
END
8+
$$;
9+
10+
11+
create table if not exists "stripe"."invoices" (
12+
"id" text primary key,
13+
"object" text,
14+
"auto_advance" boolean,
15+
"collection_method" text,
16+
"currency" text,
17+
"description" text,
18+
"hosted_invoice_url" text,
19+
"lines" jsonb,
20+
"metadata" jsonb,
21+
"period_end" integer,
22+
"period_start" integer,
23+
"status" "stripe"."invoice_status",
24+
"total" bigint,
25+
"account_country" text,
26+
"account_name" text,
27+
"account_tax_ids" jsonb,
28+
"amount_due" bigint,
29+
"amount_paid" bigint,
30+
"amount_remaining" bigint,
31+
"application_fee_amount" bigint,
32+
"attempt_count" integer,
33+
"attempted" boolean,
34+
"billing_reason" text,
35+
"created" integer,
36+
"custom_fields" jsonb,
37+
"customer_address" jsonb,
38+
"customer_email" text,
39+
"customer_name" text,
40+
"customer_phone" text,
41+
"customer_shipping" jsonb,
42+
"customer_tax_exempt" text,
43+
"customer_tax_ids" jsonb,
44+
"default_tax_rates" jsonb,
45+
"discount" jsonb,
46+
"discounts" jsonb,
47+
"due_date" integer,
48+
"ending_balance" integer,
49+
"footer" text,
50+
"invoice_pdf" text,
51+
"last_finalization_error" jsonb,
52+
"livemode" boolean,
53+
"next_payment_attempt" integer,
54+
"number" text,
55+
"paid" boolean,
56+
"payment_settings" jsonb,
57+
"post_payment_credit_notes_amount" integer,
58+
"pre_payment_credit_notes_amount" integer,
59+
"receipt_number" text,
60+
"starting_balance" integer,
61+
"statement_descriptor" text,
62+
"status_transitions" jsonb,
63+
"subtotal" integer,
64+
"tax" integer,
65+
"total_discount_amounts" jsonb,
66+
"total_tax_amounts" jsonb,
67+
"transfer_data" jsonb,
68+
"webhooks_delivered_at" integer,
69+
70+
"customer" text references "stripe"."customers",
71+
"subscription" text references "stripe"."subscriptions",
72+
"payment_intent" text, -- not yet implemented
73+
"default_payment_method" text, -- not yet implemented
74+
"default_source" text, -- not yet implemented
75+
"on_behalf_of" text, -- not yet implemented
76+
"charge" text -- not yet implemented
77+
);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
create table if not exists "stripe".charges (
3+
id text primary key,
4+
object text,
5+
card jsonb,
6+
paid boolean,
7+
"order" text,
8+
amount bigint,
9+
review text,
10+
source jsonb,
11+
status text,
12+
created integer,
13+
dispute text,
14+
invoice text,
15+
outcome jsonb,
16+
refunds jsonb,
17+
updated integer,
18+
captured boolean,
19+
currency text,
20+
customer text,
21+
livemode boolean,
22+
metadata jsonb,
23+
refunded boolean,
24+
shipping jsonb,
25+
application text,
26+
description text,
27+
destination text,
28+
failure_code text,
29+
on_behalf_of text,
30+
fraud_details jsonb,
31+
receipt_email text,
32+
payment_intent text,
33+
receipt_number text,
34+
transfer_group text,
35+
amount_refunded bigint,
36+
application_fee text,
37+
failure_message text,
38+
source_transfer text,
39+
balance_transaction text,
40+
statement_descriptor text,
41+
statement_description text,
42+
payment_method_details jsonb
43+
);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
create table if not exists "stripe".coupons (
2+
id text primary key,
3+
object text,
4+
name text,
5+
valid boolean,
6+
created integer,
7+
updated integer,
8+
currency text,
9+
duration text,
10+
livemode boolean,
11+
metadata jsonb,
12+
redeem_by integer,
13+
amount_off bigint,
14+
percent_off double precision,
15+
times_redeemed bigint,
16+
max_redemptions bigint,
17+
duration_in_months bigint,
18+
percent_off_precise double precision
19+
);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
create table if not exists "stripe".disputes (
2+
id text primary key,
3+
object text,
4+
amount bigint,
5+
charge text,
6+
reason text,
7+
status text,
8+
created integer,
9+
updated integer,
10+
currency text,
11+
evidence jsonb,
12+
livemode boolean,
13+
metadata jsonb,
14+
evidence_details jsonb,
15+
balance_transactions jsonb,
16+
is_charge_refundable boolean
17+
);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
create table if not exists "stripe".events (
2+
id text primary key,
3+
object text,
4+
data jsonb,
5+
type text,
6+
created integer,
7+
request text,
8+
updated integer,
9+
livemode boolean,
10+
api_version text,
11+
pending_webhooks bigint
12+
);

0 commit comments

Comments
 (0)