Skip to content
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

Stripe app cleanup #1915

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 0 additions & 81 deletions apps/web/app/api/stripe/integration/callback/route.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@ import type Stripe from "stripe";
export async function accountApplicationDeauthorized(event: Stripe.Event) {
const stripeAccountId = event.account;

const workspace = await prisma.project.update({
const workspace = await prisma.project.findUnique({
where: {
stripeConnectId: stripeAccountId,
},
select: {
id: true,
},
});

if (!workspace) {
return `Stripe Connect account ${stripeAccountId} deauthorized.`;
}

await prisma.project.update({
where: {
stripeConnectId: stripeAccountId,
},
Expand Down
37 changes: 0 additions & 37 deletions packages/stripe-app/src/utils/create-link.ts

This file was deleted.

21 changes: 8 additions & 13 deletions packages/stripe-app/src/utils/dub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,20 @@ import { Token } from "./types";
// Update the workspace with stripeAccountId
export async function updateWorkspace({
token,
workspaceId,
accountId,
}: {
token: Token;
workspaceId: string;
accountId: string | null;
}) {
const response = await fetch(
`${DUB_API_HOST}/stripe/integration?workspaceId=${workspaceId}`,
{
method: "PATCH",
headers: {
Authorization: `Bearer ${token.access_token}`,
},
body: JSON.stringify({
stripeAccountId: accountId,
}),
const response = await fetch(`${DUB_API_HOST}/stripe/integration`, {
method: "PATCH",
headers: {
Authorization: `Bearer ${token.access_token}`,
},
);
body: JSON.stringify({
stripeAccountId: accountId,
}),
});

if (!response.ok) {
const data = await response.json();
Expand Down
2 changes: 1 addition & 1 deletion packages/stripe-app/src/utils/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function getOAuthUrl({
state: string;
challenge: string;
}) {
return `${DUB_HOST}/oauth/authorize?client_id=${DUB_CLIENT_ID}&redirect_uri=${getRedirectURL()}&response_type=code&scope=workspaces.write,links.write&state=${state}&code_challenge=${challenge}&code_challenge_method=S256`;
return `${DUB_HOST}/oauth/authorize?client_id=${DUB_CLIENT_ID}&redirect_uri=${getRedirectURL()}&response_type=code&scope=workspaces.write&state=${state}&code_challenge=${challenge}&code_challenge_method=S256`;
}

// Exchanges the authorization code for an access token
Expand Down
7 changes: 0 additions & 7 deletions packages/stripe-app/src/views/AppSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ import { deleteSecret, setSecret } from "../utils/secrets";
import { stripe } from "../utils/stripe";
import { Workspace } from "../utils/types";

// TODO:
// Handle errors and display them to the user

const AppSettings = ({ userContext, oauthContext }: ExtensionContextValue) => {
const credentialsUsed = useRef(false);
const [oauthState, setOAuthState] = useState("");
Expand All @@ -48,7 +45,6 @@ const AppSettings = ({ userContext, oauthContext }: ExtensionContextValue) => {

await updateWorkspace({
token,
workspaceId: workspace.id,
accountId: null,
});

Expand Down Expand Up @@ -99,7 +95,6 @@ const AppSettings = ({ userContext, oauthContext }: ExtensionContextValue) => {

await updateWorkspace({
token,
workspaceId: workspace.id,
accountId: userContext.account.id,
});

Expand Down Expand Up @@ -189,8 +184,6 @@ const AppSettings = ({ userContext, oauthContext }: ExtensionContextValue) => {
brandIcon={appIcon}
/>
)}

{/* <CreateLink workspace={workspace} /> */}
</Box>
);
};
Expand Down
82 changes: 0 additions & 82 deletions packages/stripe-app/src/views/create-link.tsx

This file was deleted.

Loading