Root lifecycle events

Root Platform will call functions in the collection module code after various triggers during the policy & payment lifeycle. These events are kept and handled in the lifecycle-hooks.ts file.

See Event hooks overview for more information.

Each lifecycle hook accepts a single params object as an argument. The policy object and policyholder object are passed to all lifecycle hooks as properties of params. (Note: this guide refers to the properties of params as the function parameters.) Certain lifecycle hooks also accept additional arguments related to the event that triggered the hook.


afterPolicyPaymentMethodAssigned

This hook is triggered when a payment method is assigned to a policy.

const afterPolicyPaymentMethodAssigned = async ({ policy }) => {
  // Custom logic
}

afterPaymentCreated

This hook is triggered when a payment is created on the policy.

const afterPaymentCreated = async ({ policy }) => {
  // Custom logic
}

afterPaymentUpdated

This hook is triggered when a payment is updated.

const afterPaymentUpdated = async ({ policy }) => {
  // Custom logic
}

afterPaymentMethodRemoved

This hook is triggered when a payment method is removed from the policy.

const afterPaymentMethodRemoved = async ({ policy }) => {
  // Custom logic
}

afterPolicyCancelled

This hook is triggered when a policy is cancelled.

const afterPolicyCancelled = async ({ policy }) => {
  // Custom logic
}

afterPolicyExpired

This hook is triggered when a policy expires.

const afterPolicyExpired = async ({ policy }) => {
  // Custom logic
}

afterPolicyLapsed

This hook is triggered when a policy lapses.

const afterPolicyLapsed = async ({ policy }) => {
  // Custom logic
}

afterPolicyUpdated

This hook is triggered when a policy is updated

const afterPolicyUpdated = async ({ policy }) => {
  // Custom logic
}

afterAlterationPackageApplied

This hook is triggered when applying an alteration package to a policy.

const afterAlterationPackageApplied = async ({
  policy,
  alteration_package,
  alteration_hook_key,
} => {
  // Custom logic
}