Root lifecycle events
Lifecycle hooks that run after policy, payment, and alteration events in a Root collection module.
Use Root lifecycle events to run custom collection module code after policy and payment events.
Define lifecycle hooks in your collection module's lifecycle hooks file (lifecycle-hooks.ts). See Event hooks overview for more information.
Each lifecycle hook accepts a single params object. The examples below use destructuring to show the properties available to each hook. Use these hooks for follow-up work after the event has already happened, such as syncing data to another system, recording audit data, or triggering additional processing. You do not need to return a value from these hooks.
The policy object and policyholder object are passed to all lifecycle hooks. Depending on the event, Root also passes the payment method object, payment object, alteration package, or alteration hook key.
Policy lifecycle
afterPolicyIssued
This hook is triggered after a policy is issued. Use it for follow-up work that depends on the policy existing.
const afterPolicyIssued = async ({ policy, policyholder, payment_method }) => {
// Custom logic
}afterPolicyCancelled
This hook is triggered when a policy is cancelled.
const afterPolicyCancelled = async ({ policy, policyholder, payment_method }) => {
// Custom logic
}afterPolicyExpired
This hook is triggered when a policy expires.
const afterPolicyExpired = async ({ policy, policyholder, payment_method }) => {
// Custom logic
}afterPolicyLapsed
This hook is triggered when a policy lapses.
const afterPolicyLapsed = async ({ policy, policyholder, payment_method }) => {
// Custom logic
}afterPolicyUpdated
This hook is triggered when a policy is updated.
const afterPolicyUpdated = async ({ policy, policyholder, payment_method }) => {
// Custom logic
}afterPolicyPaymentMethodAssigned
This hook is triggered when a payment method is assigned or reassigned to a policy. The payment_method parameter is the newly assigned payment method.
const afterPolicyPaymentMethodAssigned = async ({
policy,
policyholder,
payment_method,
}) => {
// Custom logic
}Payment lifecycle
afterPaymentCreated
This hook is triggered when a payment is created on the policy. Use the payment parameter to inspect the created payment.
const afterPaymentCreated = async ({
policy,
policyholder,
payment_method,
payment,
}) => {
// Custom logic
}afterPaymentUpdated
This hook is triggered when a payment is updated. Use the payment parameter to inspect the updated payment.
const afterPaymentUpdated = async ({
policy,
policyholder,
payment_method,
payment,
}) => {
// Custom logic
}afterPaymentCouponRedeemed
This hook is triggered when a payment coupon is redeemed.
const afterPaymentCouponRedeemed = async ({
policy,
policyholder,
payment_method,
payment,
}) => {
// Custom logic
}afterPaymentMethodRemoved
This hook is triggered when a payment method is removed from the policy.
const afterPaymentMethodRemoved = async ({
policy,
policyholder,
payment_method,
}) => {
// Custom logic
}Alteration lifecycle
afterAlterationPackageApplied
This hook is triggered when an alteration package is applied to a policy.
const afterAlterationPackageApplied = async ({
policy,
policyholder,
payment_method,
alteration_package,
alteration_hook_key,
}) => {
// Custom logic
}Updated 8 days ago