Manage billing plans for PayPal Subscriptions.
A billing plan defines the pricing, billing cycles, and payment preferences for a recurring subscription.
Official PayPal API Documentation: PayPal Billing Plans API v1
Summary
Functions
Activate a billing plan by ID.
Create a billing plan.
Deactivate a billing plan by ID.
List billing plans with optional filters.
Show billing plan details by plan ID.
Billing plan statuses
Update a billing plan by ID using JSON Patch operations.
Update pricing schemes for a plan by ID.
Functions
@spec activate(String.t()) :: :ok | {:error, Paypal.Common.Error.t() | term()}
Activate a billing plan by ID.
Official documentation: Activate Plan
@spec create(map()) :: {:ok, Paypal.Subscription.Plan.Info.t()} | {:error, Paypal.Common.Error.t() | term()}
Create a billing plan.
Official documentation: Create Plan
Examples
iex> Paypal.Subscription.Plan.create(%{
...> product_id: "PROD-123",
...> name: "Monthly Premium Plan",
...> description: "Monthly subscription plan",
...> status: :active,
...> billing_cycles: [
...> %{
...> frequency: %{"interval_unit" => "MONTH", "interval_count" => 1},
...> tenure_type: :regular,
...> sequence: 1,
...> total_cycles: 0,
...> pricing_scheme: %{"fixed_price" => %{"currency_code" => "USD", "value" => "10.00"}}
...> }
...> ],
...> payment_preferences: %{
...> auto_bill_outstanding: true,
...> setup_fee_failure_action: :cancel,
...> payment_failure_threshold: 3
...> }
...> })
{:ok, %Paypal.Subscription.Plan.Info{id: "P-123", ...}}
@spec deactivate(String.t()) :: :ok | {:error, Paypal.Common.Error.t() | term()}
Deactivate a billing plan by ID.
Official documentation: Deactivate Plan
@spec list(keyword() | map()) :: {:ok, Paypal.Subscription.Plan.List.t()} | {:error, Paypal.Common.Error.t() | term()}
List billing plans with optional filters.
Official documentation: List Plans
Options
:product_id- Filter by product ID.:plan_ids- Filter by specific plan IDs (comma-separated).:page_size- Number of items per page (1 to 20, default 10).:page- Page number (default 1).:total_required- Whether total items count is returned (trueorfalse).
@spec show(String.t()) :: {:ok, Paypal.Subscription.Plan.Info.t()} | {:error, Paypal.Common.Error.t() | term()}
Show billing plan details by plan ID.
Official documentation: Show Plan Details
Billing plan statuses:
:created- Plan created but not active.:inactive- Plan inactive (cannot be used for new subscriptions).:active- Plan active and ready for subscriptions.
@spec update(String.t(), [map()]) :: :ok | {:error, Paypal.Common.Error.t() | term()}
Update a billing plan by ID using JSON Patch operations.
Official documentation: Update Plan
@spec update_pricing_schemes(String.t(), map() | [map()]) :: :ok | {:error, Paypal.Common.Error.t() | term()}
Update pricing schemes for a plan by ID.
Official documentation: Update Pricing Schemes