PaperTiger.Resources.Plan (PaperTiger v0.9.20)
View SourceHandles Plan resource endpoints.
Endpoints
- POST /v1/plans - Create plan
- GET /v1/plans/:id - Retrieve plan
- POST /v1/plans/:id - Update plan
- DELETE /v1/plans/:id - Delete plan
- GET /v1/plans - List plans
Plan Object
Note: Plans are DEPRECATED in favor of Prices but still supported.
%{
id: "plan_...",
object: "plan",
created: 1234567890,
active: true,
amount: 2000, # in cents
currency: "usd",
interval: "month",
interval_count: 1,
product: "prod_...",
nickname: "Premium Plan",
metadata: %{},
# ... other fields
}
Summary
Functions
Creates a new plan.
Deletes a plan.
Lists all plans with pagination.
Retrieves a plan by ID.
Updates a plan.
Functions
@spec create(Plug.Conn.t()) :: Plug.Conn.t()
Creates a new plan.
Required Parameters
- currency - Three-letter ISO currency code (e.g., "usd")
- interval - Billing interval ("day", "week", "month", or "year")
- amount - Price in cents (e.g., 2000 for $20.00)
Optional Parameters
- id - Custom plan ID (if not provided, auto-generated as "plan_...")
- active - Whether plan is active (default: true)
- interval_count - Number of intervals between billings (default: 1)
- product - Product ID this plan belongs to
- nickname - Plan nickname
- metadata - Key-value metadata
@spec delete(Plug.Conn.t(), String.t()) :: Plug.Conn.t()
Deletes a plan.
Returns a deletion confirmation object.
@spec list(Plug.Conn.t()) :: Plug.Conn.t()
Lists all plans with pagination.
Parameters
- limit - Number of items (default: 10, max: 100)
- starting_after - Cursor for pagination
- ending_before - Reverse cursor
- active - Filter by active status
@spec retrieve(Plug.Conn.t(), String.t()) :: Plug.Conn.t()
Retrieves a plan by ID.
@spec update(Plug.Conn.t(), String.t()) :: Plug.Conn.t()
Updates a plan.
Note: Plans have limited fields that can be updated.
Updatable Fields
- active
- metadata
- nickname