code: import stripe
  stripe.api_key = "sk_test_your_key"
  
  stripe.Subscription.delete(
    "sub_1JbiLB2eZvKYlo2CNHnqfMzf",
  )
  '''Response {
    "id": "sub_1JbiLB2eZvKYlo2CNHnqfMzf",
    "object": "subscription",
    "application": null,
    "application_fee_percent": null,
    "automatic_tax": {
      "enabled": false
    },
    "billing_cycle_anchor": 1633337949,
    "billing_thresholds": null,
    "cancel_at": null,
    "cancel_at_period_end": false,
    "canceled_at": 1659519611,
    "collection_method": "charge_automatically",
    "created": 1632128349,
    "currency": "usd",
    "current_period_end": 1660553949,
    "current_period_start": 1658739549,
    "customer": "cus_8TEMHVY5moxIPI",
    "days_until_due": null,
    "default_payment_method": "pm_1JbiL92eZvKYlo2CuiUB2nL1",
    "default_source": null,
    "default_tax_rates": [],
    "description": null,
    "discount": null,
    "ended_at": null,
    "items": {
      "object": "list",
      "data": [
        {
          "id": "si_KGEo6oKuLzcuYw",
          "object": "subscription_item",
          "billing_thresholds": null,
          "created": 1632128350,
          "metadata": {},
          "price": {
            "id": "15",
            "object": "price",
            "active": true,
            "billing_scheme": "per_unit",
            "created": 1386685951,
            "currency": "usd",
            "custom_unit_amount": null,
            "livemode": false,
            "lookup_key": null,
            "metadata": {
              "charset": "utf-8",
              "content": "15"
            },
            "nickname": null,
            "product": "prod_BTdpcRLIUTfsFR",
            "recurring": {
              "aggregate_usage": null,
              "interval": "week",
              "interval_count": 3,
              "usage_type": "licensed"
            },
            "tax_behavior": "unspecified",
            "tiers_mode": null,
            "transform_quantity": null,
            "type": "recurring",
            "unit_amount": 444,
            "unit_amount_decimal": "444"
          },
          "quantity": 1,
          "subscription": "sub_1JbiLB2eZvKYlo2CNHnqfMzf",
          "tax_rates": []
        }
      ],
      "has_more": false,
      "url": "/v1/subscription_items?subscription=sub_1JbiLB2eZvKYlo2CNHnqfMzf"
    },
    "latest_invoice": "in_1LPN8U2eZvKYlo2C2h002pSa",
    "livemode": false,
    "metadata": {},
    "next_pending_invoice_item_invoice": null,
    "pause_collection": null,
    "payment_settings": {
      "payment_method_options": null,
      "payment_method_types": null,
      "save_default_payment_method": null
    },
    "pending_invoice_item_interval": null,
    "pending_setup_intent": null,
    "pending_update": null,
    "schedule": null,
    "start_date": 1632128349,
    "status": "canceled",
    "test_clock": null,
    "transfer_data": null,
    "trial_end": 1633337949,
    "trial_start": 1632128349
  }'''
nl: Cancel a subscriptionCancels a customer’s subscription immediately. The customer will not be charged again for the subscription.
  Note, however, that any pending invoice items that you’ve created will still be charged for at the end of the period, unless manually deleted. If you’ve set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed.
  By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all.ParametersExpand all  invoice_now optional   prorate optional ReturnsThe canceled Subscription object. Its subscription status will be set to canceled