import { Autumn } from 'autumn-js'
const autumn = new Autumn()
const result = await autumn.billing.setupPayment({
customerId: "cus_123",
successUrl: "https://example.com/account/billing",
});{
"customer_id": "cus_123",
"url": "https://checkout.stripe.com/..."
}
Setup Payment
Create a payment setup session for a customer to add or update their payment method.
import { Autumn } from 'autumn-js'
const autumn = new Autumn()
const result = await autumn.billing.setupPayment({
customerId: "cus_123",
successUrl: "https://example.com/account/billing",
});{
"customer_id": "cus_123",
"url": "https://checkout.stripe.com/..."
}
Body Parameters
Response
{
"customer_id": "cus_123",
"url": "https://checkout.stripe.com/..."
}
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
Body
The ID of the customer to attach the plan to.
The ID of the entity to attach the plan to.
If specified, the plan will be attached to the customer after setup.
If this plan contains prepaid features, use this field to specify the quantity of each prepaid feature. This quantity includes the included amount and billing units defined when setting up the plan.
Show child attributes
Show child attributes
The version of the plan to attach.
Customize the plan to attach. Can override the price, items, free trial, or a combination.
Show child attributes
Show child attributes
How to handle proration when updating an existing subscription. 'prorate_immediately' charges/credits prorated amounts now, 'none' skips creating any charges.
prorate_immediately, none A unique ID to identify this subscription. Can be used to target specific subscriptions in update operations when a customer has multiple products with the same plan.
List of discounts to apply. Each discount can be an Autumn reward ID, Stripe coupon ID, or Stripe promotion code.
Show child attributes
Show child attributes
URL to redirect to after successful checkout.
Reset the billing cycle anchor immediately with 'now'.
Unix timestamp in milliseconds for when the attached plan should start. Future dates create a scheduled subscription.
0 <= x <= 9007199254740991Unix timestamp in milliseconds for when the attached plan should end.
0 <= x <= 9007199254740991Additional parameters to pass into the creation of the Stripe checkout session.
Show child attributes
Show child attributes
Custom line items that override the auto-generated proration invoice. Only valid for immediate plan changes (eg. upgrades or one off plans).
Show child attributes
Show child attributes
The processor subscription ID to link. Use this to attach an existing Stripe subscription instead of creating a new one.
Whether to carry over balances from the previous plan.
Show child attributes
Show child attributes
Whether to carry over usages from the previous plan.
Show child attributes
Show child attributes
Key-value metadata to attach to the Stripe subscription, invoice, and checkout session created during this attach flow. Keys prefixed with 'autumn_' are reserved and will be stripped.
Show child attributes
Show child attributes
If true, skips any billing changes for the attach operation.
If true, the customer's plan is activated immediately even when payment is deferred (invoice mode) or pending (Stripe checkout). For Stripe checkout, the customer_product is inserted before the customer completes the hosted form.
Stripe tax rate ID (txr_...) to apply as the default tax rate on the created subscription, invoice, or checkout session line items.