vatly-fluent-python 0.1.0a2__tar.gz → 0.1.0a3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/.gitignore +3 -0
  2. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/CHANGELOG.md +14 -3
  3. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/PKG-INFO +15 -14
  4. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/PORTING.md +5 -2
  5. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/README.md +12 -12
  6. vatly_fluent_python-0.1.0a3/docs/Checkouts.md +69 -0
  7. vatly_fluent_python-0.1.0a3/docs/Configuration.md +74 -0
  8. vatly_fluent_python-0.1.0a3/docs/CoreConcepts.md +51 -0
  9. vatly_fluent_python-0.1.0a3/docs/CustomerPortal.md +38 -0
  10. vatly_fluent_python-0.1.0a3/docs/Customers.md +63 -0
  11. vatly_fluent_python-0.1.0a3/docs/Development.md +84 -0
  12. vatly_fluent_python-0.1.0a3/docs/Orders.md +54 -0
  13. vatly_fluent_python-0.1.0a3/docs/Porting.md +34 -0
  14. vatly_fluent_python-0.1.0a3/docs/README.md +70 -0
  15. vatly_fluent_python-0.1.0a3/docs/Subscriptions.md +99 -0
  16. vatly_fluent_python-0.1.0a3/docs/Testing.md +79 -0
  17. vatly_fluent_python-0.1.0a3/docs/Webhooks.md +51 -0
  18. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/pyproject.toml +20 -7
  19. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/scripts/check_package.py +2 -3
  20. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/src/vatly_fluent/__init__.py +1 -1
  21. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/src/vatly_fluent/client.py +15 -9
  22. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/src/vatly_fluent/linkage.py +21 -7
  23. vatly_fluent_python-0.1.0a3/tests/test_docs.py +172 -0
  24. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/tests/test_fluent.py +130 -10
  25. vatly_fluent_python-0.1.0a2/docs/Checkouts.md +0 -27
  26. vatly_fluent_python-0.1.0a2/docs/Configuration.md +0 -33
  27. vatly_fluent_python-0.1.0a2/docs/CoreConcepts.md +0 -28
  28. vatly_fluent_python-0.1.0a2/docs/CustomerPortal.md +0 -12
  29. vatly_fluent_python-0.1.0a2/docs/Customers.md +0 -21
  30. vatly_fluent_python-0.1.0a2/docs/Orders.md +0 -13
  31. vatly_fluent_python-0.1.0a2/docs/Porting.md +0 -4
  32. vatly_fluent_python-0.1.0a2/docs/README.md +0 -23
  33. vatly_fluent_python-0.1.0a2/docs/Subscriptions.md +0 -52
  34. vatly_fluent_python-0.1.0a2/docs/Testing.md +0 -16
  35. vatly_fluent_python-0.1.0a2/docs/Webhooks.md +0 -39
  36. vatly_fluent_python-0.1.0a2/vendor/README.md +0 -16
  37. vatly_fluent_python-0.1.0a2/vendor/SHA256SUMS +0 -1
  38. vatly_fluent_python-0.1.0a2/vendor/vatly_api_python-0.1.0a2-py3-none-any.whl +0 -0
  39. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/LICENSE +0 -0
  40. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/examples/sqlite_driver.py +0 -0
  41. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/src/vatly_fluent/builders.py +0 -0
  42. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/src/vatly_fluent/contracts.py +0 -0
  43. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/src/vatly_fluent/customers.py +0 -0
  44. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/src/vatly_fluent/handles.py +0 -0
  45. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/src/vatly_fluent/py.typed +0 -0
  46. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/src/vatly_fluent/webhooks.py +0 -0
  47. {vatly_fluent_python-0.1.0a2 → vatly_fluent_python-0.1.0a3}/tests/fixtures/resources.json +0 -0
@@ -7,3 +7,6 @@ dist/
7
7
  *.egg-info/
