Skip to content

Getting Started (with Supabase)

Complete instructions to set stripe-sync up.

Add stripe tables

By default, we add the tables under the stripe schema.

postgres.sql
sql
CREATE SCHEMA stripe;
CREATE TABLE stripe.application (
  "id" text not null,
  "name" text,
  "object" text not null
);
CREATE TABLE stripe.account (
  "business_profile" jsonb,
  "business_type" text,
  "capabilities" jsonb,
  "charges_enabled" boolean,
  "company" jsonb,
  "controller" jsonb,
  "country" text,
  "created" integer,
  "default_currency" text,
  "details_submitted" boolean,
  "email" text,
  "external_accounts" jsonb,
  "future_requirements" jsonb,
  "id" text not null,
  "individual" jsonb,
  "metadata" jsonb,
  "object" text not null,
  "payouts_enabled" boolean,
  "requirements" jsonb,
  "settings" jsonb,
  "tos_acceptance" jsonb,
  "type" text
);
CREATE TABLE stripe.application_fee (
  "account" jsonb not null,
  "amount" integer not null,
  "amount_refunded" integer not null,
  "application" jsonb not null,
  "balance_transaction" jsonb,
  "charge" jsonb not null,
  "created" integer,
  "currency" text not null,
  "id" text not null,
  "livemode" boolean,
  "object" text not null,
  "originating_transaction" jsonb,
  "refunded" boolean not null,
  "refunds" jsonb not null
);
CREATE TABLE stripe.refund (
  "amount" integer not null,
  "balance_transaction" jsonb,
  "charge" jsonb,
  "created" integer,
  "currency" text not null,
  "description" text,
  "failure_balance_transaction" jsonb,
  "failure_reason" text,
  "id" text not null,
  "instructions_email" text,
  "metadata" jsonb,
  "next_action" jsonb,
  "object" text not null,
  "payment_intent" jsonb,
  "reason" text,
  "receipt_number" text,
  "source_transfer_reversal" jsonb,
  "status" text,
  "transfer_reversal" jsonb
);
CREATE TABLE stripe.balance (
  "available" jsonb not null,
  "connect_reserved" jsonb,
  "instant_available" jsonb,
  "issuing" jsonb,
  "livemode" boolean,
  "object" text not null,
  "pending" jsonb not null
);
CREATE TABLE stripe.configuration (
  "active" boolean not null,
  "application" jsonb,
  "business_profile" jsonb not null,
  "created" integer,
  "default_return_url" text,
  "features" jsonb not null,
  "id" text not null,
  "is_default" boolean not null,
  "livemode" boolean,
  "metadata" jsonb,
  "object" text not null,
  "updated" integer not null
);
CREATE TABLE stripe.session (
  "configuration" jsonb,
  "created" integer,
  "customer" text not null,
  "id" text not null,
  "livemode" boolean,
  "locale" text,
  "object" text not null,
  "on_behalf_of" text,
  "return_url" text,
  "url" text not null
);
CREATE TABLE stripe.capability (
  "account" jsonb not null,
  "future_requirements" jsonb,
  "id" text not null,
  "object" text not null,
  "requested" boolean not null,
  "requested_at" integer,
  "requirements" jsonb,
  "status" text
);
CREATE TABLE stripe.cash_balance (
  "available" jsonb,
  "customer" text not null,
  "livemode" boolean,
  "object" text not null,
  "settings" jsonb not null
);
CREATE TABLE stripe.charge (
  "amount" integer not null,
  "amount_captured" integer not null,
  "amount_refunded" integer not null,
  "application" jsonb,
  "application_fee" jsonb,
  "application_fee_amount" integer,
  "balance_transaction" jsonb,
  "billing_details" jsonb not null,
  "calculated_statement_descriptor" text,
  "captured" boolean not null,
  "created" integer,
  "currency" text not null,
  "customer" jsonb,
  "description" text,
  "disputed" boolean not null,
  "failure_balance_transaction" jsonb,
  "failure_code" text,
  "failure_message" text,
  "fraud_details" jsonb,
  "id" text not null,
  "invoice" jsonb,
  "livemode" boolean,
  "metadata" jsonb not null,
  "object" text not null,
  "on_behalf_of" jsonb,
  "outcome" jsonb,
  "paid" boolean not null,
  "payment_intent" jsonb,
  "payment_method" text,
  "payment_method_details" jsonb,
  "radar_options" jsonb,
  "receipt_email" text,
  "receipt_number" text,
  "receipt_url" text,
  "refunded" boolean not null,
  "refunds" jsonb not null,
  "review" jsonb,
  "shipping" jsonb,
  "source_transfer" jsonb,
  "statement_descriptor" text,
  "statement_descriptor_suffix" text,
  "status" text,
  "transfer" jsonb,
  "transfer_data" jsonb,
  "transfer_group" text
);
CREATE TABLE stripe.dispute (
  "amount" integer not null,
  "balance_transactions" jsonb not null,
  "charge" jsonb not null,
  "created" integer,
  "currency" text not null,
  "evidence" jsonb not null,
  "evidence_details" jsonb not null,
  "id" text not null,
  "is_charge_refundable" boolean not null,
  "livemode" boolean,
  "metadata" jsonb not null,
  "object" text not null,
  "payment_intent" jsonb,
  "reason" text not null,
  "status" text
);
CREATE TABLE stripe.checkout_session (
  "after_expiration" jsonb,
  "allow_promotion_codes" boolean,
  "amount_subtotal" integer,
  "amount_total" integer,
  "automatic_tax" jsonb not null,
  "billing_address_collection" text,
  "cancel_url" text not null,
  "client_reference_id" text,
  "consent" jsonb,
  "consent_collection" jsonb,
  "currency" text,
  "customer" jsonb,
  "customer_creation" text,
  "customer_details" jsonb,
  "customer_email" text,
  "expires_at" integer not null,
  "id" text not null,
  "line_items" jsonb,
  "livemode" boolean,
  "locale" text,
  "metadata" jsonb,
  "mode" text not null,
  "object" text not null,
  "payment_intent" jsonb,
  "payment_link" jsonb,
  "payment_method_collection" text,
  "payment_method_options" jsonb,
  "payment_method_types" jsonb not null,
  "payment_status" text not null,
  "phone_number_collection" jsonb,
  "recovered_from" text,
  "setup_intent" jsonb,
  "shipping_address_collection" jsonb,
  "shipping_cost" jsonb,
  "shipping_details" jsonb,
  "shipping_options" jsonb not null,
  "status" text,
  "submit_type" text,
  "subscription" jsonb,
  "success_url" text not null,
  "tax_id_collection" jsonb,
  "total_details" jsonb,
  "url" text
);
CREATE TABLE stripe.coupon (
  "amount_off" integer,
  "applies_to" jsonb,
  "created" integer,
  "currency" text,
  "currency_options" jsonb,
  "duration" text not null,
  "duration_in_months" integer,
  "id" text not null,
  "livemode" boolean,
  "max_redemptions" integer,
  "metadata" jsonb,
  "name" text,
  "object" text not null,
  "percent_off" integer,
  "redeem_by" integer,
  "times_redeemed" integer not null,
  "valid" boolean not null
);
CREATE TABLE stripe.credit_note (
  "amount" integer not null,
  "created" integer,
  "currency" text not null,
  "customer" jsonb not null,
  "customer_balance_transaction" jsonb,
  "discount_amount" integer not null,
  "discount_amounts" jsonb not null,
  "id" text not null,
  "invoice" jsonb not null,
  "lines" jsonb not null,
  "livemode" boolean,
  "memo" text,
  "metadata" jsonb,
  "number" text not null,
  "object" text not null,
  "out_of_band_amount" integer,
  "pdf" text not null,
  "reason" text,
  "refund" jsonb,
  "status" text,
  "subtotal" integer not null,
  "subtotal_excluding_tax" integer,
  "tax_amounts" jsonb not null,
  "total" integer not null,
  "total_excluding_tax" integer,
  "type" text not null,
  "voided_at" integer
);
CREATE TABLE stripe.customer (
  "address" jsonb,
  "balance" integer,
  "cash_balance" jsonb,
  "created" integer,
  "currency" text,
  "default_source" jsonb,
  "delinquent" boolean,
  "description" text,
  "discount" jsonb,
  "email" text,
  "id" text not null,
  "invoice_credit_balance" jsonb,
  "invoice_prefix" text,
  "invoice_settings" jsonb,
  "livemode" boolean,
  "metadata" jsonb,
  "name" text,
  "next_invoice_sequence" integer,
  "object" text not null,
  "phone" text,
  "preferred_locales" jsonb,
  "shipping" jsonb,
  "sources" jsonb,
  "subscriptions" jsonb,
  "tax" jsonb,
  "tax_exempt" text,
  "tax_ids" jsonb,
  "test_clock" jsonb
);
CREATE TABLE stripe.discount (
  "checkout_session" text,
  "coupon" jsonb not null,
  "customer" jsonb,
  "end" integer,
  "id" text not null,
  "invoice" text,
  "invoice_item" text,
  "object" text not null,
  "promotion_code" jsonb,
  "start" integer not null,
  "subscription" text
);
CREATE TABLE stripe.source (
  "ach_credit_transfer" jsonb,
  "ach_debit" jsonb,
  "acss_debit" jsonb,
  "alipay" jsonb,
  "amount" integer,
  "au_becs_debit" jsonb,
  "bancontact" jsonb,
  "card" jsonb,
  "card_present" jsonb,
  "client_secret" text,
  "code_verification" jsonb,
  "created" integer,
  "currency" text,
  "customer" text,
  "eps" jsonb,
  "flow" text,
  "giropay" jsonb,
  "id" text not null,
  "ideal" jsonb,
  "klarna" jsonb,
  "livemode" boolean,
  "metadata" jsonb,
  "multibanco" jsonb,
  "object" text not null,
  "owner" jsonb,
  "p24" jsonb,
  "receiver" jsonb,
  "redirect" jsonb,
  "sepa_debit" jsonb,
  "sofort" jsonb,
  "source_order" jsonb,
  "statement_descriptor" text,
  "status" text,
  "three_d_secure" jsonb,
  "type" text,
  "usage" text,
  "wechat" jsonb
);
CREATE TABLE stripe.subscription (
  "application" jsonb,
  "application_fee_percent" integer,
  "automatic_tax" jsonb not null,
  "billing_cycle_anchor" integer not null,
  "billing_thresholds" jsonb,
  "cancel_at" integer,
  "cancel_at_period_end" boolean not null,
  "canceled_at" integer,
  "collection_method" text not null,
  "created" integer,
  "currency" text not null,
  "current_period_end" integer not null,
  "current_period_start" integer not null,
  "customer" jsonb not null,
  "days_until_due" integer,
  "default_payment_method" jsonb,
  "default_source" jsonb,
  "default_tax_rates" jsonb,
  "description" text,
  "discount" jsonb,
  "ended_at" integer,
  "id" text not null,
  "items" jsonb not null,
  "latest_invoice" jsonb,
  "livemode" boolean,
  "metadata" jsonb not null,
  "next_pending_invoice_item_invoice" integer,
  "object" text not null,
  "pause_collection" jsonb,
  "payment_settings" jsonb,
  "pending_invoice_item_interval" jsonb,
  "pending_setup_intent" jsonb,
  "pending_update" jsonb,
  "schedule" jsonb,
  "start_date" integer not null,
  "status" text,
  "test_clock" jsonb,
  "transfer_data" jsonb,
  "trial_end" integer,
  "trial_start" integer
);
CREATE TABLE stripe.tax_id (
  "country" text,
  "created" integer,
  "customer" jsonb,
  "id" text not null,
  "livemode" boolean,
  "object" text not null,
  "type" text not null,
  "value" text not null,
  "verification" jsonb
);
CREATE TABLE stripe.customer_cash_balance_transaction (
  "applied_to_payment" jsonb,
  "created" integer,
  "currency" text not null,
  "customer" jsonb not null,
  "ending_balance" integer not null,
  "funded" jsonb,
  "id" text not null,
  "livemode" boolean,
  "net_amount" integer not null,
  "object" text not null,
  "refunded_from_payment" jsonb,
  "type" text not null,
  "unapplied_from_payment" jsonb
);
CREATE TABLE stripe.file (
  "created" integer,
  "expires_at" integer,
  "filename" text,
  "id" text not null,
  "links" jsonb,
  "object" text not null,
  "purpose" text,
  "size" integer not null,
  "title" text,
  "type" text,
  "url" text
);
CREATE TABLE stripe.verification_session (
  "client_secret" text,
  "created" integer,
  "id" text not null,
  "last_error" jsonb,
  "last_verification_report" jsonb,
  "livemode" boolean,
  "metadata" jsonb not null,
  "object" text not null,
  "options" jsonb not null,
  "redaction" jsonb,
  "status" text,
  "type" text,
  "url" text,
  "verified_outputs" jsonb
);
CREATE TABLE stripe.invoice (
  "account_country" text,
  "account_name" text,
  "account_tax_ids" jsonb,
  "amount_due" integer not null,
  "amount_paid" integer not null,
  "amount_remaining" integer not null,
  "application" jsonb,
  "application_fee_amount" integer,
  "attempt_count" integer not null,
  "attempted" boolean not null,
  "auto_advance" boolean,
  "automatic_tax" jsonb not null,
  "billing_reason" text,
  "charge" jsonb,
  "collection_method" text not null,
  "created" integer,
  "currency" text not null,
  "custom_fields" jsonb,
  "customer" jsonb,
  "customer_address" jsonb,
  "customer_email" text,
  "customer_name" text,
  "customer_phone" text,
  "customer_shipping" jsonb,
  "customer_tax_exempt" text,
  "customer_tax_ids" jsonb,
  "default_payment_method" jsonb,
  "default_source" jsonb,
  "default_tax_rates" jsonb not null,
  "description" text,
  "discount" jsonb,
  "discounts" jsonb,
  "due_date" integer,
  "ending_balance" integer,
  "footer" text,
  "hosted_invoice_url" text,
  "id" text,
  "invoice_pdf" text,
  "last_finalization_error" jsonb,
  "lines" jsonb not null,
  "livemode" boolean,
  "metadata" jsonb,
  "next_payment_attempt" integer,
  "number" text,
  "object" text not null,
  "on_behalf_of" jsonb,
  "paid" boolean not null,
  "paid_out_of_band" boolean not null,
  "payment_intent" jsonb,
  "payment_settings" jsonb not null,
  "period_end" integer not null,
  "period_start" integer not null,
  "post_payment_credit_notes_amount" integer not null,
  "pre_payment_credit_notes_amount" integer not null,
  "quote" jsonb,
  "receipt_number" text,
  "rendering_options" jsonb,
  "starting_balance" integer not null,
  "statement_descriptor" text,
  "status" text,
  "status_transitions" jsonb not null,
  "subscription" jsonb,
  "subscription_proration_date" integer,
  "subtotal" integer not null,
  "subtotal_excluding_tax" integer,
  "tax" integer,
  "test_clock" jsonb,
  "threshold_reason" jsonb,
  "total" integer not null,
  "total_discount_amounts" jsonb,
  "total_excluding_tax" integer,
  "total_tax_amounts" jsonb not null,
  "transfer_data" jsonb,
  "webhooks_delivered_at" integer
);
CREATE TABLE stripe.invoiceitem (
  "amount" integer not null,
  "currency" text not null,
  "customer" jsonb not null,
  "date" integer not null,
  "description" text,
  "discountable" boolean not null,
  "discounts" jsonb,
  "id" text not null,
  "invoice" jsonb,
  "livemode" boolean,
  "metadata" jsonb,
  "object" text not null,
  "period" jsonb not null,
  "price" jsonb,
  "proration" boolean not null,
  "quantity" integer not null,
  "subscription" jsonb,
  "subscription_item" text,
  "tax_rates" jsonb,
  "test_clock" jsonb,
  "unit_amount" integer,
  "unit_amount_decimal" text
);
CREATE TABLE stripe.issuing_authorization (
  "amount" integer not null,
  "amount_details" jsonb,
  "approved" boolean not null,
  "authorization_method" text not null,
  "balance_transactions" jsonb not null,
  "card" jsonb not null,
  "cardholder" jsonb,
  "created" integer,
  "currency" text not null,
  "id" text not null,
  "livemode" boolean,
  "merchant_amount" integer not null,
  "merchant_currency" text not null,
  "merchant_data" jsonb not null,
  "metadata" jsonb not null,
  "object" text not null,
  "pending_request" jsonb,
  "request_history" jsonb not null,
  "status" text,
  "transactions" jsonb not null,
  "treasury" jsonb,
  "verification_data" jsonb not null,
  "wallet" text
);
CREATE TABLE stripe.issuing_card (
  "brand" text not null,
  "cancellation_reason" text,
  "cardholder" jsonb not null,
  "created" integer,
  "currency" text not null,
  "cvc" text,
  "exp_month" integer not null,
  "exp_year" integer not null,
  "financial_account" text,
  "id" text not null,
  "last4" text not null,
  "livemode" boolean,
  "metadata" jsonb not null,
  "number" text,
  "object" text not null,
  "replaced_by" jsonb,
  "replacement_for" jsonb,
  "replacement_reason" text,
  "shipping" jsonb,
  "spending_controls" jsonb not null,
  "status" text,
  "type" text not null,
  "wallets" jsonb
);
CREATE TABLE stripe.issuing_cardholder (
  "billing" jsonb not null,
  "company" jsonb,
  "created" integer,
  "email" text,
  "id" text not null,
  "individual" jsonb,
  "livemode" boolean,
  "metadata" jsonb not null,
  "name" text not null,
  "object" text not null,
  "phone_number" text,
  "requirements" jsonb not null,
  "spending_controls" jsonb,
  "status" text,
  "type" text
);
CREATE TABLE stripe.issuing_dispute (
  "amount" integer not null,
  "balance_transactions" jsonb,
  "created" integer,
  "currency" text not null,
  "evidence" jsonb not null,
  "id" text not null,
  "livemode" boolean,
  "metadata" jsonb not null,
  "object" text not null,
  "status" text,
  "transaction" jsonb not null,
  "treasury" jsonb
);
CREATE TABLE stripe.issuing_transaction (
  "amount" integer not null,
  "amount_details" jsonb,
  "authorization" jsonb,
  "balance_transaction" jsonb,
  "card" jsonb not null,
  "cardholder" jsonb,
  "created" integer,
  "currency" text not null,
  "dispute" jsonb,
  "id" text not null,
  "livemode" boolean,
  "merchant_amount" integer not null,
  "merchant_currency" text not null,
  "merchant_data" jsonb not null,
  "metadata" jsonb not null,
  "object" text not null,
  "purchase_details" jsonb,
  "treasury" jsonb,
  "type" text,
  "wallet" text
);
CREATE TABLE stripe.mandate (
  "customer_acceptance" jsonb not null,
  "id" text not null,
  "livemode" boolean,
  "multi_use" jsonb,
  "object" text not null,
  "payment_method" jsonb not null,
  "payment_method_details" jsonb not null,
  "single_use" jsonb,
  "status" text,
  "type" text not null
);
CREATE TABLE stripe.order (
  "amount_subtotal" integer not null,
  "amount_total" integer not null,
  "application" jsonb,
  "automatic_tax" jsonb,
  "billing_details" jsonb,
  "client_secret" text,
  "created" integer,
  "currency" text not null,
  "customer" jsonb,
  "description" text,
  "discounts" jsonb,
  "id" text not null,
  "ip_address" text,
  "line_items" jsonb,
  "livemode" boolean,
  "metadata" jsonb,
  "object" text not null,
  "payment" jsonb not null,
  "shipping_cost" jsonb,
  "shipping_details" jsonb,
  "status" text,
  "tax_details" jsonb,
  "total_details" jsonb not null
);
CREATE TABLE stripe.payment_intent (
  "amount" integer not null,
  "amount_capturable" integer,
  "amount_details" jsonb,
  "amount_received" integer,
  "application" jsonb,
  "application_fee_amount" integer,
  "automatic_payment_methods" jsonb,
  "canceled_at" integer,
  "cancellation_reason" text,
  "capture_method" text not null,
  "charges" jsonb,
  "client_secret" text,
  "confirmation_method" text not null,
  "created" integer,
  "currency" text not null,
  "customer" jsonb,
  "description" text,
  "id" text not null,
  "invoice" jsonb,
  "last_payment_error" jsonb,
  "livemode" boolean,
  "metadata" jsonb,
  "next_action" jsonb,
  "object" text not null,
  "on_behalf_of" jsonb,
  "payment_method" jsonb,
  "payment_method_options" jsonb,
  "payment_method_types" jsonb not null,
  "processing" jsonb,
  "receipt_email" text,
  "review" jsonb,
  "setup_future_usage" text,
  "shipping" jsonb,
  "statement_descriptor" text,
  "statement_descriptor_suffix" text,
  "status" text,
  "transfer_data" jsonb,
  "transfer_group" text
);
CREATE TABLE stripe.payment_link (
  "active" boolean not null,
  "after_completion" jsonb not null,
  "allow_promotion_codes" boolean not null,
  "application_fee_amount" integer,
  "application_fee_percent" integer,
  "automatic_tax" jsonb not null,
  "billing_address_collection" text not null,
  "consent_collection" jsonb,
  "currency" text not null,
  "customer_creation" text not null,
  "id" text not null,
  "line_items" jsonb,
  "livemode" boolean,
  "metadata" jsonb not null,
  "object" text not null,
  "on_behalf_of" jsonb,
  "payment_intent_data" jsonb,
  "payment_method_collection" text not null,
  "payment_method_types" jsonb,
  "phone_number_collection" jsonb not null,
  "shipping_address_collection" jsonb,
  "shipping_options" jsonb not null,
  "submit_type" text not null,
  "subscription_data" jsonb,
  "tax_id_collection" jsonb not null,
  "transfer_data" jsonb,
  "url" text not null
);
CREATE TABLE stripe.payment_method (
  "acss_debit" jsonb,
  "affirm" jsonb,
  "afterpay_clearpay" jsonb,
  "alipay" jsonb,
  "au_becs_debit" jsonb,
  "bacs_debit" jsonb,
  "bancontact" jsonb,
  "billing_details" jsonb not null,
  "blik" jsonb,
  "boleto" jsonb,
  "card" jsonb,
  "card_present" jsonb,
  "created" integer,
  "customer" jsonb,
  "customer_balance" jsonb,
  "eps" jsonb,
  "fpx" jsonb,
  "giropay" jsonb,
  "grabpay" jsonb,
  "id" text not null,
  "ideal" jsonb,
  "interac_present" jsonb,
  "klarna" jsonb,
  "konbini" jsonb,
  "link" jsonb,
  "livemode" boolean,
  "metadata" jsonb,
  "object" text not null,
  "oxxo" jsonb,
  "p24" jsonb,
  "paynow" jsonb,
  "promptpay" jsonb,
  "radar_options" jsonb,
  "sepa_debit" jsonb,
  "sofort" jsonb,
  "type" text,
  "us_bank_account" jsonb,
  "wechat_pay" jsonb
);
CREATE TABLE stripe.payout (
  "amount" integer not null,
  "arrival_date" integer not null,
  "automatic" boolean not null,
  "balance_transaction" jsonb,
  "created" integer,
  "currency" text not null,
  "description" text,
  "destination" jsonb,
  "failure_balance_transaction" jsonb,
  "failure_code" text,
  "failure_message" text,
  "id" text not null,
  "livemode" boolean,
  "metadata" jsonb,
  "method" text not null,
  "object" text not null,
  "original_payout" jsonb,
  "reversed_by" jsonb,
  "source_type" text not null,
  "statement_descriptor" text,
  "status" text,
  "type" text
);
CREATE TABLE stripe.person (
  "account" text not null,
  "address" jsonb,
  "address_kana" jsonb,
  "address_kanji" jsonb,
  "created" integer,
  "dob" jsonb,
  "email" text,
  "first_name" text,
  "first_name_kana" text,
  "first_name_kanji" text,
  "full_name_aliases" jsonb,
  "future_requirements" jsonb,
  "gender" text,
  "id" text not null,
  "id_number_provided" boolean,
  "id_number_secondary_provided" boolean,
  "last_name" text,
  "last_name_kana" text,
  "last_name_kanji" text,
  "maiden_name" text,
  "metadata" jsonb,
  "nationality" text,
  "object" text not null,
  "phone" text,
  "political_exposure" text,
  "registered_address" jsonb,
  "relationship" jsonb,
  "requirements" jsonb,
  "ssn_last_4_provided" boolean,
  "verification" jsonb
);
CREATE TABLE stripe.plan (
  "active" boolean not null,
  "aggregate_usage" text,
  "amount" integer,
  "amount_decimal" text,
  "billing_scheme" text not null,
  "created" integer,
  "currency" text not null,
  "id" text not null,
  "interval" text not null,
  "interval_count" integer not null,
  "livemode" boolean,
  "metadata" jsonb,
  "nickname" text,
  "object" text not null,
  "product" jsonb,
  "tiers" jsonb,
  "tiers_mode" text,
  "transform_usage" jsonb,
  "trial_period_days" integer,
  "usage_type" text not null
);
CREATE TABLE stripe.price (
  "active" boolean not null,
  "billing_scheme" text not null,
  "created" integer,
  "currency" text not null,
  "currency_options" jsonb,
  "custom_unit_amount" jsonb,
  "id" text not null,
  "livemode" boolean,
  "lookup_key" text,
  "metadata" jsonb not null,
  "nickname" text,
  "object" text not null,
  "product" jsonb not null,
  "recurring" jsonb,
  "tax_behavior" text,
  "tiers" jsonb,
  "tiers_mode" text,
  "transform_quantity" jsonb,
  "type" text not null,
  "unit_amount" integer,
  "unit_amount_decimal" text
);
CREATE TABLE stripe.product (
  "active" boolean not null,
  "created" integer,
  "default_price" jsonb,
  "description" text,
  "id" text not null,
  "images" jsonb not null,
  "livemode" boolean,
  "metadata" jsonb not null,
  "name" text not null,
  "object" text not null,
  "package_dimensions" jsonb,
  "shippable" boolean,
  "statement_descriptor" text,
  "tax_code" jsonb,
  "unit_label" text,
  "updated" integer not null,
  "url" text
);
CREATE TABLE stripe.promotion_code (
  "active" boolean not null,
  "code" text not null,
  "coupon" jsonb not null,
  "created" integer,
  "customer" jsonb,
  "expires_at" integer,
  "id" text not null,
  "livemode" boolean,
  "max_redemptions" integer,
  "metadata" jsonb,
  "object" text not null,
  "restrictions" jsonb not null,
  "times_redeemed" integer not null
);
CREATE TABLE stripe.quote (
  "amount_subtotal" integer not null,
  "amount_total" integer not null,
  "application" jsonb,
  "application_fee_amount" integer,
  "application_fee_percent" integer,
  "automatic_tax" jsonb not null,
  "collection_method" text not null,
  "computed" jsonb not null,
  "created" integer,
  "currency" text,
  "customer" jsonb,
  "default_tax_rates" jsonb,
  "description" text,
  "discounts" jsonb not null,
  "expires_at" integer not null,
  "footer" text,
  "from_quote" jsonb,
  "header" text,
  "id" text not null,
  "invoice" jsonb,
  "invoice_settings" jsonb,
  "line_items" jsonb,
  "livemode" boolean,
  "metadata" jsonb not null,
  "number" text,
  "object" text not null,
  "on_behalf_of" jsonb,
  "status" text,
  "status_transitions" jsonb not null,
  "subscription" jsonb,
  "subscription_data" jsonb not null,
  "subscription_schedule" jsonb,
  "test_clock" jsonb,
  "total_details" jsonb not null,
  "transfer_data" jsonb
);
CREATE TABLE stripe.early_fraud_warning (
  "actionable" boolean not null,
  "charge" jsonb not null,
  "created" integer,
  "fraud_type" text not null,
  "id" text not null,
  "livemode" boolean,
  "object" text not null,
  "payment_intent" jsonb
);
CREATE TABLE stripe.recipient (
  "active_account" jsonb,
  "cards" jsonb,
  "created" integer,
  "default_card" jsonb,
  "description" text,
  "email" text,
  "id" text not null,
  "livemode" boolean,
  "metadata" jsonb not null,
  "migrated_to" jsonb,
  "name" text,
  "object" text not null,
  "rolled_back_from" jsonb,
  "type" text not null
);
CREATE TABLE stripe.report_run (
  "created" integer,
  "error" text,
  "id" text not null,
  "livemode" boolean,
  "object" text not null,
  "parameters" jsonb not null,
  "report_type" text not null,
  "result" jsonb,
  "status" text,
  "succeeded_at" integer
);
CREATE TABLE stripe.report_type (
  "data_available_end" integer not null,
  "data_available_start" integer not null,
  "default_columns" jsonb,
  "id" text not null,
  "livemode" boolean,
  "name" text not null,
  "object" text not null,
  "updated" integer not null,
  "version" integer not null
);
CREATE TABLE stripe.review (
  "billing_zip" text,
  "charge" jsonb,
  "closed_reason" text,
  "created" integer,
  "id" text not null,
  "ip_address" text,
  "ip_address_location" jsonb,
  "livemode" boolean,
  "object" text not null,
  "open" boolean not null,
  "opened_reason" text not null,
  "payment_intent" jsonb,
  "reason" text not null,
  "session" jsonb
);
CREATE TABLE stripe.setup_intent (
  "application" jsonb,
  "attach_to_self" boolean,
  "cancellation_reason" text,
  "client_secret" text,
  "created" integer,
  "customer" jsonb,
  "description" text,
  "flow_directions" jsonb,
  "id" text not null,
  "last_setup_error" jsonb,
  "latest_attempt" jsonb,
  "livemode" boolean,
  "mandate" jsonb,
  "metadata" jsonb,
  "next_action" jsonb,
  "object" text not null,
  "on_behalf_of" jsonb,
  "payment_method" jsonb,
  "payment_method_options" jsonb,
  "payment_method_types" jsonb not null,
  "single_use_mandate" jsonb,
  "status" text,
  "usage" text not null
);
CREATE TABLE stripe.scheduled_query_run (
  "created" integer,
  "data_load_time" integer not null,
  "error" jsonb,
  "file" jsonb,
  "id" text not null,
  "livemode" boolean,
  "object" text not null,
  "result_available_until" integer not null,
  "sql" text not null,
  "status" text,
  "title" text not null
);
CREATE TABLE stripe.sku (
  "active" boolean not null,
  "attributes" jsonb not null,
  "created" integer,
  "currency" text not null,
  "id" text not null,
  "image" text,
  "inventory" jsonb not null,
  "livemode" boolean,
  "metadata" jsonb not null,
  "object" text not null,
  "package_dimensions" jsonb,
  "price" integer not null,
  "product" jsonb not null,
  "updated" integer not null
);
CREATE TABLE stripe.transaction (
  "ach_credit_transfer" jsonb,
  "amount" integer not null,
  "chf_credit_transfer" jsonb,
  "created" integer,
  "currency" text not null,
  "gbp_credit_transfer" jsonb,
  "id" text not null,
  "livemode" boolean,
  "object" text not null,
  "paper_check" jsonb,
  "sepa_credit_transfer" jsonb,
  "source" text not null,
  "status" text,
  "type" text not null
);
CREATE TABLE stripe.subscription_schedule (
  "application" jsonb,
  "canceled_at" integer,
  "completed_at" integer,
  "created" integer,
  "current_phase" jsonb,
  "customer" jsonb not null,
  "default_settings" jsonb not null,
  "end_behavior" text not null,
  "id" text not null,
  "livemode" boolean,
  "metadata" jsonb,
  "object" text not null,
  "phases" jsonb not null,
  "released_at" integer,
  "released_subscription" text,
  "status" text,
  "subscription" jsonb,
  "test_clock" jsonb
);
CREATE TABLE stripe.tax_rate (
  "active" boolean not null,
  "country" text,
  "created" integer,
  "description" text,
  "display_name" text not null,
  "id" text not null,
  "inclusive" boolean not null,
  "jurisdiction" text,
  "livemode" boolean,
  "metadata" jsonb,
  "object" text not null,
  "percentage" integer not null,
  "state" text,
  "tax_type" text
);
CREATE TABLE stripe.reader (
  "action" jsonb,
  "device_sw_version" text,
  "device_type" text not null,
  "id" text not null,
  "ip_address" text,
  "label" text not null,
  "livemode" boolean,
  "location" jsonb,
  "metadata" jsonb not null,
  "object" text not null,
  "serial_number" text not null,
  "status" text
);
CREATE TABLE stripe.test_clock (
  "created" integer,
  "deletes_after" integer not null,
  "frozen_time" integer not null,
  "id" text not null,
  "livemode" boolean,
  "name" text,
  "object" text not null,
  "status" text
);
CREATE TABLE stripe.topup (
  "amount" integer not null,
  "balance_transaction" jsonb,
  "created" integer,
  "currency" text not null,
  "description" text,
  "expected_availability_date" integer,
  "failure_code" text,
  "failure_message" text,
  "id" text not null,
  "livemode" boolean,
  "metadata" jsonb not null,
  "object" text not null,
  "source" jsonb,
  "statement_descriptor" text,
  "status" text,
  "transfer_group" text
);
CREATE TABLE stripe.transfer (
  "amount" integer not null,
  "amount_reversed" integer not null,
  "balance_transaction" jsonb,
  "created" integer,
  "currency" text not null,
  "description" text,
  "destination" jsonb,
  "destination_payment" jsonb,
  "id" text not null,
  "livemode" boolean,
  "metadata" jsonb not null,
  "object" text not null,
  "reversals" jsonb not null,
  "reversed" boolean not null,
  "source_transaction" jsonb,
  "source_type" text,
  "transfer_group" text
);
CREATE TABLE stripe.credit_reversal (
  "amount" integer not null,
  "currency" text not null,
  "financial_account" text not null,
  "hosted_regulatory_receipt_url" text,
  "id" text not null,
  "livemode" boolean,
  "metadata" jsonb not null,
  "network" text not null,
  "object" text not null,
  "received_credit" text not null,
  "status" text,
  "status_transitions" jsonb not null,
  "transaction" jsonb
);
CREATE TABLE stripe.debit_reversal (
  "amount" integer not null,
  "currency" text not null,
  "financial_account" text,
  "hosted_regulatory_receipt_url" text,
  "id" text not null,
  "linked_flows" jsonb,
  "livemode" boolean,
  "metadata" jsonb not null,
  "network" text not null,
  "object" text not null,
  "received_debit" text not null,
  "status" text,
  "status_transitions" jsonb not null,
  "transaction" jsonb
);
CREATE TABLE stripe.financial_account (
  "active_features" jsonb not null,
  "balance" jsonb not null,
  "country" text not null,
  "created" integer,
  "features" jsonb,
  "financial_addresses" jsonb not null,
  "id" text not null,
  "livemode" boolean,
  "metadata" jsonb,
  "object" text not null,
  "pending_features" jsonb not null,
  "platform_restrictions" jsonb,
  "restricted_features" jsonb not null,
  "status" text,
  "status_details" jsonb not null,
  "supported_currencies" jsonb not null
);
CREATE TABLE stripe.inbound_transfer (
  "amount" integer not null,
  "cancelable" boolean not null,
  "created" integer,
  "currency" text not null,
  "description" text,
  "failure_details" jsonb,
  "financial_account" text not null,
  "hosted_regulatory_receipt_url" text,
  "id" text not null,
  "linked_flows" jsonb not null,
  "livemode" boolean,
  "metadata" jsonb not null,
  "object" text not null,
  "origin_payment_method" text not null,
  "origin_payment_method_details" jsonb,
  "returned" boolean,
  "statement_descriptor" text not null,
  "status" text,
  "status_transitions" jsonb not null,
  "transaction" jsonb
);
CREATE TABLE stripe.outbound_payment (
  "amount" integer not null,
  "cancelable" boolean not null,
  "created" integer,
  "currency" text not null,
  "customer" text,
  "description" text,
  "destination_payment_method" text,
  "destination_payment_method_details" jsonb,
  "end_user_details" jsonb,
  "expected_arrival_date" integer not null,
  "financial_account" text not null,
  "hosted_regulatory_receipt_url" text,
  "id" text not null,
  "livemode" boolean,
  "metadata" jsonb not null,
  "object" text not null,
  "returned_details" jsonb,
  "statement_descriptor" text not null,
  "status" text,
  "status_transitions" jsonb not null,
  "transaction" jsonb not null
);
CREATE TABLE stripe.outbound_transfer (
  "amount" integer not null,
  "cancelable" boolean not null,
  "created" integer,
  "currency" text not null,
  "description" text,
  "destination_payment_method" text not null,
  "destination_payment_method_details" jsonb not null,
  "expected_arrival_date" integer not null,
  "financial_account" text not null,
  "hosted_regulatory_receipt_url" text,
  "id" text not null,
  "livemode" boolean,
  "metadata" jsonb not null,
  "object" text not null,
  "returned_details" jsonb,
  "statement_descriptor" text not null,
  "status" text,
  "status_transitions" jsonb not null,
  "transaction" jsonb not null
);
CREATE TABLE stripe.received_credit (
  "amount" integer not null,
  "created" integer,
  "currency" text not null,
  "description" text not null,
  "failure_code" text,
  "financial_account" text,
  "hosted_regulatory_receipt_url" text,
  "id" text not null,
  "initiating_payment_method_details" jsonb not null,
  "linked_flows" jsonb not null,
  "livemode" boolean,
  "network" text,
  "object" text not null,
  "reversal_details" jsonb,
  "status" text,
  "transaction" jsonb
);
CREATE TABLE stripe.received_debit (
  "amount" integer not null,
  "created" integer,
  "currency" text not null,
  "description" text not null,
  "failure_code" text,
  "financial_account" text,
  "hosted_regulatory_receipt_url" text,
  "id" text not null,
  "initiating_payment_method_details" jsonb,
  "linked_flows" jsonb not null,
  "livemode" boolean,
  "network" text,
  "object" text not null,
  "reversal_details" jsonb,
  "status" text,
  "transaction" jsonb
);

