@alytegen/sdk 0.7.0 → 0.9.0-next.1

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.
@@ -1,6 +1,6 @@
1
1
  import { type ClientOptions } from './http.js';
2
2
  import { MerchantAccessRules, MerchantMemberships } from './access.js';
3
- import type { BuyerSessionMint, CatalogMerchant, Merchant, EventItem, MerchantPspLink, Tier, TierKind, FeeBearer, Scheme, PaymentRow, WebhookEndpoint, MerchantInsights, InventoryCatalog, InventoryLocation, InventoryLocationBinding, InventoryOccurrence, InventoryPool } from './types.js';
3
+ import type { BuyerSessionMint, CatalogMerchant, Merchant, EventItem, MerchantPspLink, Tier, TierKind, FeeBearer, Scheme, PaymentRow, WebhookEndpoint, MerchantInsights, MerchantBuyerWatchList, SeatingProvider, SeatingProviderInput, SeatingProviderTest, InventoryCatalog, InventoryLocation, InventoryLocationBinding, InventoryOccurrence, InventoryPool, PurchaseLimit, PurchaseLimitReadiness, SetPurchaseLimitInput } from './types.js';
4
4
  /**
5
5
  * Merchant integration client — drives the `/v1/integration/*` surface with a
6
6
  * console-minted API token (`merchant:read` / `merchant:write` scopes; `merchant:admin` for
@@ -99,6 +99,31 @@ export declare class AlyteMerchant {
99
99
  deleteEvent(eventId: string): Promise<{
100
100
  ok: boolean;
101
101
  }>;
102
+ /**
103
+ * Set or replace the per-customer ticket limit for an event (`merchant:write`).
104
+ * `maxPerCustomer` (`1..1000`) caps the tickets one customer can hold or buy;
105
+ * `maxHeldPerCustomer` optionally caps unpaid tickets held at once;
106
+ * `countWaitingWatches` decides whether queued purchases count while waiting.
107
+ * PUT replaces the whole limit, and the first PUT counts the event's earlier sales.
108
+ */
109
+ setEventPurchaseLimit(eventId: string, input: SetPurchaseLimitInput): Promise<{
110
+ purchaseLimit: PurchaseLimit;
111
+ readiness: PurchaseLimitReadiness;
112
+ }>;
113
+ /**
114
+ * Read an event's per-customer ticket limit (`null` when it has none) and how many
115
+ * of its tickets the limit can count against a customer (`merchant:read`).
116
+ */
117
+ getEventPurchaseLimit(eventId: string): Promise<{
118
+ purchaseLimit: PurchaseLimit | null;
119
+ readiness: PurchaseLimitReadiness;
120
+ }>;
121
+ /**
122
+ * Remove an event's per-customer ticket limit (`merchant:write`).
123
+ */
124
+ clearEventPurchaseLimit(eventId: string): Promise<{
125
+ cleared: boolean;
126
+ }>;
102
127
  /** Observed stock and base prices for one shop; not a reserved or quoted offer.
103
128
  * Read scope does not grant writes. A read/write key can also manage this inventory.
104
129
  * Fails with catalog_too_large if any source relation exceeds 2,000 rows. */
