Paddle.Modifier (paddlex v0.1.0) View Source

Modifier

Link to this section Summary

Functions

Create a subscription modifier to dynamically change the subscription payment amount

Delete an existing subscription modifier

List all subscription modifiers

Link to this section Types

Specs

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

Link to this section Functions

Specs

create(params) :: {: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
}}

Specs

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

Delete an existing subscription modifier

Examples

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

Specs

list() :: {: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"
}]}