Paysafe.Scheduler.Plans (Paysafe v1.0.0)

Copy Markdown View Source

Plan operations for the Paysafe Payment Scheduler API.

A Plan defines the billing parameters for a recurring subscription: amount, billing cycle, trial period, retry logic, and add-ons.

Example

Paysafe.Scheduler.Plans.create(config, %{
  name: "Monthly Pro",
  amount: 1999,
  currency_code: "USD",
  interval: "MONTHLY",
  num_payments: 12,
  payment_method_details: %{
    payment_type: "CARD",
    payment_handle_token: "SCREhpnppPsIqkxO"
  }
})

Summary

Functions

Create a billing plan.

Delete (discontinue) a plan.

Retrieve a plan by ID.

List all plans.

Update a plan's mutable fields.

Functions

create(config, params, opts \\ [])

@spec create(Paysafe.Config.t(), map(), keyword()) ::
  {:ok, Paysafe.Types.Plan.t()} | {:error, Paysafe.Error.t()}

Create a billing plan.

Parameters

  • :name (required) — Plan name.
  • :amount (required) — Per-cycle amount in minor units.
  • :currency_code (required) — ISO 4217 currency code.
  • :interval (required) — One of "DAILY", "WEEKLY", "BI_WEEKLY", "MONTHLY", "QUARTERLY", "SEMI_ANNUALLY", "ANNUALLY".
  • :num_payments — Total number of billing cycles (nil for unlimited).
  • :start_date — ISO 8601 start date. Defaults to today.
  • :trial_amount — Amount for the trial period in minor units.
  • :trial_period — Trial duration in interval units.
  • :max_failed_payments — Max consecutive failures before suspension.
  • :retry_payment_amount — Alternate amount to retry after failure.

delete(config, plan_id, opts \\ [])

@spec delete(Paysafe.Config.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, Paysafe.Error.t()}

Delete (discontinue) a plan.

get(config, plan_id, opts \\ [])

@spec get(Paysafe.Config.t(), String.t(), keyword()) ::
  {:ok, Paysafe.Types.Plan.t()} | {:error, Paysafe.Error.t()}

Retrieve a plan by ID.

list(config, opts \\ [])

@spec list(
  Paysafe.Config.t(),
  keyword()
) :: {:ok, [Paysafe.Types.Plan.t()]} | {:error, Paysafe.Error.t()}

List all plans.

update(config, plan_id, params, opts \\ [])

@spec update(Paysafe.Config.t(), String.t(), map(), keyword()) ::
  {:ok, Paysafe.Types.Plan.t()} | {:error, Paysafe.Error.t()}

Update a plan's mutable fields.

Notes

  • Keep amount increases below 20% to comply with card scheme guidelines.
  • Discontinuing a plan prevents new subscriptions but does not affect existing ones.