Skip to main content
Solved

Question Regarding the Type and Period_Type of Webhook Events

  • Oct 17, 2024 4:42 PM UTC
  • 2 replies
  • 491 views

Forum|alt.badge.img+1

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.

Best answer by kaitlin

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!

View original
This post has been closed for comments

2 replies

kaitlin
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • Answer
  • Oct 21, 2024 5:05 PM UTC

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!


Forum|alt.badge.img+1
  • Author
  • New Member
  • Oct 22, 2024 1:06 AM UTC

Thank you @kaitlin !