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 `stripeCustomerId` to customer profile pages (#3353)

Steven Teya800de2023c2
diff --git a/apps/web/lib/zod/schemas/customers.ts b/apps/web/lib/zod/schemas/customers.ts
index 07996b64e2..ac57c6faa9 100644
--- a/apps/web/lib/zod/schemas/customers.ts
+++ b/apps/web/lib/zod/schemas/customers.ts
@@ -119,12 +119,18 @@ export const CustomerSchema = z.object({
.describe(
"The unique ID of the customer. You may use either the customer's `id` on Dub (obtained via `/customers` endpoint) or their `externalId` (unique ID within your system, prefixed with `ext_`, e.g. `ext_123`).",
),
- externalId: z
- .string()
- .describe("Unique identifier for the customer in the client's app."),
name: z.string().describe("Name of the customer."),
email: z.string().nullish().describe("Email of the customer."),
avatar: z.string().nullish().describe("Avatar URL of the customer."),
+ externalId: z
+ .string()
+ .describe("Unique identifier for the customer in the client's app."),
+ stripeCustomerId: z
+ .string()
+ .nullish()
+ .describe(
+ "The customer's Stripe customer ID. This is useful for attributing recurring sale events to the partner who referred the customer.",
+ ),
country: z.string().nullish().describe("Country of the customer."),
sales: z
.number()
diff --git a/apps/web/tests/customers/index.test.ts b/apps/web/tests/customers/index.test.ts
index 7b04411e2b..4189344ac0 100644
--- a/apps/web/tests/customers/index.test.ts
+++ b/apps/web/tests/customers/index.test.ts
@@ -7,6 +7,7 @@ const expectedCustomer = {
id: "cus_n5LF7wS3Z1vfwjZCyy5QDC7Q",
externalId: "cus_OmLauTvvWCtJsFN1yJb0oevj",
+ stripeCustomerId: null,
country: "US",
name: expect.any(String),
avatar: expect.any(String),
diff --git a/apps/web/ui/customers/customer-details-column.tsx b/apps/web/ui/customers/customer-details-column.tsx
index 177329b9bd..393e19c1f4 100644
--- a/apps/web/ui/customers/customer-details-column.tsx
+++ b/apps/web/ui/customers/customer-details-column.tsx
@@ -5,6 +5,7 @@ import {
Globe,
Hyperlink,
TimestampTooltip,
+ Tooltip,
UTM_PARAMETERS,
} from "@dub/ui";
import {
@@ -232,6 +233,26 @@ export function CustomerDetailsColumn({
</div>
</div>
)}
+
+ {customer?.stripeCustomerId && (
+ <div className="flex flex-col gap-2.5">
+ <DetailHeading>Stripe Customer ID</DetailHeading>
+ <div>
+ <Tooltip content="View in Stripe" align="start">
+ <div>
+ <ConditionalLink
+ href={`https://dashboard.stripe.com/customers/${customer.stripeCustomerId}`}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="truncate text-xs"
+ >
+ {customer.stripeCustomerId}
+ </ConditionalLink>
+ </div>
+ </Tooltip>
+ </div>
+ </div>
+ )}
</div>
</div>