-
-
Notifications
You must be signed in to change notification settings - Fork 19
Enhance payment system #3112
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
Merged
Merged
Enhance payment system #3112
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
aec0efd
fix: unvalid product id and add product table
phatgg221 7160b49
fix: saving to database after buy subscription
phatgg221 0889192
fix: update security and visibility for creator and common members in…
phatgg221 3680fcb
feat: display payment history
phatgg221 749d816
feat: update dynamic data for billing history
phatgg221 fdcd4f7
feat: predefined email and name for checkout
phatgg221 7fa3149
feat: update ui for billing client
phatgg221 a906da4
update: delete unwanted comment in purchase link
phatgg221 937d579
fix: checkout links falied
phatgg221 e7f3016
chore: cancelation routing setup
phatgg221 4583883
Merge branch 'main' into feat/payment-completion
phatgg221 274d7db
fix: build + disable cancel button
phatgg221 16cb146
fix: allow only access to products table
phatgg221 277ab02
Update billing-history.tsx
phatgg221 b421cc7
Update route.ts
phatgg221 39ec750
refactor: replace 'lucide-react' icons with '@tuturuuu/ui/icons'
vhpx 236f8b3
Merge branch 'main' into feat/payment-completion
vhpx 068797d
chore(db): consolidate migration files
vhpx 6472364
feat(db): enable row level security and create view policy for worksp…
vhpx 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
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
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
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
48 changes: 48 additions & 0 deletions
48
apps/db/supabase/migrations/20250618070621_changed_check_creator_function_policy.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,48 @@ | ||
set check_function_bodies = off; | ||
|
||
CREATE OR REPLACE FUNCTION public.check_ws_creator(ws_id uuid) | ||
RETURNS boolean | ||
LANGUAGE plpgsql | ||
AS $function$BEGIN | ||
RETURN ( | ||
( | ||
SELECT creator_id FROM public.workspaces WHERE id = check_ws_creator.ws_id | ||
) = auth.uid() | ||
AND NOT EXISTS ( | ||
SELECT 1 FROM public.workspace_subscription | ||
WHERE public.workspace_subscription.ws_id = check_ws_creator.ws_id | ||
) | ||
); | ||
END;$function$ | ||
; | ||
|
||
drop policy "only allow owner of the user to buy subscription" on "public"."workspace_subscription"; | ||
|
||
create policy "only allow owner of the user to buy subscription" | ||
on "public"."workspace_subscription" | ||
as permissive | ||
for insert | ||
to authenticated | ||
with check ((EXISTS ( SELECT 1 | ||
FROM workspaces | ||
WHERE ((workspaces.id = workspace_subscription.ws_id) AND (workspaces.creator_id = auth.uid()))))); | ||
|
||
drop policy "allow select for users that are in the workspace" on "public"."workspace_subscription"; | ||
|
||
create policy "allow select for users that are in the workspace" | ||
on "public"."workspace_subscription" | ||
as permissive | ||
for select | ||
to authenticated | ||
using ((EXISTS ( SELECT 1 | ||
FROM workspace_members wm | ||
WHERE ((wm.user_id = auth.uid()) AND (wm.ws_id = workspace_subscription.ws_id))))); | ||
|
||
create policy "allow delete access for creator workspace" | ||
on "public"."workspace_subscription" | ||
as permissive | ||
for delete | ||
to authenticated | ||
using ((EXISTS ( SELECT 1 | ||
FROM workspaces | ||
WHERE ((workspaces.id = workspace_subscription.ws_id) AND (workspaces.creator_id = auth.uid()))))); |
69 changes: 69 additions & 0 deletions
69
apps/db/supabase/migrations/20250618073214_add_workspace_subscription_products_table.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,69 @@ | ||
create table "public"."workspace_subscription_products" ( | ||
"id" uuid not null, | ||
"created_at" timestamp with time zone not null default now(), | ||
"name" text, | ||
"description" text, | ||
"price" real, | ||
"recurring_interval" text default 'month'::text | ||
); | ||
|
||
alter table "public"."workspace_subscription" add column "product_id" uuid; | ||
|
||
CREATE UNIQUE INDEX workspace_subscription_products_pkey ON public.workspace_subscription_products USING btree (id); | ||
|
||
alter table "public"."workspace_subscription_products" add constraint "workspace_subscription_products_pkey" PRIMARY KEY using index "workspace_subscription_products_pkey"; | ||
|
||
alter table "public"."workspace_subscription" add constraint "workspace_subscription_product_id_fkey" FOREIGN KEY (product_id) REFERENCES workspace_subscription_products(id) not valid; | ||
|
||
alter table "public"."workspace_subscription" validate constraint "workspace_subscription_product_id_fkey"; | ||
|
||
grant delete on table "public"."workspace_subscription_products" to "anon"; | ||
|
||
grant insert on table "public"."workspace_subscription_products" to "anon"; | ||
|
||
grant references on table "public"."workspace_subscription_products" to "anon"; | ||
|
||
grant select on table "public"."workspace_subscription_products" to "anon"; | ||
|
||
grant trigger on table "public"."workspace_subscription_products" to "anon"; | ||
|
||
grant truncate on table "public"."workspace_subscription_products" to "anon"; | ||
|
||
grant update on table "public"."workspace_subscription_products" to "anon"; | ||
phatgg221 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
grant delete on table "public"."workspace_subscription_products" to "authenticated"; | ||
|
||
grant insert on table "public"."workspace_subscription_products" to "authenticated"; | ||
|
||
grant references on table "public"."workspace_subscription_products" to "authenticated"; | ||
|
||
grant select on table "public"."workspace_subscription_products" to "authenticated"; | ||
|
||
grant trigger on table "public"."workspace_subscription_products" to "authenticated"; | ||
|
||
grant truncate on table "public"."workspace_subscription_products" to "authenticated"; | ||
|
||
grant update on table "public"."workspace_subscription_products" to "authenticated"; | ||
|
||
grant delete on table "public"."workspace_subscription_products" to "service_role"; | ||
|
||
grant insert on table "public"."workspace_subscription_products" to "service_role"; | ||
|
||
grant references on table "public"."workspace_subscription_products" to "service_role"; | ||
|
||
grant select on table "public"."workspace_subscription_products" to "service_role"; | ||
|
||
grant trigger on table "public"."workspace_subscription_products" to "service_role"; | ||
|
||
grant truncate on table "public"."workspace_subscription_products" to "service_role"; | ||
|
||
grant update on table "public"."workspace_subscription_products" to "service_role"; | ||
|
||
alter table "public"."workspace_subscription_products" enable row level security; | ||
|
||
create policy "allow view for all products" | ||
on "public"."workspace_subscription_products" | ||
as permissive | ||
for select | ||
to authenticated | ||
using (true); |
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
Oops, something went wrong.
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.