Sha256: 6ab85c3d5b1dbbd572da78f42ba34fffcb1d7cc34352c0be2ef2308ba1a2e814

Contents?: true

Size: 377 Bytes

Versions: 2

Compression:

Stored size: 377 Bytes

Contents

module Tang
  class RemoveCustomerDiscount
    def self.call(customer)
      begin
        cu = Stripe::Customer.retrieve(customer.stripe_id)
        cu.delete_discount
      rescue Stripe::StripeError => e
        customer.errors.add(:base, :invalid, message: e.message)
      end

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

      return customer
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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