def cancel_subscription(customer_id, subscription_id):
 try:
  customer = stripe.Customer.retrieve(customer_id)
  if hasattr(customer, 'subscriptions'):
   subscription = customer.subscriptions.retrieve(subscription_id)
   return subscription.delete()
 except stripe.error.StripeError:
  pass

def cancel_subscription ( customer_id , subscription_id ) : try : customer = stripe . Customer . retrieve ( customer_id ) if hasattr ( customer , 'subscriptions' ) : subscription = customer . subscriptions . retrieve ( subscription_id ) return subscription . delete ( ) except stripe . error . StripeError : pass
cancel stripe subscription .