Create and find customers
Bind a host user to a Vatly billing identity once, then reuse it. Bindings require
the configured storage driver; examples accept vatly from Configuration.
Create a customer for a host user
from vatly import RequestOptions
from vatly_fluent import CustomerProfile, Vatly
async def example(vatly: Vatly):
return await vatly.customers.create_for(
"user-42",
CustomerProfile(email="buyer@example.com", name="Alex"),
options=RequestOptions(idempotency_key="signup:user-42"),
)
create_for rejects an already-bound host. To reuse an existing customer, authorize
its ID then call await vatly.customers.attribute(customer_id, host_id) instead.
Conflicting bindings fail rather than silently moving customers between users.
| Profile field | Meaning |
|---|---|
vatly_id | Existing authorized customer, used by checkout builders |
email | Required when creating a new customer |
name | Optional communication name |
An email-only checkout profile does not create a customer. Explicitly create it first if you need a durable binding. Bindings do not assign order ownership.
Look up and refresh identity
from vatly_fluent import Vatly
async def example(vatly: Vatly):
found = await vatly.customers.find_one_by_email("buyer@example.com")
handle = vatly.customer("customer_example")
identity = await handle.identity()
await handle.update({"name": "Alex Morgan"})
await handle.sync()
return found, identity, await handle.email()
model(), name(), email() and identity() share a cached snapshot. sync()
and update() refresh it. Name/email are not invoice address fields; use the
portal for hosted billing management.
| Lookup | Return |
|---|---|
find_by_host_customer_id | Customer or None |
find_by_vatly_customer_id | Customer, or the SDK's not-found error |
find_by_email | Async iterator of matching customers |
find_one_by_email | First match or None, not a global identity assertion |
claim_customer_from_checkout is only for an already host-authorized checkout;
it binds billing identity, not entitlements. Never accept arbitrary buyer-supplied IDs.