Start Free Trial
, }; } switch (scenario) { case "scheduled": return { buttonText:Plan Scheduled
, }; case "active": if (has_prepaid) { return { buttonText:Update Plan
, }; } return { buttonText:Current Plan
, }; case "new": if (is_one_off) { return { buttonText:Purchase
, }; } return { buttonText:Get started
, }; case "renew": return { buttonText:Renew
, }; case "upgrade": return { buttonText:Upgrade
, }; case "downgrade": return { buttonText:Downgrade
, }; case "cancel": return { buttonText:Cancel Plan
, }; default: return { buttonText:Get Started
, }; } }; ``` -------------------------------- TITLE: Check Metered Feature Access with Quantity (React) DESCRIPTION: Checks if a customer has access to a feature, specifying a required quantity. This prevents users from starting processes that would consume more than their allowance. It defaults to a required quantity of 1. SOURCE: https://docs.useautumn.com/features/check LANGUAGE: javascript CODE: ``` const { allowed, check } = useCustomer(); const canSendMessage = allowed({ featureId: "messages", requiredQuantity: 3 }); const { data } = await check({ featureId: "messages", requiredQuantity: 3 }); ``` -------------------------------- TITLE: Get Customer - TypeScript DESCRIPTION: Retrieves a specific customer's details using their unique identifier. This operation requires authentication with a secret key. The response includes customer information such as their ID, name, email, associated products, and feature entitlements. SOURCE: https://docs.useautumn.com/api-reference/customers/get LANGUAGE: TypeScript CODE: ``` import { Autumn as autumn } from 'autumn-js'; const { data } = await autumn.customers.get('user_123'); ``` -------------------------------- TITLE: Define Free Product with Features DESCRIPTION: Defines a 'Free' product that includes several features: 5 messages per month, 3 seats, and SSO authentication. This demonstrates how to bundle features into a product. SOURCE: https://docs.useautumn.com/api-reference/cli/config LANGUAGE: typescript CODE: ``` export const free = product({ id: "free", name: "Free", is_default: true, items: [ // 5 messages per month featureItem({ feature_id: messages.id, included_usage: 5, interval: "month", }), // 3 seats (no reset) featureItem({ feature_id: seats.id, included_usage: 3, }), // SSO Auth (boolean) featureItem({ feature_id: sso.id, }), ], }); ``` -------------------------------- TITLE: Create Product DESCRIPTION: Creates a new product in the Autumn platform. This endpoint requires authentication and accepts product details in JSON format, including ID, name, add-on status, default status, items, and free trial information. The response includes the created product's details. SOURCE: https://docs.useautumn.com/api-reference/products/post LANGUAGE: bash CODE: ``` curl --request POST \ --url https://api.useautumn.com/v1/products \ --header 'Authorization: Bearer