Method: Pay::Braintree::Subscription#cancel_now!

Defined in:
lib/pay/braintree/subscription.rb

#cancel_now!(**options) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/pay/braintree/subscription.rb', line 46

def cancel_now!(**options)
  gateway.subscription.cancel(processor_subscription.id)
  ends_at = Time.current
  pay_subscription.update!(
    status: :canceled,
    trial_ends_at: (ends_at if pay_subscription.trial_ends_at?),
    ends_at: ends_at
  )
rescue ::Braintree::BraintreeError => e
  raise Pay::Braintree::Error, e
end