#Overview
There is a simple mechanism for hooking into the lifecycle of subscriptions and transactions, which would allow you to execute custom code when certain events happen, such as deactivating or deleting a
User
when a subscription is cancelled. The current list of lifecycle hooks are:
- subscription_created
- subscription_updated
- subscription_deleted
- transaction_created
#The LifecycleHooks class
You'll find the
LifecycleHooks
class in app/kiso_stripe_payments/lifecycle_hooks.rb
and it contains stubbed out handlers for each of the supported lifecycle events. Each handler is passed the params sent to the services called, allowing you to look up subscriptions or transactions. #Example LifecycleHooks class
module KisoStripePayments module LifecycleHooks class << self def on_subscription_created(params) Rails.logger.debug("************* Subscription created lifecycle hook") end def on_subscription_deleted(params) Rails.logger.debug("************* Subscription deleted lifecycle hook") end def on_subscription_updated(params) Rails.logger.debug("************* Subscription updated lifecycle hook") end def on_transaction_created(params) Rails.logger.debug("************* Transaction created lifecycle hook") end end end end