Skip to main content

Hello,  
I am currently developing a feature that sends push notifications before the free trial expires and the subscription begins, using webhooks.

 

The logic is as follows:

if (event.type === 'INITIAL_PURCHASE' && event.period_type === 'TRIAL') {
  // Schedule push notification
} else if (event.type === 'CANCELLATION' && event.period_type === 'TRIAL') {
  // Cancel scheduled push notification
}

Will the above logic work as intended? I am curious if the `period_type` is correctly transmitted as the current subscribed product, regardless of the event type.

Hi @bang9,

This should work as long as the customer doesn’t have multiple subscriptions that may be triggering webhooks intermittently - this is an unlikely scenario but it’s the main edge case I can think of. Otherwise, your approach of listening for the period_type should work!


Thank you @kaitlin !