diff --git a/CHANGELOG.md b/CHANGELOG.md index 89e56b0c..3e860617 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx&utm_medium=paddle-python-sdk) for information about changes to the Paddle Billing platform, the Paddle API, and other developer tools. +## 1.19.1 - 2026-11-27 + +### Fixed + +- `ListProducts` now sends `product_ids` as the `id` filter. Previously it was accepted but never sent, so all products were returned. It is merged with `ids`, with duplicates removed + +### Deprecated + +- `ListProducts` `product_ids` is deprecated, use `ids` instead + ## 1.19.0 - 2026-11-24 ### Added diff --git a/paddle_billing/Client.py b/paddle_billing/Client.py index 2b5818bd..1fcbf4ec 100644 --- a/paddle_billing/Client.py +++ b/paddle_billing/Client.py @@ -247,7 +247,7 @@ def build_request_session(self) -> Session: "Authorization": f"Bearer {self.__api_key}", "Content-Type": "application/json", "Paddle-Version": str(self.use_api_version), - "User-Agent": "PaddleSDK/python 1.19.0", + "User-Agent": "PaddleSDK/python 1.19.1", } ) diff --git a/paddle_billing/Resources/Products/Operations/ListProducts.py b/paddle_billing/Resources/Products/Operations/ListProducts.py index 4c44dda2..a321ac8a 100644 --- a/paddle_billing/Resources/Products/Operations/ListProducts.py +++ b/paddle_billing/Resources/Products/Operations/ListProducts.py @@ -17,6 +17,10 @@ class ListProducts(HasParameters): + """ + Deprecated: `product_ids` is deprecated, use `ids` instead. It is merged into the `id` filter. + """ + def __init__( self, pager: Pager | None = None, @@ -38,6 +42,7 @@ def __init__( # Validation validations: list[tuple[str, list[Any], type]] = [ ("ids", self.ids, str), + ("product_ids", self.product_ids, str), ("includes", self.includes, ProductIncludes), ("statuses", self.statuses, Status), ("tax_categories", self.tax_categories, TaxCategory), @@ -54,8 +59,9 @@ def get_parameters(self) -> dict[str, str]: parameters = {} if self.pager: parameters.update(self.pager.get_parameters()) - if self.ids: - parameters["id"] = ",".join(self.ids) + ids = list(dict.fromkeys([*self.ids, *self.product_ids])) + if ids: + parameters["id"] = ",".join(ids) if self.includes: parameters["include"] = ",".join(map(enum_stringify, self.includes)) if self.statuses: diff --git a/setup.py b/setup.py index 790e3ae4..0b50636b 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup, find_packages setup( - version="1.19.0", + version="1.19.1", author="Paddle and contributors", author_email="team-dx@paddle.com", description="Paddle's Python SDK for Paddle Billing", diff --git a/tests/Functional/Resources/Products/test_ProductsClient.py b/tests/Functional/Resources/Products/test_ProductsClient.py index 3def9c9e..a61d6923 100644 --- a/tests/Functional/Resources/Products/test_ProductsClient.py +++ b/tests/Functional/Resources/Products/test_ProductsClient.py @@ -1,11 +1,12 @@ from json import loads -from pytest import mark +from pytest import mark, raises from urllib.parse import unquote from paddle_billing.Entities.Collections import ProductCollection from paddle_billing.Entities.Product import Product from paddle_billing.Entities.Shared import CustomData, Status, TaxCategory +from paddle_billing.Exceptions.SdkExceptions.InvalidArgumentException import InvalidArgumentException from paddle_billing.Resources.Products.Operations import CreateProduct, ListProducts, UpdateProduct, ProductIncludes from paddle_billing.Resources.Shared.Operations import Pager @@ -179,6 +180,24 @@ def test_update_product_uses_expected_payload( 200, "/products?id=pro_01gsz4s0w61y0pp88528f1wvvb,pro_01h1vjes1y163xfj1rh1tkfb65", ), + ( + ListProducts(product_ids=["pro_01gsz4s0w61y0pp88528f1wvvb"]), + 200, + "/products?id=pro_01gsz4s0w61y0pp88528f1wvvb", + ), + ( + ListProducts(ids=["pro_01gsz4s0w61y0pp88528f1wvvb"], product_ids=["pro_01h1vjes1y163xfj1rh1tkfb65"]), + 200, + "/products?id=pro_01gsz4s0w61y0pp88528f1wvvb,pro_01h1vjes1y163xfj1rh1tkfb65", + ), + ( + ListProducts( + ids=["pro_01gsz4s0w61y0pp88528f1wvvb", "pro_01h1vjes1y163xfj1rh1tkfb65"], + product_ids=["pro_01h1vjes1y163xfj1rh1tkfb65", "pro_01gsz4s0w61y0pp88528f1wvvb", "pro_02new"], + ), + 200, + "/products?id=pro_01gsz4s0w61y0pp88528f1wvvb,pro_01h1vjes1y163xfj1rh1tkfb65,pro_02new", + ), ( ListProducts(tax_categories=[TaxCategory.DigitalGoods, TaxCategory.Standard]), 200, @@ -193,6 +212,9 @@ def test_update_product_uses_expected_payload( "List products filtered by status", "List products filtered by id", "List products filtered by multiple ids", + "List products filtered by product_ids", + "List products filtered by ids and product_ids", + "List products merges duplicate ids and product_ids preserving order", "List products filtered by tax categories", "List products with includes", ], @@ -219,6 +241,10 @@ def test_list_products_returns_expected_response( unquote(last_request.url) == expected_url ), "The URL does not match the expected URL, verify the query string is correct" + def test_list_products_rejects_non_string_product_ids(self): + with raises(InvalidArgumentException): + ListProducts(product_ids=[123]) # type: ignore[list-item] + @mark.parametrize( "product_id, includes, expected_response_status, expected_response_body, expected_url", [