Sha256: ca93cdeb3fe9a4a11e4da93841bc38aaff489c837586e3dbdd8f5fb704f4732e

Contents?: true

Size: 391 Bytes

Versions: 2

Compression:

Stored size: 391 Bytes

Contents

module Tang
  class RemoveSubscriptionDiscount
    def self.call(subscription)
      begin
        Stripe::Subscription.retrieve(subscription.stripe_id).delete_discount()
      rescue Stripe::StripeError => e
        subscription.errors.add(:base, :invalid, message: e.message)
      end

      subscription.update(coupon: nil, coupon_start: nil)

      return subscription
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tang-0.2.2 app/services/tang/remove_subscription_discount.rb
tang-0.2.1 app/services/tang/remove_subscription_discount.rb