improve stg_stripe__charges
This commit is contained in:
parent
13395b2dca
commit
23471e5b87
3 changed files with 43 additions and 14 deletions
|
|
@ -40,9 +40,8 @@ The date when the event was pulled from the original data source.
|
|||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs currency_desc %}
|
||||
|
||||
Three-letter ISO 4217 currency code, in uppercase. Must be a supported currency.
|
||||
|
||||
{% enddocs %}
|
||||
{% enddocs %}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,10 @@ models:
|
|||
data_type: date
|
||||
description: "{{ doc('dwh_extracted_date_utc_desc')}}"
|
||||
- name: stg_stripe__charges
|
||||
description: ""
|
||||
description: |
|
||||
The Charge object represents a single attempt to move money into your Stripe account. PaymentIntent confirmation is the most common way to create Charges, but transferring money to a different Stripe account through Connect also creates Charges. Some legacy payment flows create Charges directly, which is not recommended for new integrations.
|
||||
|
||||
You can read more about this object here: https://docs.stripe.com/api/charges.
|
||||
columns:
|
||||
- name: id
|
||||
data_type: character varying
|
||||
|
|
@ -89,7 +92,7 @@ models:
|
|||
|
||||
- name: amount
|
||||
data_type: bigint
|
||||
description: "Amount intended to be collected by this payment. A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or equivalent in charge currency. The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99)."
|
||||
description: "Amount intended to be collected by this payment. A positive integer representing how much to charge in the regular unit for the currency (1 for $1)."
|
||||
|
||||
- name: object
|
||||
data_type: character varying
|
||||
|
|
@ -110,6 +113,10 @@ models:
|
|||
- name: created_at_utc
|
||||
data_type: timestamp with time zone
|
||||
description: "The timestamp at which the object was created."
|
||||
|
||||
- name: created_date_utc
|
||||
data_type: date
|
||||
description: "The date when the object was created."
|
||||
|
||||
- name: dispute
|
||||
data_type: character varying
|
||||
|
|
@ -131,13 +138,17 @@ models:
|
|||
data_type: timestamp with time zone
|
||||
description: "The timestamp at which the object was last updated."
|
||||
|
||||
- name: updated_date_utc
|
||||
data_type: date
|
||||
description: "The date when the object was last updated."
|
||||
|
||||
- name: is_captured
|
||||
data_type: boolean
|
||||
description: "If the charge was created without capturing, this Boolean represents whether it is still uncaptured or has since been captured."
|
||||
|
||||
- name: currency
|
||||
data_type: character varying
|
||||
description: "{{ doc('stripe_currency_desc') }}"
|
||||
description: "{{ doc('currency_desc') }}"
|
||||
|
||||
- name: customer
|
||||
data_type: character varying
|
||||
|
|
@ -221,11 +232,11 @@ models:
|
|||
|
||||
- name: amount_captured
|
||||
data_type: bigint
|
||||
description: "Amount in cents captured (can be less than the amount attribute on the charge if a partial capture was made)."
|
||||
description: "Amount captured (can be less than the amount attribute on the charge if a partial capture was made)."
|
||||
|
||||
- name: amount_refunded
|
||||
data_type: bigint
|
||||
description: "Amount in cents refunded (can be less than the amount attribute on the charge if a partial refund was issued)."
|
||||
description: "Amount refunded (can be less than the amount attribute on the charge if a partial refund was issued)."
|
||||
|
||||
- name: application_fee
|
||||
data_type: character varying
|
||||
|
|
@ -275,9 +286,13 @@ models:
|
|||
data_type: character varying
|
||||
description: "The full statement descriptor that is passed to card networks, and that is displayed on your customers’ credit card and bank statements. Allows you to see what the statement descriptor looks like after the static and dynamic portions are combined."
|
||||
|
||||
- name: dwh_extracted_at_date
|
||||
- name: dwh_extracted_at_utc
|
||||
data_type: timestamp with time zone
|
||||
description: "{{ doc('dwh_extracted_at_utc_desc') }}"
|
||||
|
||||
- name: dwh_extracted_date_utc
|
||||
data_type: date
|
||||
description: "{{ doc('dwh_extracted_date_utc_desc') }}"
|
||||
- name: stg_stripe__payment_intents
|
||||
description: |
|
||||
A PaymentIntent guides you through the process of collecting a payment from your customer. We recommend that you create exactly one PaymentIntent for each order or customer session in your system. You can reference the PaymentIntent later to see the history of payment attempts for a particular session.
|
||||
|
|
|
|||
|
|
@ -1,24 +1,31 @@
|
|||
with
|
||||
raw_charges as (select * from {{ source("stripe_uk", "charges") }}),
|
||||
stg_seed__currencies as (select * from {{ ref("stg_seed__currencies") }}),
|
||||
stg_stripe__charges as (
|
||||
select
|
||||
{{ adapter.quote("id") }},
|
||||
{{ adapter.quote("card") }},
|
||||
cast({{ adapter.quote("paid") }} as bool) as is_paid,
|
||||
{{ adapter.quote("order") }},
|
||||
{{ adapter.quote("amount") }},
|
||||
{{ adapter.quote("amount") }} / (10 ^ cur.decimal_positions) as amount,
|
||||
{{ adapter.quote("object") }},
|
||||
{{ adapter.quote("review") }},
|
||||
{{ adapter.quote("source") }},
|
||||
{{ adapter.quote("status") }},
|
||||
to_timestamp({{ adapter.quote("created") }}) as created_at_utc,
|
||||
cast(
|
||||
to_timestamp({{ adapter.quote("created") }}) as date
|
||||
) as created_date_utc,
|
||||
{{ adapter.quote("dispute") }},
|
||||
{{ adapter.quote("invoice") }},
|
||||
{{ adapter.quote("outcome") }},
|
||||
{{ adapter.quote("refunds") }},
|
||||
to_timestamp({{ adapter.quote("updated") }}) as updated_at_utc,
|
||||
cast(
|
||||
to_timestamp({{ adapter.quote("updated") }}) as date
|
||||
) as updated_date_utc,
|
||||
cast({{ adapter.quote("captured") }} as bool) as is_captured,
|
||||
{{ adapter.quote("currency") }},
|
||||
upper({{ adapter.quote("currency") }}) as currency,
|
||||
{{ adapter.quote("customer") }},
|
||||
cast({{ adapter.quote("disputed") }} as bool) as is_disputed,
|
||||
cast({{ adapter.quote("livemode") }} as bool) as is_livemode,
|
||||
|
|
@ -39,8 +46,10 @@ with
|
|||
{{ adapter.quote("payment_method") }},
|
||||
{{ adapter.quote("receipt_number") }},
|
||||
{{ adapter.quote("transfer_group") }},
|
||||
{{ adapter.quote("amount_captured") }},
|
||||
{{ adapter.quote("amount_refunded") }},
|
||||
{{ adapter.quote("amount_captured") }}
|
||||
/ (10 ^ cur.decimal_positions) as amount_captured,
|
||||
{{ adapter.quote("amount_refunded") }}
|
||||
/ (10 ^ cur.decimal_positions) as amount_refunded,
|
||||
{{ adapter.quote("application_fee") }},
|
||||
{{ adapter.quote("billing_details") }},
|
||||
{{ adapter.quote("failure_message") }},
|
||||
|
|
@ -53,9 +62,15 @@ with
|
|||
{{ adapter.quote("failure_balance_transaction") }},
|
||||
{{ adapter.quote("statement_descriptor_suffix") }},
|
||||
{{ adapter.quote("calculated_statement_descriptor") }},
|
||||
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_date
|
||||
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc,
|
||||
cast(
|
||||
{{ adapter.quote("_airbyte_extracted_at") }} as date
|
||||
) as dwh_extracted_date_utc
|
||||
|
||||
from raw_charges
|
||||
from raw_charges ch
|
||||
left join
|
||||
stg_seed__currencies cur
|
||||
on upper(ch.{{ adapter.quote("currency") }}) = cur.iso_4217_code
|
||||
)
|
||||
select *
|
||||
from stg_stripe__charges
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue