v0.2.0 — policy_slug on start_purchase + list_public_policies
Mirrors the TS SDK 0.2.0 changes (cf c3a57a0 in keysat-client-ts) so
all four language clients have parity on the tiered-purchase surface.
Breaking change on start_purchase: positional `(buyer_email,
redirect_url)` args replaced with a `&StartPurchaseOptions` struct.
Migration is mechanical:
// before
client.start_purchase(slug, None, None).await?;
// after
client.start_purchase(slug, &Default::default()).await?;
// tier-aware
client.start_purchase(slug, &StartPurchaseOptions {
policy_slug: Some("pro"),
buyer_email: Some("buyer@example.com"),
..Default::default()
}).await?;
The struct has fields for buyer_email, buyer_note, redirect_url,
code, and the new policy_slug. New `list_public_policies` method
fetches the buyer-visible tier list (no auth) so an in-app tier
picker can render dynamically.
Lib + tests build clean; the example's anyhow-not-in-deps issue is
pre-existing and unrelated.
This commit is contained in:
@@ -51,7 +51,18 @@ The server enforces revocation live and does trust-on-first-use fingerprint bind
|
||||
## Purchase flow
|
||||
|
||||
```rust
|
||||
let session = client.start_purchase("my-product", None, None).await?;
|
||||
use licensing_client::StartPurchaseOptions;
|
||||
|
||||
// Default tier:
|
||||
let session = client.start_purchase("my-product", &Default::default()).await?;
|
||||
|
||||
// Specific tier (e.g. Pro):
|
||||
let session = client.start_purchase("my-product", &StartPurchaseOptions {
|
||||
policy_slug: Some("pro"),
|
||||
buyer_email: Some("buyer@example.com"),
|
||||
..Default::default()
|
||||
}).await?;
|
||||
|
||||
// open session.checkout_url in the user's browser
|
||||
loop {
|
||||
let poll = client.poll_purchase(&session.invoice_id).await?;
|
||||
|
||||
Reference in New Issue
Block a user