PaperTiger.Resources.SubscriptionSchedule (PaperTiger v1.0.2)

Copy Markdown View Source

Handles SubscriptionSchedule resource endpoints.

Endpoints

  • POST /v1/subscription_schedules - Create subscription schedule
  • GET /v1/subscription_schedules/:id - Retrieve subscription schedule
  • POST /v1/subscription_schedules/:id - Update subscription schedule
  • POST /v1/subscription_schedules/:id/cancel - Cancel subscription schedule
  • POST /v1/subscription_schedules/:id/release - Release subscription schedule
  • GET /v1/subscription_schedules - List subscription schedules

SubscriptionSchedule Object

%{
  id: "sub_sched_...",
  object: "subscription_schedule",
  created: 1234567890,
  customer: "cus_...",
  status: "not_started",
  phases: [
    %{
      start_date: 1234567890,
      end_date: 1237159890,
      plans: [%{price: "price_...", quantity: 1}]
    }
  ],
  # ... other fields
}

Schedule Statuses

  • not_started - Schedule hasn't started yet
  • active - Schedule is currently active
  • completed - Schedule has completed all phases
  • released - Schedule was released
  • canceled - Schedule was canceled

Summary

Functions

Cancels a subscription schedule.

Creates a new subscription schedule.

Lists all subscription schedules with pagination.

Releases a subscription schedule.

Retrieves a subscription schedule by ID.

Updates a subscription schedule.

Functions

cancel(conn, id)

@spec cancel(Plug.Conn.t(), String.t()) :: Plug.Conn.t()

Cancels a subscription schedule.

POST /v1/subscription_schedules/:id/cancel

Cancels the schedule and any associated subscription.

create(conn)

@spec create(Plug.Conn.t()) :: Plug.Conn.t()

Creates a new subscription schedule.

Required Parameters

  • customer - Customer ID
  • phases - Array of schedule phases

Optional Parameters

  • from_subscription - Create from existing subscription
  • start_date - When schedule should start
  • end_behavior - What happens when schedule ends
  • metadata - Key-value metadata

list(conn)

@spec list(Plug.Conn.t()) :: Plug.Conn.t()

Lists all subscription schedules with pagination.

Parameters

  • limit - Number of items (default: 10, max: 100)
  • starting_after - Cursor for pagination
  • ending_before - Reverse cursor
  • customer - Filter by customer ID
  • scheduled - Filter to only scheduled (not_started) schedules

release(conn, id)

@spec release(Plug.Conn.t(), String.t()) :: Plug.Conn.t()

Releases a subscription schedule.

POST /v1/subscription_schedules/:id/release

Releases the schedule, keeping any active subscription but removing future phases.

retrieve(conn, id)

@spec retrieve(Plug.Conn.t(), String.t()) :: Plug.Conn.t()

Retrieves a subscription schedule by ID.

update(conn, id)

@spec update(Plug.Conn.t(), String.t()) :: Plug.Conn.t()

Updates a subscription schedule.