Class: Payola::CancelSubscription
- Inherits:
-
Object
- Object
- Payola::CancelSubscription
- Defined in:
- app/services/payola/cancel_subscription.rb
Class Method Summary collapse
Class Method Details
.call(subscription, options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# 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) unless [:at_period_end] == true subscription.cancel! end end |