8
8
  .amp/portals/*
9
9
  .env
10
+ .coverage*
11
+ htmlcov/
12
+ coverage.xml
@@ -1,6 +1,17 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.0a2 — Unreleased
3
+ ## 0.1.0a3 — 2026-11-13
4
+
5
+ - Link initial orders to their subscriptions through
6
+ `lines[].relatedResources.subscriptionId` in `order.paid`/`checkout.paid` reactions
7
+ and `reconcile_checkout`.
8
+ - `reconcile_checkout` reports signup lines with a still-null `subscriptionId` as
9
+ `unresolved_line_ids`; `legacy_plan_ids` now lists only plan lines without
10
+ `relatedResources` (historical orders).
11
+ - Require `vatly-api-python==0.1.0a3` from PyPI; drop the vendored SDK wheel.
12
+ - Refresh installation, European positioning and published-package documentation.
13
+
14
+ ## 0.1.0a2 — 2026-11-12
4
15
 
5
16
  - Use distribution `vatly-fluent-python`; imports remain `vatly_fluent`.
6
17
  - Depend on the renamed SDK distribution `vatly-api-python` (import `vatly`).
@@ -11,7 +22,7 @@
11
22
  - Reject conflicting trial/cycle grace deadlines; the API omits core's trial flag.
12
23
  - Require corrected SDK 0.1.0a2; refresh the unpublished bootstrap wheel.
13
24
 
14
- ## 0.1.0a1 — Unreleased
25
+ ## 0.1.0a1 — Unpublished development snapshot
15
26
 
16
27
  > Alpha — under active development. Every alpha release may include breaking changes. Pin exact versions during alpha.
17
28
 
@@ -20,4 +31,4 @@
20
31
  - Host-owned checkout/entity linkage, PR #2910-compatible subscription references,
21
32
  bounded recovery, historical plan-line reporting, and no customerId ownership fallback.
22
33
  - Typed package, SQLite transaction/outbox example, tests, guides, CI, trusted
23
- publishing workflow and idempotent orb setup. No publication or tags.
34
+ publishing workflow and idempotent orb setup.
@@ -1,24 +1,26 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vatly-fluent-python
3
- Version: 0.1.0a2
3
+ Version: 0.1.0a3
4
4
  Summary: Framework-independent fluent billing integrations built on the Vatly Python SDK
5
5
  Project-URL: Homepage, https://github.com/vatly/vatly-fluent-python
6
6
  Project-URL: Documentation, https://docs.vatly.com
7
7
  Project-URL: Issues, https://github.com/vatly/vatly-fluent-python/issues
8
8
  License-Expression: MIT
9
9
  License-File: LICENSE
10
+ Keywords: ai,billing,merchant-of-record,payments,subscriptions,vat,vatly
10
11
  Classifier: Development Status :: 3 - Alpha
11
12
  Classifier: Programming Language :: Python :: 3
12
13
  Classifier: Typing :: Typed
13
14
  Requires-Python: >=3.10
14
- Requires-Dist: vatly-api-python==0.1.0a2
15
+ Requires-Dist: vatly-api-python==0.1.0a3
15
16
  Description-Content-Type: text/markdown
16
17
 
17
18
  # Vatly Fluent for Python
18
19
 
19
20
  > **Alpha — under active development. Every alpha release may include breaking changes. Pin exact versions during alpha.**
20
21
 
21
- Integrate Vatly billing without tying your application to a framework or database.
22
+ Integrate billing with Vatly, the European Merchant of Record for AI, software and
23
+ digital products, without tying your application to a framework or database.
22
24
  Fluent adds chainable checkout/subscription builders, customer and subscription
23
25
  handles, pluggable persistence, and a signed webhook-to-domain-event pipeline on
24
26
  top of `vatly-api-python`. Your application owns authentication, entitlements, storage,
@@ -26,16 +28,12 @@ transactions and jobs. Python 3.10+, fully typed, **async-first**.
26
28
 
27
29
  ## Install
28
30
 
29
- Once both packages are published:
30
-
31
31
  ```bash
32
32
  pip install vatly-fluent-python==0.1.0a2 vatly-api-python==0.1.0a2
33
33
  ```
34
34
 
35
- Nothing is published yet. For development, run `.agents/setup` or `uv sync --locked`.
36
- The versioned wheel under `vendor/` bootstraps the unpublished SDK for uv only;
37
- normal package metadata depends on the exact SDK version from PyPI. It is not
38
- copied into Fluent's wheel. See [provenance](vendor/README.md).
35
+ For development, run `.agents/setup` or `uv sync --locked`. Both development and
36
+ package metadata use the exact SDK version from PyPI.
39
37
 
40
38
  ## First checkout
41
39
 
@@ -86,11 +84,12 @@ falls back to `customerId`, which is only billing identity and may be shared or
86
84
  Metadata is correlation data, not authorization. A signed webhook authenticates
87
85
  Vatly's snapshot; it does not authorize a browser-provided entity ID.
88
86
 
89
- Initial order lines may carry `productType="subscription"` and the intended
90
- subscription ID (core PR #2910). Historical `subscription_plan` lines remain plan
91
- references. Fluent never guesses a subscription from a plan or quantity.
92
- `reconcile_checkout()` handles bounded 404 recovery and returns unresolved IDs;
93
- an intended ID alone is not evidence of active service.
87
+ Linkage follows each order line's `relatedResources.subscriptionId`, which names
88
+ the signup's subscription on the initial order, and `productType="subscription"`
89
+ renewal lines. `subscription_plan` product IDs remain plan references. A signed
90
+ `order.paid` snapshot can carry a null `subscriptionId`; reconcile the checkout to
91
+ read the current order. See [Subscriptions](docs/Subscriptions.md).
92
+ Fluent never guesses a subscription from a customer, plan or quantity.
94
93
 
95
94
  ## Learn the integration
96
95
 
@@ -103,6 +102,8 @@ an intended ID alone is not evidence of active service.
103
102
 
104
103
  ## Develop
105
104
 
105
+ See the [development guide](docs/Development.md) for setup and contributor checks.
106
+
106
107
  ```bash
107
108
  uv sync --locked
108
109
  uv run ruff check .
@@ -30,8 +30,11 @@ customer-binding fallback. `EntityRef(kind, id)` supports teams/users/organizati
30
30
  billing identities and cannot establish entitlement ownership. Drivers enforce
31
31
  immutable links and scope every lookup by tenant, storefront and API mode.
32
32
 
33
- Pending core [PR #2910](https://github.com/sandervanhooft/vatlify/pull/2910) stamps
34
- initial subscription order lines with intended subscription IDs. Historical
33
+ Core [PR #2910](https://github.com/sandervanhooft/vatlify/pull/2910) adds nullable
34
+ `lines[].relatedResources.subscriptionId` and preserves `productType`/`productId`.
35
+ Linkage reads that field (and `subscription` renewal product IDs) to link a checkout's
36
+ order to its subscriptions. A null `subscriptionId` on a signup line means core has
37
+ not resolved it yet; frozen webhook snapshots keep the original value.
35
38
  `subscription_plan` lines are preserved but never treated as subscription IDs.
36
39
  Quantity does not multiply subscription IDs; two checkout plan lines can produce
37
40
  distinct subscription IDs for the same plan. `reconcile_checkout` explicitly reads
@@ -2,7 +2,8 @@
2
2
 
3
3
  > **Alpha — under active development. Every alpha release may include breaking changes. Pin exact versions during alpha.**
4
4
 
5
- Integrate Vatly billing without tying your application to a framework or database.
5
+ Integrate billing with Vatly, the European Merchant of Record for AI, software and
6
+ digital products, without tying your application to a framework or database.
6
7
  Fluent adds chainable checkout/subscription builders, customer and subscription
7
8
  handles, pluggable persistence, and a signed webhook-to-domain-event pipeline on
8
9
  top of `vatly-api-python`. Your application owns authentication, entitlements, storage,
@@ -10,16 +11,12 @@ transactions and jobs. Python 3.10+, fully typed, **async-first**.
10
11
 
11
12
  ## Install
12
13
 
13
- Once both packages are published:
14
-
15
14
  ```bash
16
15
  pip install vatly-fluent-python==0.1.0a2 vatly-api-python==0.1.0a2
17
16
  ```
18
17
 
19
- Nothing is published yet. For development, run `.agents/setup` or `uv sync --locked`.
20
- The versioned wheel under `vendor/` bootstraps the unpublished SDK for uv only;
21
- normal package metadata depends on the exact SDK version from PyPI. It is not
22
- copied into Fluent's wheel. See [provenance](vendor/README.md).
18
+ For development, run `.agents/setup` or `uv sync --locked`. Both development and
19
+ package metadata use the exact SDK version from PyPI.
23
20
 
24
21
  ## First checkout
25
22
 
@@ -70,11 +67,12 @@ falls back to `customerId`, which is only billing identity and may be shared or
70
67
  Metadata is correlation data, not authorization. A signed webhook authenticates
71
68
  Vatly's snapshot; it does not authorize a browser-provided entity ID.
72
69
 
73
- Initial order lines may carry `productType="subscription"` and the intended
74
- subscription ID (core PR #2910). Historical `subscription_plan` lines remain plan
75
- references. Fluent never guesses a subscription from a plan or quantity.
76
- `reconcile_checkout()` handles bounded 404 recovery and returns unresolved IDs;
77
- an intended ID alone is not evidence of active service.
70
+ Linkage follows each order line's `relatedResources.subscriptionId`, which names
71
+ the signup's subscription on the initial order, and `productType="subscription"`
72
+ renewal lines. `subscription_plan` product IDs remain plan references. A signed
73
+ `order.paid` snapshot can carry a null `subscriptionId`; reconcile the checkout to
74
+ read the current order. See [Subscriptions](docs/Subscriptions.md).
75
+ Fluent never guesses a subscription from a customer, plan or quantity.
78
76
 
79
77
  ## Learn the integration
80
78
 
@@ -87,6 +85,8 @@ an intended ID alone is not evidence of active service.
87
85
 
88
86
  ## Develop
89
87
 
88
+ See the [development guide](docs/Development.md) for setup and contributor checks.
89
+
90
90
  ```bash
91
91
  uv sync --locked
92
92
  uv run ruff check .
@@ -0,0 +1,69 @@
1
+ # Create hosted checkouts
2
+
3
+ Build a cart, then call `create()` to make the API request. The result is a full
4
+ SDK Checkout with Fluent's `get_url()` convenience. Pass the configured
5
+ `vatly` from [Configuration](Configuration.md) to these functions.
6
+
7
+ ## Sell a one-off or mixed cart
8
+
9
+ ```python
10
+ from vatly import RequestOptions
11
+ from vatly_fluent import CustomerProfile, EntityRef, Vatly
12
+
13
+
14
+ async def example(vatly: Vatly):
15
+ checkout = (
16
+ await vatly.checkout_builder(CustomerProfile(vatly_id="customer_example"))
17
+ .with_items(
18
+ [
19
+ {"id": "one_off_product_example", "quantity": 2},
20
+ {"id": "subscription_plan_example", "quantity": 1},
21
+ ]
22
+ )
23
+ .with_metadata({"purchaseId": "42"})
24
+ .for_entity(EntityRef("team", "42"))
25
+ .create(options=RequestOptions(idempotency_key="purchase:42"))
26
+ )
27
+ return checkout.id, checkout.get_url()
28
+ ```
29
+
30
+ The customer and entity must already be authorized. Omit the profile for a guest
31
+ checkout. `.for_entity()` needs the checkout-record driver.
32
+
33
+ ## Start a subscription with a trial
34
+
35
+ ```python
36
+ from vatly import RequestOptions
37
+ from vatly_fluent import Vatly
38
+
39
+
40
+ async def example(vatly: Vatly):
41
+ return (
42
+ await vatly.subscribe()
43
+ .to_plan("subscription_plan_example")
44
+ .with_quantity(3)
45
+ .with_trial_days(14)
46
+ .in_testmode()
47
+ .create(options=RequestOptions(idempotency_key="trial:42"))
48
+ )
49
+ ```
50
+
51
+ `subscribe().create()` creates a **checkout**, not an immediate subscription.
52
+ Use the general builder for mixed carts. Reusing a subscription builder replaces
53
+ its plan item rather than appending another.
54
+
55
+ | Builder method | Purpose |
56
+ | --- | --- |
57
+ | `with_items` | Append detached cart items |
58
+ | `to_plan`, `with_quantity` | Select one plan and a positive integer quantity |
59
+ | `with_trial_days`, `with_trial_ends_at` | Trial length or aware deadline, rounded up to whole days |
60
+ | `with_redirect_url_success`, `with_redirect_url_canceled` | Override default redirects |
61
+ | `with_locale`, `with_metadata`, `with_billing_address` | Add checkout details |
62
+ | `payload` | Inspect a detached wire-format dictionary without a request |
63
+ | `in_testmode`, `in_live_mode` | Assert the existing key's mode |
64
+
65
+ Store the purchase key before the API call and reuse it after ambiguous failures,
66
+ including a local-save failure after remote success. The redirect does not prove
67
+ payment; use [webhooks](Webhooks.md). Read lines through `checkout.order_id`'s Order.
68
+
69
+ [Checkout API reference](https://docs.vatly.com/api-reference/checkouts)
@@ -0,0 +1,74 @@
1
+ # Configure Fluent
2
+
3
+ Keep the SDK client open for your application or worker lifespan. Fluent reuses
4
+ it; the caller remains responsible for closing it. See [installation](README.md).
5
+
6
+ ## Add your storage driver
7
+
8
+ The `driver` below is your implementation of the [storage contracts](CoreConcepts.md).
9
+ Use one scope per tenant, storefront and test/live mode. Django users can use
10
+ `vatly-django` instead of implementing this adapter.
11
+
12
+ ```python
13
+ from vatly import AsyncVatlyClient
14
+ from vatly_fluent import Vatly, Wiring
15
+
16
+
17
+ def example(api: AsyncVatlyClient, driver):
18
+ return Vatly(
19
+ Wiring(
20
+ api=api,
21
+ redirect_url_success="https://app.example.com/billing/success",
22
+ redirect_url_canceled="https://app.example.com/billing/canceled",
23
+ webhook_secret="replace-with-your-endpoint-secret",
24
+ checkouts=driver.checkouts,
25
+ bindings=driver.bindings,
26
+ orders=driver.orders,
27
+ subscriptions=driver.subscriptions,
28
+ refunds=driver.refunds,
29
+ chargebacks=driver.chargebacks,
30
+ webhook_calls=driver,
31
+ events=driver,
32
+ )
33
+ )
34
+ ```
35
+
36
+ Load the endpoint secret from your secret manager rather than a source-code literal.
37
+ The sample value is only a placeholder.
38
+
39
+ | Wiring field | Required for |
40
+ | --- | --- |
41
+ | `api`, both redirect URLs | Hosted checkout creation |
42
+ | `checkouts` | `.for_entity(...)` and resource ownership links |
43
+ | `bindings` | Customer-to-host identity mapping |
44
+ | `orders`, `subscriptions` | Local signed snapshots and lifecycle helpers |
45
+ | `refunds`, `chargebacks` | Optional local reversal records |
46
+ | `webhook_secret`, `webhook_calls`, `events` | Verified, transactional delivery and outbox |
47
+
48
+ Missing wiring fails when its feature is used. API-only checkout creation does not
49
+ require repositories. A customer email in a profile does not create a remote customer.
50
+
51
+ ## Retry the same business operation
52
+
53
+ ```python
54
+ from vatly import RequestOptions
55
+ from vatly_fluent import Vatly
56
+
57
+
58
+ async def example(vatly: Vatly):
59
+ return (
60
+ await vatly.checkout_builder()
61
+ .with_items(
62
+ [
63
+ {"id": "one_off_product_example", "quantity": 1},
64
+ ]
65
+ )
66
+ .create(options=RequestOptions(idempotency_key="purchase:42", timeout=10))
67
+ )
68
+ ```
69
+
70
+ Persist that key before calling. Reuse it after a network or local-save failure;
71
+ do not generate a second purchase key on retry. SDK errors propagate unchanged.
72
+ Live/test keys share a host; `.in_testmode()` checks the key, not switches it.
73
+
74
+ [API reference](https://docs.vatly.com/api-reference)
@@ -0,0 +1,51 @@
1
+ # Store ownership safely
2
+
3
+ Your application decides which user, team or organization owns a purchase. Fluent
4
+ stores that decision as an `EntityRef` on your checkout record. A customer binding
5
+ is billing identity only; it never grants access to another entity's resources.
6
+
7
+ ## Attach an authorized entity
8
+
9
+ ```python
10
+ from vatly import RequestOptions
11
+ from vatly_fluent import EntityRef, Vatly
12
+
13
+
14
+ async def example(vatly: Vatly):
15
+ # The host must authorize team 42 before running this function.
16
+ return (
17
+ await vatly.subscribe()
18
+ .to_plan("subscription_plan_example")
19
+ .for_entity(EntityRef("team", "42"))
20
+ .create(options=RequestOptions(idempotency_key="team-42:purchase-1"))
21
+ )
22
+ ```
23
+
24
+ Save the checkout record durably. Signed checkout/order/subscription snapshots
25
+ then follow those links; never infer ownership from email, customerId or metadata.
26
+
27
+ ## Implement the storage contracts
28
+
29
+ | Contract | Methods or responsibility |
30
+ | --- | --- |
31
+ | `CheckoutRecords` | `record`, `find`, `link`, `find_for_resource`; reject conflicting ownership |
32
+ | `CustomerBindings` | `bind`, `record`, lookups both ways; unique on both identities |
33
+ | `Repository` | `find_by_vatly_id`, `store`, `update` complete wrapper records |
34
+ | `ReversalRepository` | Repository plus `list_for_order`, `list_for_customer` |
35
+ | `WebhookCalls` | `process(event, work)` claims signed ID, runs work and commits atomically |
36
+ | `EventDispatcher` | `dispatch(event)` writes a transactional outbox entry |
37
+
38
+ All methods are async. `Stored[T]` contains `resource` and optional `entity`;
39
+ `LocalSubscription` also contains `ends_at`. Updates omit unchanged fields; None
40
+ explicitly clears a field. A repository may decline a new save by returning None.
41
+
42
+ Scope every unique key and lookup by tenant, storefront and mode. Use database
43
+ constraints and locks, not an in-memory check followed by an insert. Webhook audit,
44
+ deduplication, links, snapshots and outbox must share one transaction.
45
+
46
+ The repository's `examples/sqlite_driver.py` is a runnable reference, not an installed
47
+ production driver. It uses one connection and lock per instance. Use an async-native
48
+ database driver or your framework's thread/transaction adapter for production.
49
+ For Django, use its supplied ORMDriver. See [webhook processing](Webhooks.md).
50
+
51
+ [API reference](https://docs.vatly.com/api-reference)
@@ -0,0 +1,38 @@
1
+ # Open the customer portal
2
+
3
+ Send an authenticated buyer to Vatly's hosted portal to manage subscriptions,
4
+ invoices and billing details. Create a new session for each visit.
5
+
6
+ ```python
7
+ from vatly_fluent import FluentError, Vatly
8
+
9
+
10
+ async def example(vatly: Vatly):
11
+ # The host authorizes user-42 before this lookup.
12
+ customer = await vatly.customers.find_by_host_customer_id("user-42")
13
+ if customer is None:
14
+ raise FluentError("No billing customer is bound to this user")
15
+ session = await vatly.customer(customer.id).portal_session(
16
+ {
17
+ "returnUrl": "https://app.example.com/account/billing",
18
+ }
19
+ )
20
+ return session.url
21
+ ```
22
+
23
+ Pass the configured `vatly` from [Configuration](Configuration.md). The key selects
24
+ the storefront and mode; the portal does not show a storefront picker.
25
+
26
+ | Field | Meaning |
27
+ | --- | --- |
28
+ | Input `returnUrl` | Optional HTTPS return link; `{}` omits it |
29
+ | Response `url` | Short-lived, single-use credential-bearing entry URL |
30
+ | Response `expires_at` | Expiry of that entry link |
31
+
32
+ Redirect the browser to `session.url`. Do not log, cache, email as a permanent link,
33
+ or expose a portal session for an unverified customer ID. SDK errors propagate.
34
+
35
+ For one subscription's invoice-address change, use its
36
+ `update_billing()` helper in [Subscriptions](Subscriptions.md).
37
+
38
+ [Portal API reference](https://docs.vatly.com/api-reference/customers)
@@ -0,0 +1,63 @@
1
+ # Create and find customers
2
+
3
+ Bind a host user to a Vatly billing identity once, then reuse it. Bindings require
4
+ the configured storage driver; examples accept `vatly` from [Configuration](Configuration.md).
5
+
6
+ ## Create a customer for a host user
7
+
8
+ ```python
9
+ from vatly import RequestOptions
10
+ from vatly_fluent import CustomerProfile, Vatly
11
+
12
+
13
+ async def example(vatly: Vatly):
14
+ return await vatly.customers.create_for(
15
+ "user-42",
16
+ CustomerProfile(email="buyer@example.com", name="Alex"),
17
+ options=RequestOptions(idempotency_key="signup:user-42"),
18
+ )
19
+ ```
20
+
21
+ `create_for` rejects an already-bound host. To reuse an existing customer, authorize
22
+ its ID then call `await vatly.customers.attribute(customer_id, host_id)` instead.
23
+ Conflicting bindings fail rather than silently moving customers between users.
24
+
25
+ | Profile field | Meaning |
26
+ | --- | --- |
27
+ | `vatly_id` | Existing authorized customer, used by checkout builders |
28
+ | `email` | Required when creating a new customer |
29
+ | `name` | Optional communication name |
30
+
31
+ An email-only checkout profile does not create a customer. Explicitly create it
32
+ first if you need a durable binding. Bindings do not assign order ownership.
33
+
34
+ ## Look up and refresh identity
35
+
36
+ ```python
37
+ from vatly_fluent import Vatly
38
+
39
+
40
+ async def example(vatly: Vatly):
41
+ found = await vatly.customers.find_one_by_email("buyer@example.com")
42
+ handle = vatly.customer("customer_example")
43
+ identity = await handle.identity()
44
+ await handle.update({"name": "Alex Morgan"})
45
+ await handle.sync()
46
+ return found, identity, await handle.email()
47
+ ```
48
+
49
+ `model()`, `name()`, `email()` and `identity()` share a cached snapshot. `sync()`
50
+ and `update()` refresh it. Name/email are not invoice address fields; use the
51
+ [portal](CustomerPortal.md) for hosted billing management.
52
+
53
+ | Lookup | Return |
54
+ | --- | --- |
55
+ | `find_by_host_customer_id` | Customer or None |
56
+ | `find_by_vatly_customer_id` | Customer, or the SDK's not-found error |
57
+ | `find_by_email` | Async iterator of matching customers |
58
+ | `find_one_by_email` | First match or None, not a global identity assertion |
59
+
60
+ `claim_customer_from_checkout` is only for an already host-authorized checkout;
61
+ it binds billing identity, not entitlements. Never accept arbitrary buyer-supplied IDs.
62
+
63
+ [Customer API reference](https://docs.vatly.com/api-reference/customers)
@@ -0,0 +1,84 @@
1
+ ---
2
+ title: Development and release
3
+ description: Set up the repository, test billing integrations and build the Fluent package locally.
4
+ ---
5
+
6
+ # Development and release
7
+
8
+ ## Set up the repository
9
+
10
+ Run commands from the repository root. On Linux or in an Amp orb:
11
+
12
+ ```bash
13
+ .agents/setup
14
+ ```
15
+
16
+ Setup installs uv 0.12.9 and Python 3.12, restores locked dependencies and checks
17
+ imports. It needs no API credentials and makes no Vatly calls.
18
+
19
+ ## Run tests
20
+
21
+ ```bash
22
+ uv run pytest --cov
23
+ ```
24
+
25
+ Tests use the real SDK with local HTTP and signed webhook fixtures. The SQLite
26
+ driver tests cover storage, ownership, duplicate delivery, rollback and the outbox.
27
+ No test changes a Vatly account. See [offline examples](Testing.md) for host tests.
28
+
29
+ ## Check formatting and types
30
+
31
+ ```bash
32
+ uv run ruff check .
33
+ uv run ruff format --check .
34
+ uv run mypy
35
+ ```
36
+
37
+ CI runs tests and these checks on Python 3.10–3.14. Type checks also include the
38
+ example storage driver.
39
+
40
+ ## Build and check the package
41
+
42
+ ```bash
43
+ uv build
44
+ uv run twine check dist/*
45
+ uv run python scripts/check_package.py
46
+ ```
47
+
48
+ The last command installs the built wheel in a fresh environment and checks
49
+ imports and `py.typed`. These commands do not publish anything.
50
+
51
+ ## Pinned SDK dependency
52
+
53
+ Fluent pins one exact `vatly-api-python` version from PyPI in `pyproject.toml`;
54
+ `uv.lock` records its hashes. To move to a new SDK version, change the pin, run
55
+ `uv lock`, and run the full checks. Use a new Fluent alpha version when dependency
56
+ behavior changes.
57
+
58
+ ## Documentation sync
59
+
60
+ Keep guides directly under `docs/` and link each page from [the overview](README.md).
61
+ Pushes to `main` affecting `docs/**` notify `vatly/vatly-docs`. The notifier needs
62
+ `VATLY_DOCS_DISPATCH_TOKEN` with Contents: write access to that repository.
63
+ The sync uses an explicit frontmatter description when present, otherwise the
64
+ page's introductory sentence.
65
+
66
+ ## Prepare a release
67
+
68
+ The published package is [vatly-fluent-python](https://pypi.org/project/vatly-fluent-python/);
69
+ the import name is `vatly_fluent`. Publish the matching SDK version first, then
70
+ Fluent, then Django, only after review and approval.
71
+
72
+ | PyPI trusted publisher field | Value |
73
+ | --- | --- |
74
+ | Owner | `vatly` |
75
+ | Repository | `vatly-fluent-python` |
76
+ | Workflow | `release.yml` |
77
+ | Environment | Leave blank |
78
+
79
+ The workflow publishes only from a published GitHub release whose tag matches
80
+ `v` plus the package version. Mark alphas as pre-releases. Pushing `main` does not
81
+ publish. Restrict release access: trusted publishing needs no environment approval
82
+ or PyPI token, and PyPI artifacts are public.
83
+
84
+ [Storage contracts](CoreConcepts.md) · [Porting notes](Porting.md)
@@ -0,0 +1,54 @@
1
+ # Read orders and reversals
2
+
3
+ Use an order handle to read purchased lines, an invoice link and exact reversal
4
+ amounts. Authorize the order in your application first. Examples accept the
5
+ configured `vatly` from [Configuration](Configuration.md).
6
+
7
+ ```python
8
+ from vatly_fluent import Vatly
9
+
10
+
11
+ async def example(vatly: Vatly):
12
+ order = vatly.order("order_example")
13
+ return {
14
+ "invoice_url": await order.invoice_url(),
15
+ "lines": await order.lines(),
16
+ "refundable": await order.refundable_subtotal(),
17
+ "partially_reversed": await order.is_partially_reversed(),
18
+ "refunds": await order.refunds(),
19
+ }
20
+ ```
21
+
22
+ | Method | Return |
23
+ | --- | --- |
24
+ | `model`, `sync` | Cached SDK Order; refresh the handle |
25
+ | `invoice_url` | Customer invoice URL or None |
26
+ | `lines` | OrderLine models |
27
+ | `reversed_subtotal`, `refundable_subtotal` | `Decimal` in currency units |
28
+ | `is_reversed`, `is_fully_reversed`, `is_partially_reversed` | Predicates derived from both totals |
29
+ | `refunds`, `chargebacks` | Local stored records, or an empty list without repositories |
30
+
31
+ `model()` and the derived fields share one lazy read; `sync()` refreshes it. Do not
32
+ convert financial values to floats. Preserve each amount's currency from the SDK
33
+ resource when combining totals.
34
+
35
+ ## Request a full refund
36
+
37
+ ```python
38
+ from vatly import RequestOptions
39
+ from vatly_fluent import Vatly
40
+
41
+
42
+ async def example(vatly: Vatly):
43
+ return await vatly.api.orders.create_full_refund(
44
+ "order_example",
45
+ {},
46
+ options=RequestOptions(idempotency_key="refund:42"),
47
+ )
48
+ ```
49
+
50
+ Fluent exposes the raw SDK as `vatly.api` for operations without a convenience
51
+ handle. A timeout is ambiguous; reuse the same refund key instead of issuing a
52
+ second refund. Signed reversal events update optional local repositories.
53
+
54
+ [Order API reference](https://docs.vatly.com/api-reference/orders) · [Refund reference](https://docs.vatly.com/api-reference/refunds)
@@ -0,0 +1,34 @@
1
+ # Move from JS or PHP
2
+
3
+ Python Fluent keeps the same billing concepts, with snake_case methods and async
4
+ I/O. Compose an existing `AsyncVatlyClient`; no framework container is installed.
5
+
6
+ | Concept | Python |
7
+ | --- | --- |
8
+ | Checkout builder | `vatly.checkout_builder().with_items(...).create()` |
9
+ | Subscription checkout | `vatly.subscribe().to_plan(...).create()` |
10
+ | Billable/entity | Host-authorized `EntityRef(kind, id)` |
11
+ | Customer handle | `vatly.customer(id)`; await cache/network accessors |
12
+ | Subscription handle | `vatly.subscription(LocalSubscription(...))` |
13
+ | Resource fields | Pydantic snake_case attributes; wire-key dictionaries for overrides |
14
+ | Storage | Async Protocol implementations supplied by the host |
15
+
16
+ ## Inspect a checkout before sending it
17
+
18
+ ```python
19
+ from vatly_fluent import Vatly
20
+
21
+
22
+ def example(vatly: Vatly):
23
+ builder = vatly.subscribe().to_plan("subscription_plan_example").with_quantity(2)
24
+ return builder.payload()
25
+ ```
26
+
27
+ `payload()` is a detached dictionary and makes no network request. Use the same
28
+ builder with `await builder.create()` to send it. PHP/JS method names are not
29
+ aliases in Python. Cancellation returns no resource; resume refreshes a handle.
30
+
31
+ See [Core concepts](CoreConcepts.md) before porting a storage driver and
32
+ [Subscriptions](Subscriptions.md) for the initial-linkage/expiry limitations.
33
+ [PORTING.md](../PORTING.md) records upstream source revisions and deliberate API
34
+ differences. [API reference](https://docs.vatly.com/api-reference) defines wire fields.