Paypal.Subscription.Product (Paypal v0.2.0)

Copy Markdown View Source

Manage catalog products for PayPal Subscriptions.

Products represent the goods or services that you offer to your subscribers. Before creating a billing plan or subscription, you need to create a product.

Official PayPal API Documentation: PayPal Catalog Products API v1

Summary

Functions

Create a product.

List products with optional pagination filters.

Show product details by product ID.

Returns the supported product types

Update a product by ID using JSON Patch operations.

Functions

create(params)

@spec create(map()) ::
  {:ok, Paypal.Subscription.Product.Info.t()}
  | {:error, Paypal.Common.Error.t() | term()}

Create a product.

Official documentation: Create Product

Examples

iex> Paypal.Subscription.Product.create(%{
...>   name: "Video Streaming Service",
...>   type: :service,
...>   description: "Monthly video streaming access",
...>   category: "SOFTWARE"
...> })
{:ok, %Paypal.Subscription.Product.Info{id: "PROD-123", ...}}

list(opts \\ [])

@spec list(keyword() | map()) ::
  {:ok, Paypal.Subscription.Product.List.t()}
  | {:error, Paypal.Common.Error.t() | term()}

List products with optional pagination filters.

Official documentation: List Products

Options

  • :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 (true or false).

show(product_id)

@spec show(String.t()) ::
  {:ok, Paypal.Subscription.Product.Info.t()}
  | {:error, Paypal.Common.Error.t() | term()}

Show product details by product ID.

Official documentation: Show Product Details

types()

@spec types() :: [physical: String.t(), digital: String.t(), service: String.t()]

Returns the supported product types:

  • :physical - Physical goods.
  • :digital - Digital goods.
  • :service - Services or recurring memberships.

update(product_id, patch_operations)

@spec update(String.t(), [map()]) :: :ok | {:error, Paypal.Common.Error.t() | term()}

Update a product by ID using JSON Patch operations.

Official documentation: Update Product

Examples

iex> Paypal.Subscription.Product.update("PROD-123", [
...>   %{op: "replace", path: "/description", value: "New product description"}
...> ])
:ok