Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

## Unreleased

## 0.1.0a5 — 2026-11-30

- Sync `openapi.yaml` with the production specification (discounts).
- `CreateCheckoutRequest.discounts` takes an optional list of `CheckoutDiscount`, at
most one for now: a `percentage` or a fixed EUR `amount`, plus an optional
`description`. A fixed amount follows the products' tax basis. Validation errors
from Vatly are keyed `discounts.0.*`.
- Add `Order.discounts` and `OrderLine.discounts`, lists of `Discount` with `id`,
`description`, `discount_type`, `percentage` and `amount` (always excluding taxes),
on order resources and in order webhooks. `discount_type` is an open string:
values other than `percentage` and `fixed_amount` parse. Orders and lines without
`discounts`, such as webhook events stored before discounts existed, read as `[]`.
- `OrderLine` field descriptions now say `subtotal`, `taxes` and `total` are net of
discounts, and `base_price` is on the product's tax basis.

- The `User-Agent` is now a chain of `vendor/package/version` tokens, starting with
`vatly/vatly-api-python/<version> Python/<version> httpx/<version>` instead of
`vatly-api-python/<version>`, matching the other Vatly SDKs.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ uses, so Vatly sees the whole chain:

```python
client.add_version_string("vatly/vatly-fluent-python/0.1.0a4")
# User-Agent: vatly/vatly-api-python/0.1.0a4 Python/3.12.8 httpx/0.28.1 vatly/vatly-fluent-python/0.1.0a4
# User-Agent: vatly/vatly-api-python/0.1.0a5 Python/3.12.8 httpx/0.28.1 vatly/vatly-fluent-python/0.1.0a4
```

Use your PyPI package name and its version constant. Whitespace in a token becomes `-`,
Expand Down
32 changes: 32 additions & 0 deletions docs/Checkouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,45 @@ that convenience belongs to Fluent.
| `redirect_url_canceled` | `redirectUrlCanceled` | Yes |
| `customer_id` | `customerId` | No: an authorized existing customer |
| `locale`, `metadata`, `billing_address` | `locale`, `metadata`, `billingAddress` | No |
| `discounts` | `discounts` | No: at most one [discount](#add-a-discount) |

Pydantic inputs accept Python names. Dictionary inputs use wire keys, including
`trialDays` inside product dictionaries. Omit `customer_id` for a guest checkout.
Omit `trialDays`, or pass `None`, for no trial; `0` is rejected before sending.
`metadata` takes up to 50 string values, with keys up to 40 characters and values
up to 500 characters. The SDK rejects anything else before calling Vatly.

## Add a discount

```python
from vatly import VatlyClient
from vatly.models import CheckoutDiscount, CreateCheckoutRequest


def example(client: VatlyClient):
checkout = client.checkouts.create(
CreateCheckoutRequest(
products=[{"id": "one_off_product_example", "quantity": 1}],
redirect_url_success="https://app.example.com/billing/success",
redirect_url_canceled="https://app.example.com/billing/canceled",
discounts=[CheckoutDiscount(percentage="20", description="Black Friday")],
)
)
return checkout.id
```

A `CheckoutDiscount` takes a `percentage` (above 0 and below 100, at most three
decimals) or a fixed `amount` such as `{"value": "10.00", "currency": "EUR"}`, not
both, and an optional `description` of up to 255 characters shown on the checkout
and invoice. Send at most one discount; a second is rejected before sending.

A fixed `amount` follows the products' tax basis: it includes taxes on tax-inclusive
products and excludes them on tax-exclusive ones. The discount applies to each
product's first payment only; renewals are charged in full. On a subscription in
trial it moves to the first paid charge, on tax-inclusive prices too. Validation
errors are keyed `discounts.0.*`, for example `error.errors["discounts.0.amount"]`
on a `VatlyValidationError`.

## Read a checkout or traverse pages

```python
Expand Down
14 changes: 8 additions & 6 deletions docs/Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ Review the generated diff and rerun the checks above. Do not hand-edit generated
models, resources, clients or `docs/API.md`.

Output models preserve extra fields and keep URLs and emails as strings. The
generator handles two observed API differences: metadata `[]` becomes `{}`, and
response product types stay open to catalogue values added before the next sync.
generator handles three observed API differences: metadata `[]` becomes `{}`,
response product types stay open to catalogue values added before the next sync, and
order and order-line `discounts` default to `[]` for webhook payloads stored before
discounts existed.
Request validation follows the pinned schema: dictionaries are validated through the
request model, request metadata limits are checked, and only spec-defined fields are
sent, with `null` only where the specification allows it. Invalid responses raise `VatlyApiError`; avoid
Expand All @@ -70,14 +72,14 @@ logging response bodies that may contain personal data.

| Source | Revision |
| --- | --- |
| Production OpenAPI, retrieved 2026-11-24 | [vatly-docs specification](https://github.com/vatly/vatly-docs/blob/7ec49a749e7b3df53cfce8e498160f03003e0dd9/public/openapi.yaml) |
| Production OpenAPI, retrieved 2026-11-30 | [vatly-docs specification](https://github.com/vatly/vatly-docs/blob/0caf974016352f9aabb1910a01e3002ecd882d68/public/openapi.yaml) |
| Original JS design reference | [SDK revision](https://github.com/vatly/vatly-api-js/commit/8b0b920c29f7e7b30bf71b9e379ec0a8a1a22028) |

The checked-in specification is byte-identical to that source and to the bundle
published by Vatly's production release. Its SHA-256 is:
The checked-in specification is byte-identical to that source, which docs.vatly.com
serves. Its SHA-256 is:

```text
a8aff52f58ff58cda5b1de0f911849ba21109ea07d5df66d55747262eb21f29d
75c539cd33a5d3f5629ae5c806b9e0158ebcd48c1ff5d2a96f95a4ca47ed167c
```

The specification's generated-at date is not its retrieval date.
Expand Down
24 changes: 24 additions & 0 deletions docs/Orders.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def example(client: VatlyClient):
| `id`, `status`, `customer_id` | Order identity and payment state |
| `lines` | OrderLine models with `id`, `product_type`, `product_id`, `quantity`, `related_resources` |
| `refundable_subtotal`, `reversed_subtotal` | Money wrappers; read `.root.value` and `.root.currency` |
| `discounts` | Discount models applied to the order; each line also has its share in `line.discounts` |
| `links.customer_invoice` | Optional customer invoice link |
| `testmode`, `metadata` | Mode and custom data |

Expand All @@ -41,6 +42,29 @@ 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.

## Read discounts

```python
from decimal import Decimal
from vatly import VatlyClient


def example(client: VatlyClient):
order = client.orders.get("order_example")
off = {d.id: Decimal(d.amount.root.value) for d in order.discounts}
per_line = [(line.id, [d.id for d in line.discounts]) for line in order.lines]
return off, per_line
```

`order.discounts` lists each discount once with its total over all lines; each
line's `discounts` holds its share, matched by `id`. Line `subtotal`, `taxes` and
`total` are already net of discounts. A discount's `amount` always excludes taxes,
even on tax-inclusive products. `discount_type` is `"percentage"` or
`"fixed_amount"` today, but more values may be added: treat an unknown value as a
discount of an unknown kind. `id` and `discount_type` are `None` only on discounts
applied before they were recorded. Orders and lines in webhook events stored before
discounts existed parse with empty `discounts`.

## List orders and request an invoice-details link

```python
Expand Down
Loading
Loading