{"id":22793370,"url":"https://github.com/fivetran/dbt_stripe_source","last_synced_at":"2025-04-16T18:51:27.275Z","repository":{"id":37079692,"uuid":"264264416","full_name":"fivetran/dbt_stripe_source","owner":"fivetran","description":"Fivetran's Stripe source dbt package","archived":false,"fork":false,"pushed_at":"2025-03-26T22:14:00.000Z","size":64850,"stargazers_count":9,"open_issues_count":8,"forks_count":31,"subscribers_count":43,"default_branch":"main","last_synced_at":"2025-03-26T22:32:07.817Z","etag":null,"topics":["dbt","dbt-packages","fivetran","stripe"],"latest_commit_sha":null,"homepage":"https://fivetran.github.io/dbt_stripe_source/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fivetran.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-15T18:04:54.000Z","updated_at":"2025-03-25T11:25:38.000Z","dependencies_parsed_at":"2023-02-15T12:01:29.296Z","dependency_job_id":"ac872b40-8e41-4ed3-9380-37523184d6df","html_url":"https://github.com/fivetran/dbt_stripe_source","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_stripe_source","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_stripe_source/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_stripe_source/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_stripe_source/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fivetran","download_url":"https://codeload.github.com/fivetran/dbt_stripe_source/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249266639,"owners_count":21240792,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dbt","dbt-packages","fivetran","stripe"],"created_at":"2024-12-12T03:19:37.401Z","updated_at":"2025-04-16T18:51:27.267Z","avatar_url":"https://github.com/fivetran.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stripe Source dbt Package ([Docs](https://fivetran.github.io/dbt_stripe_source/))\n\n\u003cp align=\"left\"\u003e\n    \u003ca alt=\"License\"\n        href=\"https://github.com/fivetran/dbt_stripe_source/blob/main/LICENSE\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/License-Apache%202.0-blue.svg\" /\u003e\u003c/a\u003e\n    \u003ca alt=\"dbt-core\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/dbt_Core™_version-\u003e=1.3.0_,\u003c2.0.0-orange.svg\" /\u003e\u003c/a\u003e\n    \u003ca alt=\"Maintained?\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Maintained%3F-yes-green.svg\" /\u003e\u003c/a\u003e\n    \u003ca alt=\"PRs\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Contributions-welcome-blueviolet\" /\u003e\u003c/a\u003e\n    \u003ca alt=\"Fivetran Quickstart Compatible\"\n        href=\"https://fivetran.com/docs/transformations/dbt/quickstart\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Fivetran_Quickstart_Compatible%3F-yes-green.svg\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## What does this dbt package do?\n\u003c!--section=\"stripe_source_model\"--\u003e\n- Materializes [Stripe staging tables](https://fivetran.github.io/dbt_stripe_source/#!/overview/stripe_source/models/?g_v=1\u0026g_e=seeds) which leverage data in the format described by [this ERD](https://fivetran.com/docs/applications/stripe/#schemainformation). These staging tables clean, test, and prepare your Stripe data from [Fivetran's connector](https://fivetran.com/docs/applications/stripe) for analysis by doing the following:\n  - Name columns for consistency across all packages and for easier analysis\n  - Adds freshness tests to source data\n  - Adds column-level testing where applicable. For example, all primary keys are tested for uniqueness and non-null values.\n- Generates a comprehensive data dictionary of your Stripe data through the [dbt docs site](https://fivetran.github.io/dbt_stripe_source/).\n- These tables are designed to work simultaneously with our [Stripe transformation package](https://github.com/fivetran/dbt_stripe).\n\u003c!--section-end--\u003e\n\n## How do I use the dbt package?\n### Step 1: Prerequisites\nTo use this dbt package, you must have the following:\n\n- At least one Fivetran stripe connection syncing data into your destination.\n- A **BigQuery**, **Snowflake**, **Redshift**, **Databricks**, or **PostgreSQL** destination.\n\n#### Databricks Dispatch Configuration\nIf you are using a Databricks destination with this package you will need to add the below (or a variation of the below) dispatch configuration within your `dbt_project.yml`. This is required in order for the package to accurately search for macros within the `dbt-labs/spark_utils` then the `dbt-labs/dbt_utils` packages respectively.\n```yml\ndispatch:\n  - macro_namespace: dbt_utils\n    search_order: ['spark_utils', 'dbt_utils']\n```\n\n### Step 2: Install the package (skip if also using the `stripe` transformation package)\nIf you  are **not** using the [Stripe transformation package](https://github.com/fivetran/dbt_stripe), include the following package version in your `packages.yml` file. If you are installing the transform package, the source package is automatically installed as a dependency.\n\u003e TIP: Check [dbt Hub](https://hub.getdbt.com/) for the latest installation instructions or [read the dbt docs](https://docs.getdbt.com/docs/package-management) for more information on installing packages.\n```yaml\npackages:\n  - package: fivetran/stripe_source\n    version: [\"\u003e=0.14.0\", \"\u003c0.15.0\"]\n```\n### Step 3: Define database and schema variables\nBy default, this package runs using your destination and the `stripe` schema. If this is not where your stripe data is (for example, if your stripe schema is named `stripe_fivetran`), add the following configuration to your root `dbt_project.yml` file:\n\n```yml\nvars:\n    stripe_database: your_destination_name\n    stripe_schema: your_schema_name \n```\n### Step 4: Disable models for non-existent sources\nThis package takes into consideration that not every Stripe account utilizes the `invoice`, `invoice_line_item`, `payment_method`, `payment_method_card`, `plan`, `price`, `subscription`, `product`, or `credit_note` features, and allows you to disable the corresponding functionality. By default, all variables' values are assumed to be `true` with the exception of `credit_note`. Add variables for only the tables you want to disable or enable respectively:\n\n```yml\n# dbt_project.yml\n\n...\nvars:\n    stripe__using_invoices:        False  #Disable if you are not using the invoice and invoice_line_item tables\n    stripe__using_payment_method:  False  #Disable if you are not using the payment_method and payment_method_card tables\n    stripe__using_subscriptions:   False  #Disable if you are not using the subscription, product, and plan/price tables.\n    stripe__using_credit_notes:    True   #Enable if you are using the credit note tables.\n\n```\n### (Optional) Step 5: Additional configurations\n\u003cdetails open\u003e\u003csummary\u003eExpand to view configurations\u003c/summary\u003e\n\n#### Unioning Multiple Stripe Connections\nIf you have multiple Stripe connections you would like to use this package on simultaneously, we have added the ability to do so. Data from disparate connections will be unioned together and be passed downstream to the end models. The `source_relation` column will specify where each record comes from. To use this functionality, you will need to either set the `stripe_union_schemas` or `stripe_union_databases` variables. Please also make sure the single-source `stripe_database` and `stripe_schema` variables are removed.\n\n```yml\n# dbt_project.yml\n\n...\nconfig-version: 2\n\nvars:\n    stripe_union_schemas: ['stripe_us','stripe_mx'] # use this if the data is in different schemas/datasets of the same database/project\n    stripe_union_databases: ['stripe_db_1','stripe_db_2'] # use this if the data is in different databases/projects but uses the same schema name\n```\n#### Leveraging Plan vs Price Sources\n\nCustomers using Fivetran with the newer [Stripe Price API](https://stripe.com/docs/billing/migration/migrating-prices) will have a `price` table, and possibly a `plan` table if that was used previously. Therefore to accommodate two different source tables we added logic to check if there exists a `price` table by default. If not, it will leverage the `plan` table. However if you wish to use the `plan` table instead, you may set `stripe__using_price` to `false` in your `dbt_project.yml` to override the macro.\n\n```yml\n# dbt_project.yml\n\n...\nconfig-version: 2\n\nvars:\n  stripe__using_price: false #  True by default. If true, will look `price ` table. If false, will look for the `plan` table. \n```\n\n#### Leveraging Subscription Vs Subscription History Sources\nFor Stripe connections set up after February 09, 2022 the `subscription` table has been replaced with the new `subscription_history` table. By default this package will look for your subscription data within the `subscription_history` source table. However, if you have an older connection then you must configure the `stripe__using_subscription_history` to `false` in order to have the package use the `subscription` source rather than the `subscription_history` table.\n\u003e **Please note that if you have `stripe__using_subscription_history` enabled then the package will filter for only active records.**\n```yml\nvars:\n    stripe__using_subscription_history: False  # True by default. Set to False if your connection syncs the `subscription` table instead. \n```\n\n#### Running on Live vs Test Customers\nBy default, this package will run on non-test data (`where livemode = true`) from the source Stripe tables. However, you may want to include and focus on test data when testing out the package or developing your analyses. To run on only test data, add the following configuration to your root `dbt_project.yml` file:\n\n```yml\nvars:\n    stripe_source:\n        stripe__using_livemode: false  # Default = true\n```\n#### Including sub Invoice Line Items\nBy default, this package will filter out any records from the `invoice_line_item` source table which include the string `sub_`. This is due to a legacy Stripe issue where `sub_` records were found to be duplicated. However, if you highly utilize these records you may wish they be included in the final output of the `stg_stripe__invoice_line_item` model. To do, so you may include the below variable configuration in your root `dbt_project.yml`:\n```yml\nvars:\n    stripe_source:\n        stripe__using_invoice_line_sub_filter: false # Default = true\n```\n\n#### Pivoting out Metadata Properties\nOftentimes you may have custom fields within your source tables that is stored as a JSON object that you wish to pass through. By leveraging the `metadata` variable, this package pivot out fields into their own columns. The metadata variables accept dictionaries in addition to strings.\n\nAdditionally, you may `alias` your field if you happen to be using a reserved word as a metadata field, any otherwise incompatible name, or just wish to rename your field. Below are examples of how you would add the respective fields.\n\nThe `metadata` JSON field is present within the `customer`, `charge`, `card`, `dispute`, `invoice`, `invoice_line_item`, `payment_intent`, `payment_method`, `payout`, `plan`, `price`, `refund`, `subscription`, and `transfer` source tables. To pivot these fields out and include in the respective downstream staging model, add the respective variable(s) to your root `dbt_project.yml` file like below.\n\n```yml\nvars: \n  stripe__account_metadata:\n    - name: metadata_field\n    - name: another_metadata_field\n    - name: and_another_metadata_field\n  stripe__charge_metadata:\n    - name: metadata_field_1\n  stripe__card_metadata:\n    - name: metadata_field_10\n  stripe__customer_metadata:\n    - name: metadata_field_6\n      alias: metadata_field_six\n  stripe__dispute_metadata:\n    - name: dispute_metadata_field\n  stripe__invoice_metadata: \n    - name: metadata_field_2\n  stripe__invoice_line_item_metadata: \n    - name: metadata_field_20\n  stripe__payment_intent_metadata:\n    - name: incompatible.field\n      alias: rename_incompatible_field\n  stripe__payment_method_metadata:\n    - name: field_is_reserved_word\n      alias: field_is_reserved_word_xyz\n  stripe__payout_metadata:\n    - name: 123\n      alias: one_two_three\n  stripe__price_plan_metadata: ## Used for both Price and Plan sources\n    - name: rename_price\n      alias: renamed_field_price\n  stripe__refund_metadata:\n    - name: metadata_field_3\n  stripe__subscription_metadata:\n    - name: 567\n      alias: five_six_seven\n  stripe__transfer_metadata:\n    - name: transfer_metadata_field\n\n```\n\nAlternatively, if you only have strings in your JSON object, the metadata variable accepts the following configuration as well.\n\n```yml\nvars:\n    stripe__subscription_metadata: ['the', 'list', 'of', 'property', 'fields'] # Note: this is case-SENSITIVE and must match the casing of the property as it appears in the JSON\n```\n\n#### Enabling Cent to Dollar Conversion\n\nAmount-based fields, such as `amount` and `net`, are typically displayed in the smallest denomination (e.g., cents for USD). By default, amount-based fields will be in this raw form. However, some currencies use major and minor units (for example, cents and dollars when using USD). In these cases, it may be useful to divide the amounts by 100, converting amounts to major units (dollars for USD). To enable the division, configure the `stripe__convert_values` to `true` in your project.yml: \n\n```yml\nvars:\n    stripe__convert_values: true  # default is false \n```\n\nIf you are working in a currency that does not differentiate between minor and major units, such as JPY or KRW, it may make more sense to keep the amount-based fields in raw form and therefore the package can be ran without configuration. As `stripe__convert_values` is disabled by default, these fields will not be impacted.\n\n#### Passing Through Additional Fields\nThis package includes all source columns defined in the macros folder. You can add more columns using our pass-through column variables. These variables allow for the pass-through fields to be aliased (`alias`) and casted (`transform_sql`) if desired, but not required. Datatype casting is configured via a sql snippet within the `transform_sql` key. You may add the desired sql while omitting the `as field_name` at the end and your custom pass-though fields will be casted accordingly. Use the below format for declaring the respective pass-through variables:\n\n```yml\n# dbt_project.yml\n\nvars:\n  stripe_source:\n    card_pass_through_columns:\n      - name: \"description\"\n      - name: \"iin\"\n      - name: \"issuer\"\n        alias: \"card_issuer\"  # optional: define an alias for the column \n        transform_sql: \"cast(card_issuer as string)\" # optional: apply transformation to column. must reference the alias if provided\n```\n\n#### Change the build schema\nBy default, this package builds the stripe staging models within a schema titled (`\u003ctarget_schema\u003e` + `_stg_stripe`) in your destination. If this is not where you would like your stripe staging data to be written to, add the following configuration to your root `dbt_project.yml` file:\n\n```yml\nmodels:\n    stripe_source:\n      +schema: my_new_schema_name # leave blank for just the target_schema\n```\n    \n#### Change the source table references\nIf an individual source table has a different name than the package expects, add the table name as it appears in your destination to the respective variable:\n\u003e IMPORTANT: See this project's [`dbt_project.yml`](https://github.com/fivetran/dbt_stripe_source/blob/main/dbt_project.yml) variable declarations to see the expected names.\n    \n```yml\nvars:\n    stripe_\u003cdefault_source_table_name\u003e_identifier: your_table_name \n```\n\n\u003c/details\u003e\n\n### (Optional) Step 6: Orchestrate your models with Fivetran Transformations for dbt Core™\n\u003cdetails\u003e\u003csummary\u003eExpand to view details\u003c/summary\u003e\n\u003cbr\u003e\n    \nFivetran offers the ability for you to orchestrate your dbt project through [Fivetran Transformations for dbt Core™](https://fivetran.com/docs/transformations/dbt). Learn how to set up your project for orchestration through Fivetran in our [Transformations for dbt Core™ setup guides](https://fivetran.com/docs/transformations/dbt#setupguide).\n\u003c/details\u003e\n    \n## Does this package have dependencies?\nThis dbt package is dependent on the following dbt packages. These dependencies are installed by default within this package. For more information on the following packages, refer to the [dbt hub](https://hub.getdbt.com/) site.\n\u003e IMPORTANT: If you have any of these dependent packages in your own `packages.yml` file, we highly recommend that you remove them from your root `packages.yml` to avoid package version conflicts.\n```yml\npackages:\n    - package: fivetran/fivetran_utils\n      version: [\"\u003e=0.4.0\", \"\u003c0.5.0\"]\n\n    - package: dbt-labs/dbt_utils\n      version: [\"\u003e=1.0.0\", \"\u003c2.0.0\"]\n\n    - package: dbt-labs/spark_utils\n      version: [\"\u003e=0.3.0\", \"\u003c0.4.0\"]\n```\n          \n## How is this package maintained and can I contribute?\n### Package Maintenance\nThe Fivetran team maintaining this package _only_ maintains the latest version of the package. We highly recommend that you stay consistent with the [latest version](https://hub.getdbt.com/fivetran/stripe_source/latest/) of the package and refer to the [CHANGELOG](https://github.com/fivetran/dbt_stripe_source/blob/main/CHANGELOG.md) and release notes for more information on changes across versions.\n\n### Contributions\nA small team of analytics engineers at Fivetran develops these dbt packages. However, the packages are made better by community contributions.\n\nWe highly encourage and welcome contributions to this package. Check out [this dbt Discourse article](https://discourse.getdbt.com/t/contributing-to-a-dbt-package/657) to learn how to contribute to a dbt package.\n\n## Are there any resources available?\n- If you have questions or want to reach out for help, see the [GitHub Issue](https://github.com/fivetran/dbt_stripe_source/issues/new/choose) section to find the right avenue of support for you.\n- If you would like to provide feedback to the dbt package team at Fivetran or would like to request a new dbt package, fill out our [Feedback Form](https://www.surveymonkey.com/r/DQ7K7WW).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffivetran%2Fdbt_stripe_source","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffivetran%2Fdbt_stripe_source","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffivetran%2Fdbt_stripe_source/lists"}