Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions fastspring/lib/eventHandlers/handleOrderCreated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,16 @@ export async function handleOrderCreated(
status: 201,
};
} catch (error) {
const reason =
error instanceof Error ? error.message : String(error);
throw new Error(
`Could not process the order.completed webhook event with Id ${orderCompletedEvent.id}. ${userId ? `User ID: ${userId} created` : "User ID not created"}.
${licenses.length ? `Licenses created: ${licenses.map((license: any) => license.id).join(", ")}` : "No License created"} `
`Could not process the order.completed webhook event with Id ${orderCompletedEvent.id}. ${userId ? `User ID: ${userId} created` : "User ID not created"}. ${licenses.length ? `Licenses created: ${licenses.map((license: any) => license.id).join(", ")}` : "No License created"}. Failure reason: ${reason}`
);
}
} else {
throw new Error(
`Could not process the order.completed webhook event with Id ${orderCompletedEvent.id}.`
`Could not process the order.completed webhook event with Id ${orderCompletedEvent.id}.
Order was not completed.`
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,16 @@ export async function handleSubscriptionChargeCompleted(
status: 200,
};
} catch (error) {
const reason =
error instanceof Error ? error.message : String(error);
throw new Error(
`Could not process the subscription.charge.completed webhook event with Id ${subscriptionChargeCompletedEvent.id}. ${responses.length ? `Licenses renewed: ${responses.map((response: any) => response.id).join(", ")}` : "No License renewed"} `
`Could not process the subscription.charge.completed webhook event with Id ${subscriptionChargeCompletedEvent.id}. ${responses.length ? `Licenses renewed: ${responses.map((response: any) => response.id).join(", ")}` : "No License renewed"}. Failure reason: ${reason}`
);
}
} else {
throw new Error(
`Could not process the subscription.charge.completed webhook event with Id ${subscriptionChargeCompletedEvent.id}.`
`Could not process the subscription.charge.completed webhook event with Id ${subscriptionChargeCompletedEvent.id}.
Subscription charge was not completed.`
);
}
}
7 changes: 5 additions & 2 deletions fastspring/lib/eventHandlers/handleSubscriptionDeactivated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ export async function handleSubscriptionDeactivated(
status: 200,
};
} catch (error) {
const reason =
error instanceof Error ? error.message : String(error);
throw new Error(
`Could not process the subscription.deactivated webhook event with Id ${subscriptionDeactivatedEvent.id}. All licenses were not deleted`
`Could not process the subscription.deactivated webhook event with Id ${subscriptionDeactivatedEvent.id}. Failed to delete all licenses.. Failure reason: ${reason}`
);
}
} else {
throw new Error(
`Could not process the subscription.deactivated webhook event with Id ${subscriptionDeactivatedEvent.id}.`
`Could not process the subscription.deactivated webhook event with Id ${subscriptionDeactivatedEvent.id}.
Subscription was not deactivated.`
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ export async function handleSubscriptionPaymentOverdue(
status: 200,
};
} catch (error) {
const reason =
error instanceof Error ? error.message : String(error);
throw new Error(
`Could not process the subscription.payment.overdue webhook event with Id ${paymentOverdueEvent.id}.
${responses.length ? `Licenses suspended: ${responses.map((response: any) => response.id).join(", ")}` : "No License suspended"} `
`Could not process the subscription.payment.overdue webhook event with Id ${paymentOverdueEvent.id}. ${responses.length ? `Licenses suspended: ${responses.map((response: any) => response.id).join(", ")}` : "No License suspended"}. Failure reason: ${reason}`
);
}
} else {
throw new Error(
`Could not process the subscription.payment.overdue webhook event with Id ${paymentOverdueEvent.id}.`
`Could not process the subscription.payment.overdue webhook event with Id ${paymentOverdueEvent.id}.
Subscription payment was not overdue.`
);
}
}
2 changes: 1 addition & 1 deletion fastspring/lib/utils/getCustomAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function getCustomAttributes(item: any) {
const subscriptionInterval =
customAttributes?.cryptlex_license_subscription_interval;
const mappingsQuantity = customAttributes?.cryptlex_mappings_quantity;
const isBundle = customAttributes?.is_bundle === "true";
const isBundle = customAttributes?.cryptlex_is_bundle === "true";
if ((productId && licenseTemplateId) || isBundle) {
return {
productId,
Expand Down