Sha256: f0772bcb47c324b1cf324aa923ee7fc93a5536370966d03a474dd036d366b8dc
Contents?: true
Size: 849 Bytes
Versions: 17
Compression:
Stored size: 849 Bytes
Contents
module Pay module Paddle module Webhooks class SubscriptionCancelled def call(event) pay_subscription = Pay::Subscription.find_by_processor_and_id(:paddle, event.subscription_id) # We couldn't find the subscription for some reason, maybe it's from another service return if pay_subscription.nil? # User canceled subscriptions have an ends_at # Automatically canceled subscriptions need this value set pay_subscription.update!(ends_at: Time.zone.parse(event.cancellation_effective_date)) if pay_subscription.ends_at.blank? && event.cancellation_effective_date.present? # Paddle doesn't allow reusing customers, so we should remove their payment methods pay_subscription.customer.payment_methods.destroy_all end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems