Class: Payola::CancelSubscription

Inherits:
Object
  • Object
show all
Defined in:
app/services/payola/cancel_subscription.rb

Class Method Summary collapse

Class Method Details

.call(subscription) ⇒ Object



3
4
5
6
7
8
9
# File 'app/services/payola/cancel_subscription.rb', line 3

def self.call(subscription)
  secret_key = Payola.secret_key_for_sale(subscription)
  Stripe.api_key = secret_key
  customer = Stripe::Customer.retrieve(subscription.stripe_customer_id, secret_key)
  customer.subscriptions.retrieve(subscription.stripe_id,secret_key).delete({},secret_key)
  subscription.cancel!
end