Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

add stripe integration section

Steven Teyddaee78d9ee2
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page-client.tsx
index 67ee69ddf4..d18e86e536 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page-client.tsx
@@ -1,7 +1,7 @@
"use client";
import useWorkspace from "@/lib/swr/use-workspace";
-import ConnectStripeButton from "@/ui/workspaces/connect-stripe-button";
+import ConnectStripe from "@/ui/workspaces/connect-stripe";
import DeleteWorkspace from "@/ui/workspaces/delete-workspace";
import UploadLogo from "@/ui/workspaces/upload-logo";
import WorkspaceId from "@/ui/workspaces/workspace-id";
@@ -16,8 +16,6 @@ export default function WorkspaceSettingsClient() {
return (
<>
- {/* TODO: Move the button to proper place */}
- {betaTester && <ConnectStripeButton />}
<Form
title="Workspace Name"
description={`This is the name of your workspace on ${process.env.NEXT_PUBLIC_APP_NAME}.`}
@@ -90,6 +88,7 @@ export default function WorkspaceSettingsClient() {
/>
<WorkspaceId />
<UploadLogo />
+ {betaTester && <ConnectStripe />}
<DeleteWorkspace />
</>
);
diff --git a/apps/web/ui/workspaces/connect-stripe-button.tsx b/apps/web/ui/workspaces/connect-stripe-button.tsx
deleted file mode 100644
index 543331928c..0000000000
--- a/apps/web/ui/workspaces/connect-stripe-button.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-"use client";
-
-import useWorkspace from "@/lib/swr/use-workspace";
-import { Button } from "@dub/ui/src/button";
-import { useEffect, useState } from "react";
-
-export default function ConnectStripeButton() {
- const { id: workspaceId } = useWorkspace();
-
- const [redirecting, setRedirecting] = useState(false);
-
- const redirectToStripe = async () => {
- setRedirecting(true);
- const response = await fetch(
- `/api/campaigns/connect-stripe?workspaceId=${workspaceId}`,
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- },
- );
-
- const { url } = await response.json();
-
- window.location.href = url;
- };
-
- useEffect(() => {
- // when leave page, reset state
- return () => {
- setRedirecting(false);
- };
- }, []);
-
- return (
- <Button
- text="Connect to Stripe"
- loading={redirecting}
- onClick={redirectToStripe}
- className="max-w-xs"
- />
- );
-}
diff --git a/apps/web/ui/workspaces/connect-stripe.tsx b/apps/web/ui/workspaces/connect-stripe.tsx
new file mode 100644
index 0000000000..b2387a404b
--- /dev/null
+++ b/apps/web/ui/workspaces/connect-stripe.tsx
@@ -0,0 +1,72 @@
+"use client";
+
+import useWorkspace from "@/lib/swr/use-workspace";
+import { CopyButton } from "@dub/ui";
+import { Button } from "@dub/ui/src/button";
+import { useEffect, useState } from "react";
+
+export default function ConnectStripe() {
+ const { id: workspaceId, stripeConnectId } = useWorkspace();
+
+ const [redirecting, setRedirecting] = useState(false);
+
+ const redirectToStripe = async () => {
+ setRedirecting(true);
+ const response = await fetch(
+ `/api/campaigns/connect-stripe?workspaceId=${workspaceId}`,
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ },
+ );
+
+ const { url } = await response.json();
+
+ window.location.href = url;
+ };
+
+ useEffect(() => {
+ // when leave page, reset state
+ return () => {
+ setRedirecting(false);
+ };
+ }, []);
+
+ return (
+ <div className="rounded-lg border border-gray-200 bg-white">
+ <div className="relative flex flex-col space-y-6 p-5 sm:p-10">
+ <div className="flex flex-col space-y-3">
+ <h2 className="text-xl font-medium">Stripe Integration</h2>
+ <p className="text-sm text-gray-500">
+ Connect your Stripe account to set up conversion tracking and pay
+ out affiliates.
+ </p>
+ </div>
+ {stripeConnectId ? (
+ <div className="flex w-full max-w-md items-center justify-between rounded-md border border-gray-300 bg-white p-2">
+ <p className="text-sm text-gray-500">{stripeConnectId}</p>
+ <CopyButton value={stripeConnectId} className="rounded-md" />
+ </div>
+ ) : (
+ <Button
+ text="Connect to Stripe"
+ loading={redirecting}
+ onClick={redirectToStripe}
+ className="max-w-xs"
+ />
+ )}
+ </div>
+ <div className="flex items-center justify-between rounded-b-lg border-t border-gray-200 bg-gray-50 px-3 py-5 sm:px-10">
+ <a
+ href="https://dub.co/help/article/how-to-get-workspace-id"
+ target="_blank"
+ className="text-sm text-gray-400 underline underline-offset-4 transition-colors hover:text-gray-700"
+ >
+ Learn more about Workspace ID.
+ </a>
+ </div>
+ </div>
+ );
+}
diff --git a/packages/stripe-app/stripe-app.json b/packages/stripe-app/stripe-app.json
index 19a04c75ca..e6f7d4f7a6 100644
--- a/packages/stripe-app/stripe-app.json
+++ b/packages/stripe-app/stripe-app.json
@@ -1,6 +1,6 @@
{
"id": "com.example.dub",
- "version": "0.0.20",
+ "version": "0.0.21",
"name": "Dub",
"icon": "",
"permissions": [
@@ -50,4 +50,4 @@
],
"stripe_api_access_type": "oauth",
"distribution_type": "public"
-}
+}
\ No newline at end of file