diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf72294..758b1cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,7 @@ jobs: python-version: '3.12' - run: >- uv run --isolated --no-project --default-index https://pypi.org/simple - --with 'vatly-api-python==0.1.0a2' --with 'pytest>=8,<10' + --refresh-package vatly-api-python + --with 'vatly-api-python==0.1.0a3' --with 'pytest>=8,<10' --with 'pytest-asyncio>=1,<2' --with 'pyyaml>=6,<7' python -m pytest -q tests/test_docs.py diff --git a/docs/Orders.md b/docs/Orders.md index 4db9e67..0ecbac9 100644 --- a/docs/Orders.md +++ b/docs/Orders.md @@ -14,22 +14,32 @@ from vatly import VatlyClient def example(client: VatlyClient): order = client.orders.get("order_example") lines = [(line.product_type, line.product_id, line.quantity) for line in order.lines] + subscription_ids = [ + line.related_resources.subscription_id + for line in order.lines + if line.related_resources is not None + ] refundable = Decimal(order.refundable_subtotal.root.value) - return order.status, lines, refundable + return order.status, lines, subscription_ids, refundable ``` | Response field | Meaning | | --- | --- | | `id`, `status`, `customer_id` | Order identity and payment state | -| `lines` | OrderLine models with `id`, `product_type`, `product_id`, `quantity` | +| `lines` | OrderLine models with `id`, `product_type`, `product_id`, `quantity`, `related_resources` | | `refundable_subtotal`, `reversed_subtotal` | Money wrappers; read `.root.value` and `.root.currency` | | `links.customer_invoice` | Optional customer invoice link | | `testmode`, `metadata` | Mode and custom data | `product_type="subscription_plan"` means `product_id` is a plan ID; `"subscription"` means a subscription ID. Never substitute one for the other. -This alpha has no typed related-resources accessor; extra response fields survive -validation, but application linkage support still needs a package update. + +`line.related_resources.subscription_id` is the subscription associated with a +signup, renewal or immediate-update line. `related_resources` is `None` on +historical and unrelated lines. On a signup line, `subscription_id` is `None` +until the subscription is available; read the order again later. An ID alone +does not prove activation or entitlement: check the subscription's ownership and +status before granting access. ## List orders and request an invoice-details link diff --git a/docs/README.md b/docs/README.md index daac941..7e74763 100644 --- a/docs/README.md +++ b/docs/README.md @@ -9,7 +9,7 @@ integration, use Fluent Python or Vatly Django. ## Install and connect ```bash -python -m pip install vatly-api-python==0.1.0a2 +python -m pip install vatly-api-python==0.1.0a3 ``` Set `VATLY_API_KEY` in your server environment. Test and live keys use the same @@ -63,4 +63,4 @@ camelCase wire keys. Unknown response fields are preserved. [API reference](https://docs.vatly.com/api-reference) contains the complete request and response contracts. Examples in these guides are executed against published -`0.1.0a2` packages with local HTTP fixtures; tests make no Vatly account changes. +`0.1.0a3` packages with local HTTP fixtures; tests make no Vatly account changes.