Cancel a subscription
Cancels a customer’s subscription. If you set the at_period_end parameter to true, the subscription will remain active until the end of the period, at which point it will be canceled and not renewed. Otherwise, with the default false value, the subscription is terminated immediately. In either case, 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.
API Endpoint: DELETE /v1/customers/{customer}/subscriptions/{subscription_exposed_id}
from os import getenv
from sideko_stripe import Stripe
client = Stripe(token=getenv("API_TOKEN"))
res = client.customer.subscription.delete(
customer="string", subscription_exposed_id="string"
)from os import getenv
from sideko_stripe import AsyncStripe
client = AsyncStripe(token=getenv("API_TOKEN"))
res = await client.customer.subscription.delete(
customer="string", subscription_exposed_id="string"
)List active subscriptions
You can see a list of the customer’s active subscriptions. Note that the 10 most recent active subscriptions are always available by default on the customer object. If you need more than those 10, you can use the limit and starting_after parameters to page through additional subscriptions.
API Endpoint: GET /v1/customers/{customer}/subscriptions
from os import getenv
from sideko_stripe import Stripe
client = Stripe(token=getenv("API_TOKEN"))
res = client.customer.subscription.list(customer="string")from os import getenv
from sideko_stripe import AsyncStripe
client = AsyncStripe(token=getenv("API_TOKEN"))
res = await client.customer.subscription.list(customer="string")Retrieve a subscription
Retrieves the subscription with the given ID.
API Endpoint: GET /v1/customers/{customer}/subscriptions/{subscription_exposed_id}
from os import getenv
from sideko_stripe import Stripe
client = Stripe(token=getenv("API_TOKEN"))
res = client.customer.subscription.get(
customer="string", subscription_exposed_id="string"
)from os import getenv
from sideko_stripe import AsyncStripe
client = AsyncStripe(token=getenv("API_TOKEN"))
res = await client.customer.subscription.get(
customer="string", subscription_exposed_id="string"
)Create a subscription
Creates a new subscription on an existing customer.
API Endpoint: POST /v1/customers/{customer}/subscriptions
from os import getenv
from sideko_stripe import Stripe
client = Stripe(token=getenv("API_TOKEN"))
res = client.customer.subscription.create(customer="string")from os import getenv
from sideko_stripe import AsyncStripe
client = AsyncStripe(token=getenv("API_TOKEN"))
res = await client.customer.subscription.create(customer="string")Update a subscription on a customer
Updates an existing subscription on a customer to match the specified parameters. When changing plans or quantities, we will optionally prorate the price we charge next month to make up for any price changes. To preview how the proration will be calculated, use the upcoming invoice endpoint.
API Endpoint: POST /v1/customers/{customer}/subscriptions/{subscription_exposed_id}
from os import getenv
from sideko_stripe import Stripe
client = Stripe(token=getenv("API_TOKEN"))
res = client.customer.subscription.modify(
customer="string", subscription_exposed_id="string"
)from os import getenv
from sideko_stripe import AsyncStripe
client = AsyncStripe(token=getenv("API_TOKEN"))
res = await client.customer.subscription.modify(
customer="string", subscription_exposed_id="string"
)