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.

resolvePromotionCodeError

Steven Tey74dddc53aee3
diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts
index d2caa5d9e5..8c1453fac0 100644
--- a/apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts
+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts
@@ -109,18 +109,12 @@ export async function invoicePaid(
};
}
- const { promotionCodeId, error } = await resolvePromotionCodeIdFromInvoice({
- invoiceId,
- stripeAccountId,
- mode,
- });
-
- if (error) {
- return {
- response: `Failed to resolve promotion code from invoice ${invoiceId}: ${error}`,
- workspaceId: workspace.id,
- };
- }
+ const { promotionCodeId, resolvePromotionCodeError } =
+ await resolvePromotionCodeIdFromInvoice({
+ invoiceId,
+ stripeAccountId,
+ mode,
+ });
if (promotionCodeId) {
const promoCodeResponse = await attributeViaPromotionCodeId({
@@ -139,6 +133,10 @@ export async function invoicePaid(
if (promoCodeResponse) {
customer = promoCodeResponse.customer;
}
+ } else if (resolvePromotionCodeError) {
+ console.log(
+ `Failed to resolve promotion code from invoice ${invoiceId}: ${resolvePromotionCodeError}`,
+ );
}
if (!customer) {
@@ -421,11 +419,11 @@ async function resolvePromotionCodeIdFromInvoice({
}): Promise<
| {
promotionCodeId: string;
- error: null;
+ resolvePromotionCodeError: null;
}
| {
promotionCodeId: null;
- error: string;
+ resolvePromotionCodeError: string;
}
> {
const stripe = stripeAppClient({ mode });