Update database permissions

Make sure to only use the service_role Supabase client in a protected server environment to access Stripe data.

sql
grant usage on schema stripe to service_role;
grant all privileges on all tables in schema stripe to service_role;

Update Supabase API options

Add the stripe schema to search path and make sure that Supabase/Postgrest will expose the schema to the API.

Supabase schema settings

Add Supabase Edge Functions handler

Init Supabase

bash
supabase init

Create Supabase function handler

bash
supabase functions new stripe

./supabase/functions/stripe/index.ts

ts
import { serve } from "https://deno.land/std@0.131.0/http/server.ts";
import Stripe from "https://esm.sh/stripe@9.6.0?target=deno&no-check";
import {
  createDenoHandler,
  createSupabaseAdapter,
} from "https://esm.sh/stripe-sync@0.0.9";
import { createClient } from "https://esm.sh/@supabase/supabase-js@2.0.0-rc.4";

const stripe = Stripe(Deno.env.get("STRIPE_API_KEY"), {
  httpClient: Stripe.createFetchHttpClient(),
  apiVersion: "2022-08-01",
});
const cryptoProvider = Stripe.createSubtleCryptoProvider();

export const supabaseClient = createClient(
  Deno.env.get("SUPABASE_URL") ?? "",
  Deno.env.get("SUPABASE_SERVICE_ROLE_KEY") ?? "",
  {
    db: {
      schema: "stripe",
    },
  }
);

const handler = createDenoHandler({
  databaseAdapter: createSupabaseAdapter({
    supabase: supabaseClient,
  }),
  stripe,
  cryptoProvider,
  stripeEndpointSecret: Deno.env.get("STRIPE_ENDPOINT_SECRET") ?? "",
  stripeSecretKey: Deno.env.get("STRIPE_SK") ?? "",
});

serve(handler);

Create .env file

./supabase/.env

STRIPE_SK=sk_...
STRIPE_ENDPOINT_SECRET=whsec_...

Deploy edge functions

Make sure to pass the --no-verify-jwt flat, since we want Stripe to be able to send us POST reqeusts.

supabase secrets set --env-file ./supabase/.env
supabase functions deploy stripe --no-verify-jwt

Released under the MIT License.