@@ -129,13 +154,17 @@ export declare class AlyteMerchant {
129
154
  setSlotLocation(merchantId: string, slotId: string, input: InventoryLocationBinding): Promise<{
130
155
  slot: InventoryOccurrence;
131
156
  }>;
157
+ /** Create a shared pool. With `externalRef` (your stable id, unique per tenant) the create is
158
+ * idempotent: a repeat returns the existing pool untouched with `existing: true`. */
132
159
  createPool(input: {
133
160
  merchantId: string;
134
161
  eventId?: string | null;
135
162
  title: string;
136
163
  capacity: number;
164
+ externalRef?: string;
137
165
  }): Promise<{
138
166
  pool: InventoryPool;
167
+ existing?: boolean;
139
168
  }>;
140
169
  listPools(merchantId: string): Promise<{
141
170
  pools: InventoryPool[];
@@ -185,6 +214,19 @@ export declare class AlyteMerchant {
185
214
  payments: PaymentRow[];
186
215
  }>;
187
216
  getPayment(intentId: string): Promise<unknown>;
217
+ /**
218
+ * ONE buyer's queued purchases at your shops, newest first. `buyerRef` is the `byr_…` id the
219
+ * buyer-session mint returned. Only your account is searched: the same buyer's purchases at
220
+ * another merchant never appear. `status: 'active'` (default) returns queued, paused, firing and
221
+ * awaiting_sca; `'all'` adds the history. Read only — cancelling stays with the buyer on Alyte's
222
+ * page. Lets you show a signed-in buyer their waiting agents without minting a buyer session.
223
+ */
224
+ buyerWatches(buyerRef: string, opts?: {
225
+ status?: 'active' | 'all';
226
+ merchantId?: string;
227
+ limit?: number;
228
+ cursor?: string;
229
+ }): Promise<MerchantBuyerWatchList>;
188
230
  /** Agent adoption + per-tier watch demand for a shop (counts only — the
189
231
  * "N in line" number; never buyer identities). */
190
232
  insights(merchantId: string): Promise<MerchantInsights>;
@@ -209,6 +251,25 @@ export declare class AlyteMerchant {
209
251
  ok: boolean;
210
252
  }>;
211
253
  };
254
+ /**
255
+ * The shop's seating system: the URLs Alyte calls to allocate and release seats, plus the optional
256
+ * venue chart, seat offers and partial allocation. Every Alyte call is signed like a webhook; verify it with
257
+ * `verifyWebhookSignature` and the signing secret.
258
+ */
259
+ readonly seatingProvider: {
260
+ /** Connect or change it (admin key). `signingSecret` is returned ONCE, on the first call or with
261
+ * `rotateSecret`. A changed URL or secret, or enabling `partialAllocate`, needs `test()` again. */
262
+ put: (merchantId: string, input: SeatingProviderInput) => Promise<{
263
+ seatingProvider: SeatingProvider;
264
+ signingSecret?: string;
265
+ }>;
266
+ get: (merchantId: string) => Promise<{
267
+ seatingProvider: SeatingProvider;
268
+ }>;
269
+ /** Pings every configured URL. Resolves only when all answer 2xx; otherwise throws
270
+ * `AlyteApiError` 409 `seating_provider_unverified` with the per-URL results in `details`. */
271
+ test: (merchantId: string) => Promise<SeatingProviderTest>;
272
+ };
212
273
  readonly buyerSessions: {
213
274
  /**
214
275
  * Attest YOUR authenticated user → a single-use redeem link (15-min TTL).
@@ -223,6 +284,16 @@ export declare class AlyteMerchant {
223
284
  tierId?: string;
224
285
  /** Ticket count hint (1–10), requires tierId; permission and tier limits still govern. */
225
286
  quantity?: number;
287
+ /** Open Alyte's page on this event's instruction form. Must be an event of this shop. */
288
+ eventId?: string;
289
+ /** Seed a basket for ONE event (1–20 lines, no repeated ticket type); cannot be combined with
290
+ * tierId/quantity. A hint only: the buyer reviews and confirms on Alyte's page. */
291
+ lines?: Array<{
292
+ tierId: string;
293
+ quantity: number;
294
+ minQuantity?: number;
295
+ required?: boolean;
296
+ }>;
226
297
  /** Back-to-shop link, not an automatic redirect. HTTPS (local HTTP allowed);
227
298
  * restricted to registered embed origins when configured. */
228
299
  returnUrl?: string;
package/dist/merchant.js CHANGED
@@ -54,6 +54,29 @@ export class AlyteMerchant {
54
54
  deleteEvent(eventId) {
55
55
  return this.t.request('DELETE', `/v1/integration/events/${encodeURIComponent(eventId)}`);
56
56
  }
57
+ /**
58
+ * Set or replace the per-customer ticket limit for an event (`merchant:write`).
59
+ * `maxPerCustomer` (`1..1000`) caps the tickets one customer can hold or buy;
60
+ * `maxHeldPerCustomer` optionally caps unpaid tickets held at once;
61
+ * `countWaitingWatches` decides whether queued purchases count while waiting.
62
+ * PUT replaces the whole limit, and the first PUT counts the event's earlier sales.
63
+ */
64
+ setEventPurchaseLimit(eventId, input) {
65
+ return this.t.request('PUT', `/v1/integration/events/${encodeURIComponent(eventId)}/purchase-limit`, input);
66
+ }
67
+ /**
68
+ * Read an event's per-customer ticket limit (`null` when it has none) and how many
69
+ * of its tickets the limit can count against a customer (`merchant:read`).
70
+ */
71
+ getEventPurchaseLimit(eventId) {
72
+ return this.t.request('GET', `/v1/integration/events/${encodeURIComponent(eventId)}/purchase-limit`);
73
+ }
74
+ /**
75
+ * Remove an event's per-customer ticket limit (`merchant:write`).
76
+ */
77
+ clearEventPurchaseLimit(eventId) {
78
+ return this.t.request('DELETE', `/v1/integration/events/${encodeURIComponent(eventId)}/purchase-limit`);
79
+ }
57
80
  /** Observed stock and base prices for one shop; not a reserved or quoted offer.
58
81
  * Read scope does not grant writes. A read/write key can also manage this inventory.
59
82
  * Fails with catalog_too_large if any source relation exceeds 2,000 rows. */
@@ -77,6 +100,8 @@ export class AlyteMerchant {
77
100
  setSlotLocation(merchantId, slotId, input) {
78
101
  return this.t.request('PUT', `/v1/integration/merchants/${encodeURIComponent(merchantId)}/slots/${encodeURIComponent(slotId)}/location`, input);
79
102
  }
103
+ /** Create a shared pool. With `externalRef` (your stable id, unique per tenant) the create is
104
+ * idempotent: a repeat returns the existing pool untouched with `existing: true`. */
80
105
  createPool(input) {
81
106
  return this.t.request('POST', '/v1/integration/pools', input);
82
107
  }
@@ -119,6 +144,25 @@ export class AlyteMerchant {
119
144
  getPayment(intentId) {
120
145
  return this.t.request('GET', `/v1/integration/payments/${encodeURIComponent(intentId)}`);
121
146
  }
147
+ /**
148
+ * ONE buyer's queued purchases at your shops, newest first. `buyerRef` is the `byr_…` id the
149
+ * buyer-session mint returned. Only your account is searched: the same buyer's purchases at
150
+ * another merchant never appear. `status: 'active'` (default) returns queued, paused, firing and
151
+ * awaiting_sca; `'all'` adds the history. Read only — cancelling stays with the buyer on Alyte's
152
+ * page. Lets you show a signed-in buyer their waiting agents without minting a buyer session.
153
+ */
154
+ buyerWatches(buyerRef, opts = {}) {
155
+ const q = new URLSearchParams({ buyerRef });
156
+ if (opts.status)
157
+ q.set('status', opts.status);
158
+ if (opts.merchantId)
159
+ q.set('merchantId', opts.merchantId);
160
+ if (opts.limit)
161
+ q.set('limit', String(opts.limit));
162
+ if (opts.cursor)
163
+ q.set('cursor', opts.cursor);
164
+ return this.t.request('GET', `/v1/integration/watches?${q.toString()}`);
165
+ }
122
166
  /** Agent adoption + per-tier watch demand for a shop (counts only — the
123
167
  * "N in line" number; never buyer identities). */
124
168
  insights(merchantId) {
@@ -135,6 +179,20 @@ export class AlyteMerchant {
135
179
  /** Disable an endpoint — delivery (including queued retries) stops immediately. */
136
180
  delete: (id) => this.t.request('DELETE', `/v1/integration/webhooks/${encodeURIComponent(id)}`),
137
181
  };
182
+ /**
183
+ * The shop's seating system: the URLs Alyte calls to allocate and release seats, plus the optional
184
+ * venue chart, seat offers and partial allocation. Every Alyte call is signed like a webhook; verify it with
185
+ * `verifyWebhookSignature` and the signing secret.
186
+ */
187
+ seatingProvider = {
188
+ /** Connect or change it (admin key). `signingSecret` is returned ONCE, on the first call or with
189
+ * `rotateSecret`. A changed URL or secret, or enabling `partialAllocate`, needs `test()` again. */
190
+ put: (merchantId, input) => this.t.request('PUT', `/v1/integration/merchants/${encodeURIComponent(merchantId)}/seating-provider`, input),
191
+ get: (merchantId) => this.t.request('GET', `/v1/integration/merchants/${encodeURIComponent(merchantId)}/seating-provider`),
192
+ /** Pings every configured URL. Resolves only when all answer 2xx; otherwise throws
193
+ * `AlyteApiError` 409 `seating_provider_unverified` with the per-URL results in `details`. */
194
+ test: (merchantId) => this.t.request('POST', `/v1/integration/merchants/${encodeURIComponent(merchantId)}/seating-provider/test`, {}),
195
+ };
138
196
  buyerSessions = {
139
197
  /**
140
198
  * Attest YOUR authenticated user → a single-use redeem link (15-min TTL).
@@ -13,6 +13,8 @@ export interface AlyteEventEnvelope<T = unknown> {
13
13
  }
14
14
  /** A purchase that authorized and captured. Fulfil on `tierId` + `quantity`. */
15
15
  export interface PaymentSettled {
16
+ /** Verified purchase facts when the PSP reports them; not a liability-shift assertion. */
17
+ authentication?: import('./types.js').PurchaseAuthentication;
16
18
  intentId: string;
17
19
  merchantId: string;
18
20
  /** Integer minor units. NEVER a float — see formatMinor for display. */
@@ -45,6 +47,18 @@ export interface WatchFailed {
45
47
  };
46
48
  failedAt: string;
47
49
  }
50
+ /** Relay to the merchant's buyer before the deadline. This event grants no authority and is not fulfilment. */
51
+ export interface WatchActionRequired {
52
+ tenantId: string;
53
+ merchantId: string;
54
+ buyerRef: string;
55
+ watchId: string;
56
+ purchaseId: string;
57
+ deadline: string;
58
+ agentId?: string;
59
+ tierId?: string;
60
+ quantity?: number;
61
+ }
48
62
  /** A signed delivery carrying no payment data. NEVER fulfil on this. */
49
63
  export interface WebhookTest {
50
64
  [key: string]: unknown;
@@ -54,6 +68,8 @@ export interface PurchaseHandlers {
54
68
  onSettled?: (data: PaymentSettled, event: AlyteEventEnvelope<PaymentSettled>) => Promise<void> | void;
55
69
  /** A queued purchase terminally refused. Tell the buyer why. */
56
70
  onWatchFailed?: (data: WatchFailed, event: AlyteEventEnvelope<WatchFailed>) => Promise<void> | void;
71
+ /** The merchant owns buyer outreach. Deduplicate by eventId; do not buy again or fulfil. */
72
+ onWatchActionRequired?: (data: WatchActionRequired, event: AlyteEventEnvelope<WatchActionRequired>) => Promise<void> | void;
57
73
  /** A test delivery — use it to prove your signature check works. */
58
74
  onTest?: (event: AlyteEventEnvelope<WebhookTest>) => Promise<void> | void;
59
75
  /** Any event type this SDK version does not know. Default: ignored. */
@@ -62,6 +62,9 @@ export async function handleWebhook(rawBody, signatureHeader, handlers, options)
62
62
  case 'watch.failed':
63
63
  await handlers.onWatchFailed?.(event.data, event);
64
64
  break;
65
+ case 'watch.action_required':
66
+ await handlers.onWatchActionRequired?.(event.data, event);
67
+ break;
65
68
  case 'webhook.test':
66
69
  await handlers.onTest?.(event);
67
70
  break;
package/dist/types.d.ts CHANGED
@@ -6,6 +6,19 @@ export type Scheme = 'visa' | 'mastercard' | 'amex';
6
6
  export type TierKind = 'general' | 'seated';
7
7
  export type FeeBearer = 'buyer' | 'merchant';
8
8
  export type * from './inventoryTypes.js';
9
+ export type { BasketLineInput, ReserveBasketInput, ReservationStatus, ReservationLine, Reservation, BasketQuoteLine, BasketQuote, ConfirmReservationInput, ConfirmReservationOutcome } from './baskets.js';
10
+ export type TierRole = 'primary' | 'addon';
11
+ /** A server-enforced add-on rule. Qualifying parent tickets must be in the same event and basket. */
12
+ export interface TierLinkRule {
13
+ parentScope: 'any_primary_in_event' | 'specific_tiers';
14
+ parentTierIds?: string[];
15
+ scaling: 'per_basket' | 'per_parent_unit';
16
+ minQty?: number;
17
+ maxQty?: number;
18
+ minPerParent?: number;
19
+ maxPerParent?: number;
20
+ parentGroupSize?: number;
21
+ }
9
22
  export interface Merchant {
10
23
  id: string;
11
24
  name: string;
@@ -29,6 +42,35 @@ export interface EventItem {
29
42
  title: string;
30
43
  /** ISO-8601 start time. */
31
44
  startsAt: string;
45
+ /** Per-customer ticket limit on this event, when set. */
46
+ purchaseLimit?: {
47
+ maxPerCustomer: number;
48
+ maxHeldPerCustomer?: number;
49
+ };
50
+ }
51
+ /** Per-event customer ticket limit record (`GET/PUT /v1/integration/events/:id/purchase-limit`). */
52
+ export interface PurchaseLimit {
53
+ eventId: string;
54
+ merchantId: string;
55
+ maxPerCustomer: number;
56
+ maxHeldPerCustomer?: number;
57
+ /** Whether queued purchases count toward the limit while waiting; null when not chosen, which counts. */
58
+ countWaitingWatches: boolean | null;
59
+ revision: number;
60
+ updatedBy?: string;
61
+ updatedAt: string;
62
+ }
63
+ /** How an event's per-customer ticket limit recognises customers and how many tickets it covers. */
64
+ export interface PurchaseLimitReadiness {
65
+ identifiers: string[];
66
+ ticketsCounted: number;
67
+ ticketsNotCounted: number;
68
+ }
69
+ /** Body for `AlyteMerchant.setEventPurchaseLimit`. Whole numbers only (`1..1000`); PUT replaces the whole limit. */
70
+ export interface SetPurchaseLimitInput {
71
+ maxPerCustomer: number;
72
+ maxHeldPerCustomer?: number;
73
+ countWaitingWatches?: boolean;
32
74
  }
33
75
  export interface Tier {
34
76
  id: string;
@@ -41,6 +83,11 @@ export interface Tier {
41
83
  availableCount?: number;
42
84
  /** When present, availability comes from this shared pool. Restock the pool. */
43
85
  poolId?: string;
86
+ role?: TierRole;
87
+ category?: string;
88
+ categoryLabel?: string;
89
+ countsTowardPartySize?: boolean;
90
+ linkRule?: TierLinkRule;
44
91
  maxQtyPerPurchase?: number;
45
92
  sellable?: boolean;
46
93
  onSaleStart?: string;
@@ -98,7 +145,25 @@ export interface Hold {
98
145
  requestedQuantity?: number;
99
146
  partialReason?: string;
100
147
  }
148
+ /** Verified purchase authentication facts; never an assertion of liability shift. */
149
+ export type PurchaseAuthentication = ({
150
+ provider: 'stripe';
151
+ paymentIntentId: string;
152
+ chargeId?: string;
153
+ } | {
154
+ provider: 'adyen';
155
+ pspReference: string;
156
+ }) & {
157
+ result: string;
158
+ flow?: string;
159
+ version?: string;
160
+ eci?: string;
161
+ transactionId?: string;
162
+ observedAt: string;
163
+ };
101
164
  export interface PaymentResult {
165
+ purchaseId?: string;
166
+ authentication?: PurchaseAuthentication;
102
167
  intentId: string;
103
168
  status: string;
104
169
  psp?: string;
@@ -107,9 +172,20 @@ export interface PaymentResult {
107
172
  [k: string]: unknown;
108
173
  }
109
174
  export type ConfirmOutcome = {
175
+ status: 'payment_pending';
176
+ result: PaymentResult;
177
+ holdStatus: 'reconcile';
178
+ } | {
110
179
  status: 'settled';
111
180
  result: PaymentResult;
112
181
  holdStatus: string;
182
+ } | {
183
+ status: 'sca_required';
184
+ purchaseId: string;
185
+ challenge: {
186
+ expiresAt: string;
187
+ };
188
+ holdStatus: 'reconcile';
113
189
  } | {
114
190
  status: 'sca_required';
115
191
  challenge: {
@@ -175,6 +251,32 @@ export interface WebhookEndpoint {
175
251
  description?: string;
176
252
  createdAt: string;
177
253
  }
254
+ /** One buyer's queued purchase at your shops (`GET /v1/integration/watches`). */
255
+ export interface MerchantBuyerWatch {
256
+ id: string;
257
+ /** `firing` = being bought right now; `awaiting_sca` = waiting for the buyer's bank approval;
258
+ * `paused` = needs the buyer on Alyte's page. Active = queued | paused | firing | awaiting_sca. */
259
+ status: 'queued' | 'paused' | 'firing' | 'awaiting_sca' | 'fired' | 'failed' | 'cancelled' | 'expired';
260
+ merchantId: string;
261
+ /** The Alyte tier id, as in the integration catalogue. */
262
+ tierId: string;
263
+ /** Absent when the tier or event no longer exists. */
264
+ tierTitle?: string;
265
+ eventTitle?: string;
266
+ quantity: number;
267
+ agentId: string;
268
+ createdAt: string;
269
+ expiresAt?: string;
270
+ /** Why a queued purchase is waiting, as the dispatcher last decided. */
271
+ waitingReason?: 'access_window' | 'price_target' | 'stock' | 'whole_party' | 'purchase_limit';
272
+ /** When the buyer's next opening starts (with `access_window`). */
273
+ nextEligibleAt?: string;
274
+ }
275
+ /** A page of one buyer's queued purchases; pass `nextCursor` back as `cursor` for the next page. */
276
+ export interface MerchantBuyerWatchList {
277
+ watches: MerchantBuyerWatch[];
278
+ nextCursor?: string;
279
+ }
178
280
  /** Agent adoption + per-tier watch demand for one shop (counts only). */
179
281
  export interface MerchantInsights {
180
282
  agents: {
@@ -193,5 +295,52 @@ export interface MerchantInsights {
193
295
  failed: number;
194
296
  cancelled: number;
195
297
  expired: number;
298
+ /** Why queued requests wait, as the dispatcher last decided. Absent on older servers. */
299
+ waiting?: {
300
+ stock: number;
301
+ whole_party: number;
302
+ price_target: number;
303
+ access_window: number;
304
+ };
196
305
  }>;
197
306
  }
307
+ /** The shop's seating-system connection. The signing secret is never part of it. */
308
+ export interface SeatingProvider {
309
+ merchantId: string;
310
+ allocateUrl: string;
311
+ releaseUrl: string;
312
+ /** Venue chart: enables seat requests (sections, rows, traits). */
313
+ chartUrl?: string;
314
+ /** Held seat offers the agent chooses from. */
315
+ offersUrl?: string;
316
+ /** Whether a seated basket may come back reduced or with a line dropped. */
317
+ partialAllocate: boolean;
318
+ status: 'pending' | 'verified';
319
+ verifiedAt?: string;
320
+ lastTestError?: string;
321
+ updatedAt: string;
322
+ }
323
+ export interface SeatingProviderInput {
324
+ allocateUrl: string;
325
+ releaseUrl: string;
326
+ /** `null` removes it. */
327
+ chartUrl?: string | null;
328
+ offersUrl?: string | null;
329
+ partialAllocate?: boolean;
330
+ rotateSecret?: boolean;
331
+ }
332
+ export interface SeatingProviderPing {
333
+ ok: boolean;
334
+ status?: number;
335
+ error?: string;
336
+ }
337
+ export interface SeatingProviderTest {
338
+ verified: true;
339
+ seatingProvider: SeatingProvider;
340
+ allocate: SeatingProviderPing;
341
+ release: SeatingProviderPing;
342
+ chart?: SeatingProviderPing;
343
+ offers?: SeatingProviderPing;
344
+ /** Chart problems that do not block verification (e.g. a group no ticket type can fill). */
345
+ chartWarnings?: string[];
346
+ }
@@ -0,0 +1,28 @@
1
+ /** Reserve, quote and release a basket without charging.
2
+ * ALYTE_BASE_URL=… ALYTE_AGENT_TOKEN=… ADULT_TIER_ID=… CHILD_TIER_ID=… npx tsx agent-basket.ts
3
+ * Requires catalog:read + payments:read + payments:write and a covering mandate.
4
+ */
5
+ import { AlyteAgent, type ConfirmReservationOutcome } from '@alytegen/sdk';
6
+
7
+ const agent = new AlyteAgent({ baseUrl: process.env.ALYTE_BASE_URL!, token: process.env.ALYTE_AGENT_TOKEN! });
8
+ const reservation = await agent.reserveBasket({ lines: [
9
+ { tierId: process.env.ADULT_TIER_ID!, quantity: 2 },
10
+ { tierId: process.env.CHILD_TIER_ID!, quantity: 1 },
11
+ ], scheme: 'visa', geo: 'DE' });
12
+ const quote = await agent.quoteReservation(reservation.id);
13
+ console.log({ reservationId: reservation.id, quoteId: quote.id, lines: quote.lines,
14
+ chargeMinor: quote.chargeMinor, currency: quote.currency, expiresAt: reservation.expiresAt });
15
+
16
+ // A real application persists the reservation, quote, instrument and idempotency
17
+ // key before calling confirmReservation. This example stops before any charge.
18
+ await agent.releaseReservation(reservation.id);
19
+
20
+ /** Interpret confirmation or resolveBasketSca results without treating an uncertain
21
+ * payment as a decline. Only an authorized, confirmed basket may be fulfilled. */
22
+ export function purchaseState(outcome: ConfirmReservationOutcome): 'paid' | 'challenge' | 'refused' | 'pending' {
23
+ if (outcome.status === 'sca_required') return 'challenge';
24
+ if (outcome.status === 'sca_failed') return 'refused';
25
+ if (outcome.status === 'payment_pending' || outcome.reservationStatus === 'reconcile') return 'pending';
26
+ if (outcome.result.status === 'authorized' && outcome.reservationStatus === 'confirmed') return 'paid';
27
+ return outcome.result.status === 'declined' ? 'refused' : 'pending';
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alytegen/sdk",
3
- "version": "0.7.0",
3
+ "version": "0.9.0-next.1",
4
4
  "description": "Alyte client SDK \u2014 merchant integration (catalog, PSP links, buyer sessions, payments visibility) and the agent buy path (discover \u2192 quote \u2192 hold \u2192 confirm).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -48,7 +48,8 @@
48
48
  ],
49
49
  "sideEffects": false,
50
50
  "publishConfig": {
51
- "access": "public"
51
+ "access": "public",
52
+ "tag": "next"
52
53
  },
53
54
  "devDependencies": {
54
55
  "@types/node": "^22.10.5",