Skip to content

Commit

Permalink
Merge pull request #1915 from dubinc/stripe-followup
Browse files Browse the repository at this point in the history
Stripe app cleanup
  • Loading branch information
steven-tey authored Jan 17, 2025
2 parents ca301c7 + 8f6d344 commit fb8e821
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 141 deletions.
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.

0 comments on commit fb8e821

Please sign in to comment.