-
-
Notifications
You must be signed in to change notification settings - Fork 68
feat: added checkout session #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Niki2k1
wants to merge
2
commits into
supabase:main
Choose a base branch
from
Niki2k1:feat/checkout-sessions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
packages/sync-engine/src/database/migrations/0032_checkout_sessions.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
create table | ||
if not exists "stripe"."checkout_sessions" ( | ||
"id" text primary key, | ||
"object" text, | ||
"adaptive_pricing" jsonb, | ||
"after_expiration" jsonb, | ||
"allow_promotion_codes" boolean, | ||
"amount_subtotal" integer, | ||
"amount_total" integer, | ||
"automatic_tax" jsonb, | ||
"billing_address_collection" text, | ||
"cancel_url" text, | ||
"client_reference_id" text, | ||
"client_secret" text, | ||
"collected_information" jsonb, | ||
"consent" jsonb, | ||
"consent_collection" jsonb, | ||
"created" integer, | ||
"currency" text, | ||
"currency_conversion" jsonb, | ||
"custom_fields" jsonb, | ||
"custom_text" jsonb, | ||
"customer" text, | ||
"customer_creation" text, | ||
"customer_details" jsonb, | ||
"customer_email" text, | ||
"discounts" jsonb, | ||
"expires_at" integer, | ||
"invoice" text, | ||
"invoice_creation" jsonb, | ||
"livemode" boolean, | ||
"locale" text, | ||
"metadata" jsonb, | ||
"mode" text, | ||
"optional_items" jsonb, | ||
"payment_intent" text, | ||
"payment_link" text, | ||
"payment_method_collection" text, | ||
"payment_method_configuration_details" jsonb, | ||
"payment_method_options" jsonb, | ||
"payment_method_types" jsonb, | ||
"payment_status" text, | ||
"permissions" jsonb, | ||
"phone_number_collection" jsonb, | ||
"presentment_details" jsonb, | ||
"recovered_from" text, | ||
"redirect_on_completion" text, | ||
"return_url" text, | ||
"saved_payment_method_options" jsonb, | ||
"setup_intent" text, | ||
"shipping_address_collection" jsonb, | ||
"shipping_cost" jsonb, | ||
"shipping_details" jsonb, | ||
"shipping_options" jsonb, | ||
"status" text, | ||
"submit_type" text, | ||
"subscription" text, | ||
"success_url" text, | ||
"tax_id_collection" jsonb, | ||
"total_details" jsonb, | ||
"ui_mode" text, | ||
"url" text, | ||
"wallet_options" jsonb, | ||
"updated_at" timestamptz default timezone('utc'::text, now()) not null | ||
); | ||
|
||
create index stripe_checkout_sessions_customer_idx on "stripe"."checkout_sessions" using btree (customer); | ||
create index stripe_checkout_sessions_subscription_idx on "stripe"."checkout_sessions" using btree (subscription); | ||
create index stripe_checkout_sessions_payment_intent_idx on "stripe"."checkout_sessions" using btree (payment_intent); | ||
create index stripe_checkout_sessions_invoice_idx on "stripe"."checkout_sessions" using btree (invoice); | ||
|
||
create trigger handle_updated_at | ||
before update | ||
on stripe.checkout_sessions | ||
for each row | ||
execute procedure set_updated_at(); |
25 changes: 25 additions & 0 deletions
25
packages/sync-engine/src/database/migrations/0033_checkout_session_line_items.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
create table if not exists "stripe"."checkout_session_line_items" ( | ||
"id" text, | ||
"object" text, | ||
"adjustable_quantity" jsonb, | ||
"amount_subtotal" integer, | ||
"amount_total" integer, | ||
"currency" text, | ||
"description" text, | ||
"discounts" jsonb, | ||
"price" text, | ||
"quantity" integer, | ||
"taxes" jsonb, | ||
"checkout_session" text references "stripe"."checkout_sessions", | ||
"updated_at" timestamptz default timezone('utc'::text, now()) not null, | ||
primary key ("checkout_session", "id") | ||
); | ||
|
||
create index stripe_checkout_session_line_items_session_idx on "stripe"."checkout_session_line_items" using btree (checkout_session); | ||
create index stripe_checkout_session_line_items_price_idx on "stripe"."checkout_session_line_items" using btree (price); | ||
|
||
create trigger handle_updated_at | ||
before update | ||
on stripe.checkout_session_line_items | ||
for each row | ||
execute procedure set_updated_at(); |
18 changes: 18 additions & 0 deletions
18
packages/sync-engine/src/schemas/checkout_session_line_items.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { EntitySchema } from './types' | ||
|
||
export const checkoutSessionLineItemSchema: EntitySchema = { | ||
properties: [ | ||
'id', | ||
'object', | ||
'adjustable_quantity', | ||
'amount_subtotal', | ||
'amount_total', | ||
'currency', | ||
'description', | ||
'discounts', | ||
'price', | ||
'quantity', | ||
'taxes', | ||
'checkout_session', | ||
], | ||
} as const |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import type { EntitySchema } from './types' | ||
|
||
export const checkoutSessionSchema: EntitySchema = { | ||
properties: [ | ||
'id', | ||
'object', | ||
'adaptive_pricing', | ||
'after_expiration', | ||
'allow_promotion_codes', | ||
'amount_subtotal', | ||
'amount_total', | ||
'automatic_tax', | ||
'billing_address_collection', | ||
'cancel_url', | ||
'client_reference_id', | ||
'client_secret', | ||
'collected_information', | ||
'consent', | ||
'consent_collection', | ||
'created', | ||
'currency', | ||
'currency_conversion', | ||
'custom_fields', | ||
'custom_text', | ||
'customer', | ||
'customer_creation', | ||
'customer_details', | ||
'customer_email', | ||
'discounts', | ||
'expires_at', | ||
'invoice', | ||
'invoice_creation', | ||
'livemode', | ||
'locale', | ||
'metadata', | ||
'mode', | ||
'optional_items', | ||
'payment_intent', | ||
'payment_link', | ||
'payment_method_collection', | ||
'payment_method_configuration_details', | ||
'payment_method_options', | ||
'payment_method_types', | ||
'payment_status', | ||
'permissions', | ||
'phone_number_collection', | ||
'presentment_details', | ||
'recovered_from', | ||
'redirect_on_completion', | ||
'return_url', | ||
'saved_payment_method_options', | ||
'setup_intent', | ||
'shipping_address_collection', | ||
'shipping_cost', | ||
'shipping_details', | ||
'shipping_options', | ||
'status', | ||
'submit_type', | ||
'subscription', | ||
'success_url', | ||
'tax_id_collection', | ||
'total_details', | ||
'ui_mode', | ||
'url', | ||
'wallet_options', | ||
], | ||
} as const | ||
|
||
export const checkoutSessionDeletedSchema: EntitySchema = { | ||
properties: ['id', 'object', 'deleted'], | ||
} as const |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a single upsert and not one upsert per line item ideally
Are line items sent via the webhook by default? Otherwise the checkout session line items would never be there for a regular webhook