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.

premium domain custom registration

Steven Tey3c1c0757f633
diff --git a/apps/web/app/(ee)/api/admin/domains/register-premium/route.ts b/apps/web/app/(ee)/api/admin/domains/register-premium/route.ts
index 3a39162446..41a0c8215a 100644
--- a/apps/web/app/(ee)/api/admin/domains/register-premium/route.ts
+++ b/apps/web/app/(ee)/api/admin/domains/register-premium/route.ts
@@ -61,20 +61,9 @@ export const POST = withAdmin(
workspace,
skipWorkspaceChecks: true,
});
-
- const status = response.paymentIntentStatus;
-
- if (status === "succeeded") {
- return NextResponse.json({
- success: true,
- message: `Charge succeeded (${currencyFormatter(response.registrationPriceCents)}). Domain registration will finalize via Stripe webhook.`,
- ...response,
- });
- }
-
return NextResponse.json({
success: true,
- message: `Payment initiated (${currencyFormatter(response.registrationPriceCents)}). Domain registration will finalize via Stripe webhook once payment succeeds.`,
+ message: `Payment initiated (${currencyFormatter(response.registrationPriceCents)}). Upon a successful charge, please register the domain manually via Dynadot.`,
...response,
});
} catch (error) {
diff --git a/apps/web/lib/dynadot/register-domain.ts b/apps/web/lib/dynadot/register-domain.ts
index e1043750db..430163631b 100644
--- a/apps/web/lib/dynadot/register-domain.ts
+++ b/apps/web/lib/dynadot/register-domain.ts
@@ -26,6 +26,8 @@ const schema = z.object({
const ERROR_CODES = {
not_available: "Domain not available.",
system_busy: "System is busy. Please try again.",
+ insufficient_funds:
+ "Insufficient funds. Please add more funds to your account.",
};
export const registerDomain = async ({
@@ -35,8 +37,8 @@ export const registerDomain = async ({
domain: string;
premium?: boolean;
}) => {
- // mock response for development
- if (process.env.NODE_ENV === "development") {
+ // for premium domain registrations, we return early with a mock response since we'll need to manually register the domain via Dynadot
+ if (premium) {
return RegisterDomainSchema.parse({
domain,
status: "success",
@@ -49,7 +51,7 @@ export const registerDomain = async ({
command: "register",
duration: "1",
currency: "USD",
- ...(premium ? { premium: "1" } : { coupon: DYNADOT_COUPON }),
+ coupon: DYNADOT_COUPON,
key: DYNADOT_API_KEY,
});
@@ -69,7 +71,8 @@ export const registerDomain = async ({
});
}
- const data = schema.parse(await response.json());
+ const res = await response.json();
+ const data = schema.parse(res);
const { Status, Error } = data.RegisterResponse;