# frozen_string_literal: true #app/commands/stripe/subscription_webhook/handle_paused_command.rb module Stripe module SubscriptionWebhook class HandlePausedCommand < Stripe::SubscriptionWebhookCommand def call return error! unless valid? && subscription_paused_event? extract_data_from_event return self if failure? pause_local_subscription return self if failure? success! end private def pause_local_subscription subscription.hold! if subscription_status == 'paused' rescue StandardError => e failure!(e.message) end def subscription_paused_event? event[:type] == SUBSCRIPTION_PAUSED_EVENT end end end end