Skip to main content
Solved

Question Regarding the Type and Period_Type of Webhook Events

  • October 17, 2024
  • 2 replies
  • 55 views

Forum|alt.badge.img

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
Did this post help you find an answer to your question?
This post has been closed for comments

2 replies

kaitlin
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • 365 replies
  • Answer
  • October 21, 2024

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
  • Author
  • New Member
  • 1 reply
  • October 22, 2024

Thank you @kaitlin !


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings