diff --git a/fastspring/lib/eventHandlers/handleOrderCreated.ts b/fastspring/lib/eventHandlers/handleOrderCreated.ts index 34b8b30..929694c 100644 --- a/fastspring/lib/eventHandlers/handleOrderCreated.ts +++ b/fastspring/lib/eventHandlers/handleOrderCreated.ts @@ -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.` ); } } diff --git a/fastspring/lib/eventHandlers/handleSubscriptionChargeCompleted.ts b/fastspring/lib/eventHandlers/handleSubscriptionChargeCompleted.ts index 8dd91f9..915d1d9 100644 --- a/fastspring/lib/eventHandlers/handleSubscriptionChargeCompleted.ts +++ b/fastspring/lib/eventHandlers/handleSubscriptionChargeCompleted.ts @@ -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.` ); } } diff --git a/fastspring/lib/eventHandlers/handleSubscriptionDeactivated.ts b/fastspring/lib/eventHandlers/handleSubscriptionDeactivated.ts index 0c2a152..a042654 100644 --- a/fastspring/lib/eventHandlers/handleSubscriptionDeactivated.ts +++ b/fastspring/lib/eventHandlers/handleSubscriptionDeactivated.ts @@ -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.` ); } } diff --git a/fastspring/lib/eventHandlers/handleSubscriptionPaymentOverdue.ts b/fastspring/lib/eventHandlers/handleSubscriptionPaymentOverdue.ts index 0e3c5e7..38c0468 100644 --- a/fastspring/lib/eventHandlers/handleSubscriptionPaymentOverdue.ts +++ b/fastspring/lib/eventHandlers/handleSubscriptionPaymentOverdue.ts @@ -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.` ); } } diff --git a/fastspring/lib/utils/getCustomAttributes.ts b/fastspring/lib/utils/getCustomAttributes.ts index b83e3ed..4be82a4 100644 --- a/fastspring/lib/utils/getCustomAttributes.ts +++ b/fastspring/lib/utils/getCustomAttributes.ts @@ -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,