Sha256: 62babc31eaa0d32398e6a560df39cd9e1bbaaad1fbb3f9cd85e1ce3c38a9ffd6

Contents?: true

Size: 698 Bytes

Versions: 4

Compression:

Stored size: 698 Bytes

Contents

module Pay
  module Paddle
    module Webhooks
      class SubscriptionCancelled
        def initialize(data)
          subscription = Pay.subscription_model.find_by(processor: :paddle, processor_id: data["subscription_id"])

          # We couldn't find the subscription for some reason, maybe it's from another service
          return if subscription.nil?

          # User canceled subscriptions have an ends_at
          # Automatically canceled subscriptions need this value set
          subscription.update!(ends_at: Time.zone.parse(data["cancellation_effective_date"])) if subscription.ends_at.blank? && data["cancellation_effective_date"].present?
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pay-2.4.4 lib/pay/paddle/webhooks/subscription_cancelled.rb
pay-2.4.3 lib/pay/paddle/webhooks/subscription_cancelled.rb
pay-2.4.2 lib/pay/paddle/webhooks/subscription_cancelled.rb
pay-2.4.0 lib/pay/paddle/webhooks/subscription_cancelled.rb