Skip to content

Latest commit

 

History

History
151 lines (104 loc) · 4.95 KB

File metadata and controls

151 lines (104 loc) · 4.95 KB

delete

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}

Synchronous Client

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"
)

Asynchronous Client

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

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

Synchronous Client

from os import getenv
from sideko_stripe import Stripe

client = Stripe(token=getenv("API_TOKEN"))
res = client.customer.subscription.list(customer="string")

Asynchronous Client

from os import getenv
from sideko_stripe import AsyncStripe

client = AsyncStripe(token=getenv("API_TOKEN"))
res = await client.customer.subscription.list(customer="string")

get

Retrieve a subscription

Retrieves the subscription with the given ID.

API Endpoint: GET /v1/customers/{customer}/subscriptions/{subscription_exposed_id}

Synchronous Client

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"
)

Asynchronous Client

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

Create a subscription

Creates a new subscription on an existing customer.

API Endpoint: POST /v1/customers/{customer}/subscriptions

Synchronous Client

from os import getenv
from sideko_stripe import Stripe

client = Stripe(token=getenv("API_TOKEN"))
res = client.customer.subscription.create(customer="string")

Asynchronous Client

from os import getenv
from sideko_stripe import AsyncStripe

client = AsyncStripe(token=getenv("API_TOKEN"))
res = await client.customer.subscription.create(customer="string")

modify

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}

Synchronous Client

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"
)

Asynchronous Client

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"
)