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.

refund wip

Kiran K1ddcc09fe064
diff --git a/apps/web/app/(ee)/api/singular/webhook/route.ts b/apps/web/app/(ee)/api/singular/webhook/route.ts
index 3908889be6..a0e30f6ecc 100644
--- a/apps/web/app/(ee)/api/singular/webhook/route.ts
+++ b/apps/web/app/(ee)/api/singular/webhook/route.ts
@@ -1,4 +1,5 @@
import { DubApiError, handleAndReturnErrorResponse } from "@/lib/api/errors";
+import { refundSingularSaleEvent } from "@/lib/integrations/singular/refund-sale";
import { trackSingularLeadEvent } from "@/lib/integrations/singular/track-lead";
import { trackSingularSaleEvent } from "@/lib/integrations/singular/track-sale";
import { prisma } from "@dub/prisma";
@@ -11,6 +12,7 @@ const singularToDubEvent = {
sng_subscribe: "sale",
sng_ecommerce_purchase: "sale",
__iap__: "sale", // In-app purchase
+ Refund: "refund",
"Copy GAID": "lead", // Singular Device Assist
"copy IDFA": "lead", // Singular Device Assist
};
@@ -43,6 +45,8 @@ export const GET = async (req: Request) => {
const queryParams = getSearchParams(req.url);
+ console.log(queryParams);
+
const { dub_token: token, dub_workspace_id: workspaceId } =
authSchema.parse(queryParams);
@@ -92,6 +96,11 @@ export const GET = async (req: Request) => {
queryParams,
workspace,
});
+ } else if (dubEvent === "refund") {
+ await refundSingularSaleEvent({
+ queryParams,
+ workspace,
+ });
} else {
throw new DubApiError({
code: "bad_request",
diff --git a/apps/web/lib/integrations/singular/refund-sale.ts b/apps/web/lib/integrations/singular/refund-sale.ts
new file mode 100644
index 0000000000..27e3e9b041
--- /dev/null
+++ b/apps/web/lib/integrations/singular/refund-sale.ts
@@ -0,0 +1,12 @@
+import { WorkspaceProps } from "@/lib/types";
+
+export const refundSingularSaleEvent = async ({
+ queryParams,
+ workspace,
+}: {
+ queryParams: Record<string, string>;
+ workspace: Pick<WorkspaceProps, "id" | "stripeConnectId" | "webhookEnabled">;
+}) => {
+ // TODO:
+ // Not implemented
+};