Class: Tang::RemoveCustomerDiscount

Inherits:
Object
  • Object
show all
Defined in:
app/services/tang/remove_customer_discount.rb

Class Method Summary collapse

Class Method Details

.call(customer) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/services/tang/remove_customer_discount.rb', line 3

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