Paddle.Modifier (paddlex v0.2.0)

Copy Markdown View Source

Create, list, and delete recurring charge modifiers on subscriptions.

Summary

Functions

Create a subscription modifier to dynamically change the subscription payment amount

Delete an existing subscription modifier

List all subscription modifiers

Types

t()

@type t() :: %{
  modifier_id: integer(),
  subscription_id: integer(),
  amount: String.t(),
  currency: String.t(),
  is_recurring: boolean(),
  description: String.t()
}

Functions

create(params, opts \\ [])

@spec create(
  params,
  keyword()
) :: {:ok, map()} | {:error, Paddle.Error.t()}
when params: %{
       subscription_id: integer(),
       modifier_recurring: boolean(),
       modifier_amount: number(),
       modifier_description: String.t()
     }

Create a subscription modifier to dynamically change the subscription payment amount

A modifier applied to a recurring subscription increases or decreases the next payment by a flat amount (in the currency of the subscription). The modifier itself may recur and apply to all future payments until it is removed.

Examples

Paddle.Modifier.create(params) 
params = %{
  subscription_id: 12345,
  modifier_recurring: true,
  modifier_amount: 20,
  modifier_description: "TestModifier"
}
{:ok, %{
  subscription_id: 12345,
  modifier_id: 10
}}

delete(modifier_id, opts \\ [])

@spec delete(
  integer(),
  keyword()
) :: {:ok, nil} | {:error, Paddle.Error.t()}

Delete an existing subscription modifier

Examples

Paddle.Modifier.delete(10)
{:ok, nil}

list(opts \\ [])

@spec list(keyword()) :: {:ok, [t()]} | {:error, Paddle.Error.t()}

List all subscription modifiers

Optionally, the query accepts the parameter plan_id with the value of a Plan/Product ID, to list all the subscriptions modifiers of a certain plan. It also accepts subscription_id to get modifiers applied to a specific subscription plan.

Examples

Paddle.Modifier.list() 
{:ok, [%Paddle.Modifier{
  modifier_id: 10,
  subscription_id: 12345,
  amount: "1.000",
  currency: "USD",
  is_recurring: false,
  description: "Example Modifier"
}]}