@moneymq/sdk 0.9.4 → 0.10.0

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.
package/dist/index.d.mts CHANGED
@@ -248,7 +248,7 @@ declare class CatalogAPI {
248
248
  }
249
249
 
250
250
  /**
251
- * MoneyMQ Channel API - Listener, Processor, and Actor patterns
251
+ * MoneyMQ Channel API - Listener, PaymentStream, and PaymentHook patterns
252
252
  *
253
253
  * Provides pub/sub event communication over SSE with optional publish capability.
254
254
  *
@@ -259,16 +259,16 @@ declare class CatalogAPI {
259
259
  * listener.connect();
260
260
  * ```
261
261
  *
262
- * @example Processor (backend - transaction spawner)
262
+ * @example PaymentStream (backend - transaction spawner)
263
263
  * ```typescript
264
- * const processor = moneymq.payment.processor();
265
- * processor.on('transaction', (tx) => {
266
- * const actor = tx.actor();
267
- * actor.on('payment:settled', async (event) => {
268
- * await actor.send('order:completed', { ... });
264
+ * const stream = moneymq.payment.paymentStream();
265
+ * stream.on('transaction', (tx) => {
266
+ * const hook = tx.hook();
267
+ * hook.on('payment:settled', async (event) => {
268
+ * await hook.attach('fulfillment', { orderId: tx.id });
269
269
  * });
270
270
  * });
271
- * processor.connect();
271
+ * stream.connect();
272
272
  * ```
273
273
  */
274
274
  declare class EventSource {
@@ -389,18 +389,22 @@ interface ReaderOptions {
389
389
  maxReconnectAttempts?: number;
390
390
  }
391
391
  /**
392
- * Actor options (subscribe + publish)
392
+ * PaymentHook options (subscribe + publish)
393
393
  */
394
- interface ActorOptions extends ReaderOptions {
394
+ interface PaymentHookOptions extends ReaderOptions {
395
395
  /** Secret for authorization (uses client secret if not provided) */
396
396
  secret?: string;
397
+ /** Actor ID for identifying this hook in attachments (required for attach) */
398
+ actorId?: string;
397
399
  }
398
400
  /**
399
- * Receiver options (transaction listener)
401
+ * PaymentStream options (transaction listener)
400
402
  */
401
- interface ReceiverOptions {
403
+ interface PaymentStreamOptions {
402
404
  /** Secret for authorization (uses client secret if not provided) */
403
405
  secret?: string;
406
+ /** Actor ID for identifying this hook in attachments (required for attach) */
407
+ actorId?: string;
404
408
  /** Auto-reconnect on disconnect */
405
409
  autoReconnect?: boolean;
406
410
  /** Reconnect delay in ms */
@@ -452,15 +456,15 @@ interface ErrorStreamMessage {
452
456
  error: ChannelError;
453
457
  }
454
458
  /**
455
- * Transaction with actor factory method and convenience methods
459
+ * Transaction with hook factory method and convenience methods
456
460
  */
457
- interface TransactionWithActor extends Transaction {
458
- /** Create an actor scoped to this transaction's channel */
459
- actor(options?: Omit<ActorOptions, 'secret'>): EventActor;
461
+ interface TransactionWithHook extends Transaction {
462
+ /** Create a hook scoped to this transaction's channel */
463
+ hook(options?: Omit<PaymentHookOptions, 'secret'>): PaymentHook;
460
464
  /**
461
465
  * Stream events for this transaction
462
466
  *
463
- * Creates an actor internally and yields events from the transaction's channel.
467
+ * Creates a hook internally and yields events from the transaction's channel.
464
468
  */
465
469
  events(options?: {
466
470
  signal?: AbortSignal;
@@ -468,18 +472,21 @@ interface TransactionWithActor extends Transaction {
468
472
  /**
469
473
  * Attach data to this transaction's channel
470
474
  *
471
- * Creates an actor internally if not already created.
475
+ * Creates a hook internally if not already created.
472
476
  * The server will create a signed receipt JWT and emit a transaction:completed event.
477
+ *
478
+ * @param key - Attachment key identifying this fulfillment (e.g., 'fulfillment', 'surfnet')
479
+ * @param data - Data to attach
473
480
  */
474
- attach<T = unknown>(data: T): Promise<ChannelEvent<T>>;
481
+ attach<T = unknown>(key: string, data: T): Promise<ChannelEvent<T>>;
475
482
  }
476
483
  /**
477
- * Transaction message (for receivers)
478
- * Note: The transaction has an actor() method to create a scoped EventActor
484
+ * Transaction message (for payment streams)
485
+ * Note: The transaction has a hook() method to create a scoped PaymentHook
479
486
  */
480
487
  interface TransactionStreamMessage {
481
488
  type: 'transaction';
482
- transaction: TransactionWithActor;
489
+ transaction: TransactionWithHook;
483
490
  }
484
491
  /**
485
492
  * Union of all channel stream message types
@@ -624,49 +631,51 @@ declare class EventReader extends BaseChannel {
624
631
  protected buildUrl(): string;
625
632
  }
626
633
  /**
627
- * Event actor - subscribe + publish channel connection
634
+ * Payment hook - subscribe + publish channel connection
628
635
  *
629
- * Use for backend applications that need to receive events and publish responses.
636
+ * Use for backend applications that need to receive events and attach fulfillment data.
630
637
  *
631
638
  * @example
632
639
  * ```typescript
633
- * const actor = new EventActor('http://localhost:8488', 'order-123', {
640
+ * const hook = new PaymentHook('http://localhost:8488', 'order-123', {
634
641
  * secret: 'your-secret'
635
642
  * });
636
643
  *
637
- * actor.on('payment:settled', async (event) => {
644
+ * hook.on('payment:settled', async (event) => {
638
645
  * // Process the payment
639
646
  * const order = await processOrder(event.data);
640
647
  *
641
- * // Publish completion event to all channel subscribers
642
- * await actor.send('order:completed', {
648
+ * // Attach fulfillment data - server creates signed receipt
649
+ * await hook.attach('fulfillment', {
643
650
  * orderId: order.id,
644
651
  * trackingNumber: order.tracking
645
652
  * });
646
653
  * });
647
654
  *
648
- * actor.connect();
655
+ * hook.connect();
649
656
  * ```
650
657
  */
651
- declare class EventActor extends BaseChannel {
658
+ declare class PaymentHook extends BaseChannel {
652
659
  private secret?;
653
- constructor(endpoint: string, channelId: string, options: ActorOptions);
660
+ private actorId?;
661
+ constructor(endpoint: string, channelId: string, options: PaymentHookOptions);
654
662
  protected buildUrl(): string;
655
663
  /**
656
- * Publish an event to the channel
664
+ * Attach data to the channel
657
665
  *
658
- * All connected readers and actors on this channel will receive the event.
666
+ * The server will create a signed receipt JWT and emit a transaction:completed event.
667
+ * Attachments are stored as: attachments[actorId][key] = data
659
668
  *
660
- * @param type - Event type (e.g., 'order:completed')
661
- * @param data - Event payload
669
+ * @param key - Attachment key identifying this fulfillment (e.g., 'fulfillment', 'surfnet')
670
+ * @param data - Data to attach
662
671
  * @returns The created event
663
672
  */
664
- send<T = unknown>(type: string, data: T): Promise<ChannelEvent<T>>;
673
+ attach<T = unknown>(key: string, data: T): Promise<ChannelEvent<T>>;
665
674
  }
666
675
  /**
667
- * Transaction wrapper for receiver callbacks
676
+ * Transaction wrapper for payment stream callbacks
668
677
  */
669
- declare class TransactionContext implements TransactionWithActor {
678
+ declare class TransactionContext implements TransactionWithHook {
670
679
  id: string;
671
680
  channelId: string;
672
681
  basket: BasketItem$1[];
@@ -674,12 +683,13 @@ declare class TransactionContext implements TransactionWithActor {
674
683
  metadata?: Record<string, unknown>;
675
684
  private endpoint;
676
685
  private secret;
677
- private _actor;
678
- constructor(data: Transaction, endpoint: string, secret: string);
686
+ private actorId?;
687
+ private _hook;
688
+ constructor(data: Transaction, endpoint: string, secret: string, actorId?: string);
679
689
  /**
680
- * Get or create the internal actor (lazy initialization)
690
+ * Get or create the internal hook (lazy initialization)
681
691
  */
682
- private getOrCreateActor;
692
+ private getOrCreateHook;
683
693
  /**
684
694
  * Get the payment amount as string (from payment details)
685
695
  */
@@ -705,22 +715,22 @@ declare class TransactionContext implements TransactionWithActor {
705
715
  */
706
716
  get features(): Record<string, ProductFeature> | unknown | undefined;
707
717
  /**
708
- * Create an actor scoped to this transaction's channel
718
+ * Create a hook scoped to this transaction's channel
709
719
  *
710
- * The actor is automatically connected.
711
- * Note: If you use events() or send() methods, they share the same internal actor.
720
+ * The hook is automatically connected.
721
+ * Note: If you use events() or attach() methods, they share the same internal hook.
712
722
  */
713
- actor(options?: Omit<ActorOptions, 'secret'>): EventActor;
723
+ hook(options?: Omit<PaymentHookOptions, 'secret' | 'actorId'>): PaymentHook;
714
724
  /**
715
725
  * Stream events for this transaction
716
726
  *
717
- * Creates an actor internally and yields events from the transaction's channel.
727
+ * Creates a hook internally and yields events from the transaction's channel.
718
728
  *
719
729
  * @example
720
730
  * ```typescript
721
731
  * for await (const event of tx.events()) {
722
732
  * if (event.type === 'payment:settled') {
723
- * await tx.send('order:completed', { orderId: tx.id });
733
+ * await tx.attach('fulfillment', { orderId: tx.id });
724
734
  * break;
725
735
  * }
726
736
  * }
@@ -732,48 +742,53 @@ declare class TransactionContext implements TransactionWithActor {
732
742
  /**
733
743
  * Attach data to this transaction's channel
734
744
  *
735
- * Creates an actor internally if not already created.
745
+ * Creates a hook internally if not already created.
736
746
  * The server will create a signed receipt JWT and emit a transaction:completed event.
747
+ * Attachments are stored as: attachments[actorId][key] = data
748
+ *
749
+ * @param key - Attachment key identifying this fulfillment (e.g., 'fulfillment', 'surfnet')
750
+ * @param data - Data to attach
737
751
  *
738
752
  * @example
739
753
  * ```typescript
740
- * await tx.attach({ orderId: tx.id, trackingNumber: '...' });
754
+ * await tx.attach('fulfillment', { orderId: tx.id, trackingNumber: '...' });
741
755
  * ```
742
756
  */
743
- attach<T = unknown>(data: T): Promise<ChannelEvent<T>>;
757
+ attach<T = unknown>(key: string, data: T): Promise<ChannelEvent<T>>;
744
758
  }
745
759
  /**
746
760
  * Transaction handler callback
747
761
  */
748
762
  type TransactionHandler = (tx: TransactionContext) => void | Promise<void>;
749
763
  /**
750
- * Event receiver - listens for new transactions and spawns actors
764
+ * Payment stream - listens for new transactions and spawns hooks
751
765
  *
752
766
  * Use for backend applications that need to handle multiple concurrent transactions.
753
767
  *
754
768
  * @example
755
769
  * ```typescript
756
- * const receiver = new EventReceiver('http://localhost:8488', {
770
+ * const stream = new PaymentStream('http://localhost:8488', {
757
771
  * secret: 'your-secret'
758
772
  * });
759
773
  *
760
- * receiver.on('transaction', (tx) => {
774
+ * stream.on('transaction', (tx) => {
761
775
  * console.log('New transaction:', tx.id);
762
776
  *
763
- * const actor = tx.actor();
777
+ * const hook = tx.hook();
764
778
  *
765
- * actor.on('payment:settled', async (event) => {
779
+ * hook.on('payment:settled', async (event) => {
766
780
  * await processPayment(event.data);
767
- * await actor.send('order:completed', { orderId: tx.id });
781
+ * await hook.attach('fulfillment', { orderId: tx.id });
768
782
  * });
769
783
  * });
770
784
  *
771
- * receiver.connect();
785
+ * stream.connect();
772
786
  * ```
773
787
  */
774
- declare class EventReceiver {
788
+ declare class PaymentStream {
775
789
  private endpoint;
776
790
  private secret?;
791
+ private actorId?;
777
792
  private options;
778
793
  private eventSource;
779
794
  private state;
@@ -782,7 +797,7 @@ declare class EventReceiver {
782
797
  private connectionHandlers;
783
798
  private disconnectionHandlers;
784
799
  private errorHandlers;
785
- constructor(endpoint: string, options?: ReceiverOptions);
800
+ constructor(endpoint: string, options?: PaymentStreamOptions);
786
801
  /**
787
802
  * Current connection state
788
803
  */
@@ -820,14 +835,14 @@ declare class EventReceiver {
820
835
  *
821
836
  * @example
822
837
  * ```typescript
823
- * const receiver = moneymq.payment.processor();
838
+ * const stream = moneymq.payment.paymentStream();
824
839
  *
825
- * for await (const message of receiver.stream()) {
840
+ * for await (const message of stream.stream()) {
826
841
  * if (message.type === 'transaction') {
827
842
  * const tx = message.transaction;
828
843
  * console.log('New transaction:', tx.id);
829
844
  *
830
- * const actor = tx.actor();
845
+ * const hook = tx.hook();
831
846
  * // Handle the transaction...
832
847
  * } else if (message.type === 'state') {
833
848
  * console.log('State:', message.state);
@@ -846,15 +861,15 @@ declare class EventReceiver {
846
861
  *
847
862
  * @example
848
863
  * ```typescript
849
- * const processor = moneymq.payment.processor();
864
+ * const stream = moneymq.payment.paymentStream();
850
865
  *
851
- * for await (const tx of processor.transactions()) {
866
+ * for await (const tx of stream.transactions()) {
852
867
  * console.log('New transaction:', tx.id, tx.payment?.amount);
853
868
  *
854
- * const actor = tx.actor();
855
- * for await (const event of actor.events()) {
869
+ * const hook = tx.hook();
870
+ * for await (const event of hook.events()) {
856
871
  * if (event.type === 'payment:settled') {
857
- * await actor.send('order:completed', { orderId: tx.id });
872
+ * await hook.attach('fulfillment', { orderId: tx.id });
858
873
  * break;
859
874
  * }
860
875
  * }
@@ -863,7 +878,7 @@ declare class EventReceiver {
863
878
  */
864
879
  transactions(options?: {
865
880
  signal?: AbortSignal;
866
- }): AsyncGenerator<TransactionWithActor>;
881
+ }): AsyncGenerator<TransactionWithHook>;
867
882
  private setState;
868
883
  private shouldReconnect;
869
884
  private scheduleReconnect;
@@ -874,13 +889,13 @@ declare class EventReceiver {
874
889
  */
875
890
  declare function createEventReader(endpoint: string, channelId: string, options?: ReaderOptions): EventReader;
876
891
  /**
877
- * Create an event actor
892
+ * Create a payment hook
878
893
  */
879
- declare function createEventActor(endpoint: string, channelId: string, options: ActorOptions): EventActor;
894
+ declare function createPaymentHook(endpoint: string, channelId: string, options: PaymentHookOptions): PaymentHook;
880
895
  /**
881
- * Create an event receiver
896
+ * Create a payment stream
882
897
  */
883
- declare function createEventReceiver(endpoint: string, options: ReceiverOptions): EventReceiver;
898
+ declare function createPaymentStream(endpoint: string, options: PaymentStreamOptions): PaymentStream;
884
899
 
885
900
  /** Line item for checkout session creation - references catalog products */
886
901
  interface CheckoutLineItem {
@@ -1203,21 +1218,21 @@ declare class PaymentAPI {
1203
1218
  *
1204
1219
  * @example
1205
1220
  * ```typescript
1206
- * const processor = moneymq.payment.processor();
1221
+ * const stream = moneymq.payment.paymentStream();
1207
1222
  *
1208
- * processor.on('transaction', (tx) => {
1209
- * const actor = tx.actor();
1223
+ * stream.on('transaction', (tx) => {
1224
+ * const hook = tx.hook();
1210
1225
  *
1211
- * actor.on('payment:settled', async (event) => {
1226
+ * hook.on('payment:settled', async (event) => {
1212
1227
  * await processPayment(event.data);
1213
- * await actor.send('order:completed', { orderId: tx.id });
1228
+ * await hook.attach('fulfillment', { orderId: tx.id });
1214
1229
  * });
1215
1230
  * });
1216
1231
  *
1217
- * processor.connect();
1232
+ * stream.connect();
1218
1233
  * ```
1219
1234
  */
1220
- processor(options?: ReceiverOptions): EventReceiver;
1235
+ paymentStream(options?: PaymentStreamOptions): PaymentStream;
1221
1236
  /**
1222
1237
  * Create a payment listener (subscribe only)
1223
1238
  *
@@ -1268,7 +1283,34 @@ declare class PaymentAPI {
1268
1283
  }
1269
1284
 
1270
1285
  /**
1271
- * MoneyMQ server configuration returned from /config endpoint
1286
+ * Payment API configuration returned from /payment/v1/config endpoint
1287
+ */
1288
+ interface PaymentConfig {
1289
+ isSandbox: boolean;
1290
+ x402: {
1291
+ solana: {
1292
+ payout: {
1293
+ recipientAddress?: string;
1294
+ recipientTokenAccount?: string;
1295
+ tokenAddress: string;
1296
+ };
1297
+ facilitator: {
1298
+ address?: string;
1299
+ };
1300
+ };
1301
+ };
1302
+ stack: {
1303
+ name?: string;
1304
+ imageUrl?: string;
1305
+ };
1306
+ studio?: {
1307
+ rpcUrl?: string;
1308
+ wsUrl?: string;
1309
+ };
1310
+ }
1311
+ /**
1312
+ * Legacy server configuration returned from /config endpoint
1313
+ * @deprecated Use PaymentConfig and fetchPaymentConfig instead
1272
1314
  */
1273
1315
  interface ServerConfig {
1274
1316
  account: {
@@ -1304,20 +1346,29 @@ interface ServerConfig {
1304
1346
  };
1305
1347
  }
1306
1348
  /**
1307
- * Fetch server configuration from MoneyMQ API
1349
+ * Fetch payment configuration from MoneyMQ Payment API
1308
1350
  *
1309
1351
  * @param apiUrl - The MoneyMQ API URL
1310
- * @returns Server configuration including RPC URL
1352
+ * @param includeStudio - Include studio config (RPC/WS URLs)
1353
+ * @returns Payment configuration
1311
1354
  *
1312
1355
  * @example
1313
1356
  * ```typescript
1314
- * const config = await fetchConfig('http://localhost:8488');
1315
- * console.log(config.x402.validator.rpcUrl);
1357
+ * const config = await fetchPaymentConfig('http://localhost:8488', true);
1358
+ * console.log(config.studio?.rpcUrl);
1316
1359
  * ```
1317
1360
  */
1361
+ declare function fetchPaymentConfig(apiUrl: string, includeStudio?: boolean): Promise<PaymentConfig>;
1362
+ /**
1363
+ * Fetch server configuration from MoneyMQ API
1364
+ * @deprecated Use fetchPaymentConfig instead
1365
+ *
1366
+ * @param apiUrl - The MoneyMQ API URL
1367
+ * @returns Server configuration including RPC URL
1368
+ */
1318
1369
  declare function fetchConfig(apiUrl: string): Promise<ServerConfig>;
1319
1370
  /**
1320
- * Get the Solana RPC URL from server config
1371
+ * Get the Solana RPC URL from payment config
1321
1372
  *
1322
1373
  * @param apiUrl - The MoneyMQ API URL
1323
1374
  * @param fallback - Fallback RPC URL if fetch fails
@@ -1376,7 +1427,7 @@ interface X402ClientConfig {
1376
1427
  */
1377
1428
  declare class X402API {
1378
1429
  private config;
1379
- private serverConfig;
1430
+ private paymentConfig;
1380
1431
  private sandboxAccounts;
1381
1432
  constructor(config: MoneyMQConfig);
1382
1433
  /**
@@ -1408,60 +1459,13 @@ declare class X402API {
1408
1459
  */
1409
1460
  getConfig(): Promise<X402ClientConfig>;
1410
1461
  /**
1411
- * Get the full server configuration
1462
+ * Get the full payment configuration
1412
1463
  *
1413
- * @returns The complete server configuration including x402 settings
1464
+ * @returns The complete payment configuration including x402 settings
1414
1465
  */
1415
- getServerConfig(): Promise<ServerConfig>;
1466
+ getPaymentConfig(): Promise<PaymentConfig>;
1416
1467
  }
1417
1468
 
1418
- /**
1419
- * Server-Sent Events (SSE) helpers for MoneyMQ real-time events
1420
- *
1421
- * Supports two modes:
1422
- * - **Stateless**: Client tracks cursor, replay from memory on reconnect
1423
- * - **Stateful**: Server tracks cursor in DB, guaranteed delivery on reconnect
1424
- *
1425
- * @example Stateless stream (client-side cursor)
1426
- * ```typescript
1427
- * import { MoneyMQ } from '@moneymq/sdk';
1428
- *
1429
- * const moneymq = new MoneyMQ({ endpoint: 'http://localhost:8488' });
1430
- *
1431
- * // Create a stateless event stream with replay
1432
- * const stream = moneymq.events.stream({ last: 10 });
1433
- *
1434
- * stream.on('payment', (event) => {
1435
- * console.log('Payment event:', event.type, event.data);
1436
- * // Store cursor for reconnection
1437
- * localStorage.setItem('cursor', event.id);
1438
- * });
1439
- *
1440
- * stream.connect();
1441
- * ```
1442
- *
1443
- * @example Stateful stream (server-side cursor persistence)
1444
- * ```typescript
1445
- * import { MoneyMQ } from '@moneymq/sdk';
1446
- *
1447
- * const moneymq = new MoneyMQ({ endpoint: 'http://localhost:8488' });
1448
- *
1449
- * // Create a stateful stream - server tracks your position
1450
- * // Use a unique, deterministic ID for your consumer
1451
- * const stream = moneymq.events.stream({
1452
- * streamId: 'checkout-widget-user-123',
1453
- * });
1454
- *
1455
- * stream.on('payment', (event) => {
1456
- * // Server automatically tracks cursor - no need to store locally
1457
- * console.log('Payment event:', event.type, event.data);
1458
- * });
1459
- *
1460
- * stream.connect();
1461
- *
1462
- * // On reconnect, server replays missed events automatically
1463
- * ```
1464
- */
1465
1469
  /**
1466
1470
  * CloudEvent v1.0 specification envelope
1467
1471
  */
@@ -1558,10 +1562,32 @@ interface PaymentSettlementFailedData {
1558
1562
  /** Payment flow type (x402 or checkout) */
1559
1563
  payment_flow: PaymentFlow;
1560
1564
  }
1565
+ /**
1566
+ * Transaction completed event data
1567
+ * This is emitted when a transaction is fully complete (settled and all attachments received)
1568
+ */
1569
+ interface TransactionCompletedData {
1570
+ /** Transaction ID (payment_hash) */
1571
+ transaction_id: string;
1572
+ /** JWT receipt token containing payment claims */
1573
+ receipt: string;
1574
+ /** Wallet address of the payer */
1575
+ payer: string;
1576
+ /** Payment amount */
1577
+ amount: string;
1578
+ /** Currency code */
1579
+ currency: string;
1580
+ /** Network name */
1581
+ network: string;
1582
+ /** Transaction signature on-chain */
1583
+ transaction_signature: string | null;
1584
+ /** Product ID if applicable */
1585
+ product_id: string | null;
1586
+ }
1561
1587
  /**
1562
1588
  * All MoneyMQ event types
1563
1589
  */
1564
- type MoneyMQEventType = 'mq.money.payment.verification.succeeded' | 'mq.money.payment.verification.failed' | 'mq.money.payment.settlement.succeeded' | 'mq.money.payment.settlement.failed';
1590
+ type MoneyMQEventType = 'mq.money.payment.verification.succeeded' | 'mq.money.payment.verification.failed' | 'mq.money.payment.settlement.succeeded' | 'mq.money.payment.settlement.failed' | 'mq.money.transaction.completed';
1565
1591
  /**
1566
1592
  * Event type to data type mapping
1567
1593
  */
@@ -1570,6 +1596,7 @@ interface MoneyMQEventMap {
1570
1596
  'mq.money.payment.verification.failed': PaymentVerificationFailedData;
1571
1597
  'mq.money.payment.settlement.succeeded': PaymentSettlementSucceededData;
1572
1598
  'mq.money.payment.settlement.failed': PaymentSettlementFailedData;
1599
+ 'mq.money.transaction.completed': TransactionCompletedData;
1573
1600
  }
1574
1601
  /**
1575
1602
  * Payment verification event (succeeded or failed)
@@ -1579,10 +1606,14 @@ type PaymentVerificationEvent = CloudEventEnvelope<PaymentVerificationSucceededD
1579
1606
  * Payment settlement event (succeeded or failed)
1580
1607
  */
1581
1608
  type PaymentSettlementEvent = CloudEventEnvelope<PaymentSettlementSucceededData> | CloudEventEnvelope<PaymentSettlementFailedData>;
1609
+ /**
1610
+ * Transaction completed event
1611
+ */
1612
+ type TransactionCompletedEvent = CloudEventEnvelope<TransactionCompletedData>;
1582
1613
  /**
1583
1614
  * Any payment event
1584
1615
  */
1585
- type PaymentEvent = PaymentVerificationEvent | PaymentSettlementEvent;
1616
+ type PaymentEvent = PaymentVerificationEvent | PaymentSettlementEvent | TransactionCompletedEvent;
1586
1617
  /**
1587
1618
  * Options for creating an event stream connection
1588
1619
  */
@@ -1772,6 +1803,10 @@ declare function isPaymentSettlementSucceeded(event: PaymentEvent): event is Clo
1772
1803
  * Check if an event is a payment settlement failed event
1773
1804
  */
1774
1805
  declare function isPaymentSettlementFailed(event: PaymentEvent): event is CloudEventEnvelope<PaymentSettlementFailedData>;
1806
+ /**
1807
+ * Check if an event is a transaction completed event
1808
+ */
1809
+ declare function isTransactionCompleted(event: PaymentEvent): event is CloudEventEnvelope<TransactionCompletedData>;
1775
1810
  /**
1776
1811
  * Parse a raw SSE data string into a CloudEvent
1777
1812
  *
@@ -1864,7 +1899,7 @@ declare class MoneyMQ {
1864
1899
  /** X402 API for agentic payments */
1865
1900
  readonly x402: X402API;
1866
1901
  /** Events API for real-time SSE streams
1867
- * @deprecated Use `payment.processor()` and `payment.listener()` instead
1902
+ * @deprecated Use `payment.paymentStream()` and `payment.listener()` instead
1868
1903
  */
1869
1904
  readonly events: {
1870
1905
  /**
@@ -1874,21 +1909,21 @@ declare class MoneyMQ {
1874
1909
  */
1875
1910
  reader: (channelId: string, options?: ReaderOptions) => EventReader;
1876
1911
  /**
1877
- * Create an event actor (subscribe + publish)
1912
+ * Create a payment hook (subscribe + publish)
1878
1913
  *
1879
- * @deprecated Use `payment.processor()` with `tx.actor()` instead
1914
+ * @deprecated Use `payment.paymentStream()` with `tx.hook()` instead
1880
1915
  */
1881
- actor: (channelId: string, options?: ActorOptions) => EventActor;
1916
+ hook: (channelId: string, options?: PaymentHookOptions) => PaymentHook;
1882
1917
  /**
1883
- * Create an event receiver (transaction spawner)
1918
+ * Create a payment stream (transaction spawner)
1884
1919
  *
1885
- * @deprecated Use `payment.processor()` instead
1920
+ * @deprecated Use `payment.paymentStream()` instead
1886
1921
  */
1887
- receiver: (options?: ReceiverOptions) => EventReceiver;
1922
+ paymentStream: (options?: PaymentStreamOptions) => PaymentStream;
1888
1923
  /**
1889
1924
  * Create a new event stream connection
1890
1925
  *
1891
- * @deprecated Use `payment.processor()` instead
1926
+ * @deprecated Use `payment.paymentStream()` instead
1892
1927
  */
1893
1928
  stream: (options?: EventStreamOptions) => EventStream;
1894
1929
  };
@@ -2085,4 +2120,4 @@ declare class CheckoutReceipt {
2085
2120
  };
2086
2121
  }
2087
2122
 
2088
- export { type ActorOptions, type Attachments, type BasketItem, ChannelError, type ChannelErrorHandler, type ChannelEvent, type ChannelEventHandler, type ChannelStreamMessage, type CheckoutCreateParams, type CheckoutLineItem, CheckoutReceipt, type CheckoutSession, type CloudEventEnvelope, type ConnectionHandler, type ConnectionState, type Customer, type CustomerCreateParams, type CustomerUpdateParams, type ErrorHandler, type ErrorStreamMessage, EventActor, type EventHandler, EventReader, EventReceiver, EventStream, type EventStreamMessage, type EventStreamOptions, type EventStreamState, type ExperimentConfig, type GetSignerParams, MoneyMQ, type MoneyMQConfig, type MoneyMQEventMap, type MoneyMQEventType, type PayParams, type PayResult, type Payment, type PaymentDetails, type PaymentEvent, type PaymentFlow, type PaymentIntent, type PaymentIntentCreateParams, type PaymentLink, type PaymentLinkCreateParams, type PaymentListParams, PaymentRequiredError, type PaymentRequirements, type PaymentSettlementEvent, type PaymentSettlementFailedData, type PaymentSettlementSucceededData, type PaymentVerificationEvent, type PaymentVerificationFailedData, type PaymentVerificationSucceededData, type Payout, type PayoutCreateParams, type PayoutListParams, type PayoutSettings, type PayoutSettingsUpdateParams, type Price, type PriceCreateParams, type PriceRecurring, type ProcessorData, type Product, type ProductAccessParams, type ProductAccessResponse, type ProductCreateParams, type ProductFeature$1 as ProductFeature, type ProductListParams, type ProductPrice, type ReaderOptions, type ReceiptClaims, type ReceiverOptions, type ReceiverStreamMessage, type ServerConfig, type StateHandler, type StateStreamMessage, type StreamOptions, type Transaction, type TransactionHandler, type TransactionStreamMessage, type TransactionWithActor, type X402ClientConfig, buildEventStreamUrl, computeChannelId, createEventActor, createEventReader, createEventReceiver, createEventStream, fetchConfig, getRpcUrl, isPaymentSettlementFailed, isPaymentSettlementSucceeded, isPaymentVerificationFailed, isPaymentVerificationSucceeded, parseCloudEvent };
2123
+ export { type Attachments, type BasketItem, ChannelError, type ChannelErrorHandler, type ChannelEvent, type ChannelEventHandler, type ChannelStreamMessage, type CheckoutCreateParams, type CheckoutLineItem, CheckoutReceipt, type CheckoutSession, type CloudEventEnvelope, type ConnectionHandler, type ConnectionState, type Customer, type CustomerCreateParams, type CustomerUpdateParams, type ErrorHandler, type ErrorStreamMessage, type EventHandler, EventReader, EventStream, type EventStreamMessage, type EventStreamOptions, type EventStreamState, type ExperimentConfig, type GetSignerParams, MoneyMQ, type MoneyMQConfig, type MoneyMQEventMap, type MoneyMQEventType, type PayParams, type PayResult, type Payment, type PaymentConfig, type PaymentDetails, type PaymentEvent, type PaymentFlow, PaymentHook, type PaymentHookOptions, type PaymentIntent, type PaymentIntentCreateParams, type PaymentLink, type PaymentLinkCreateParams, type PaymentListParams, PaymentRequiredError, type PaymentRequirements, type PaymentSettlementEvent, type PaymentSettlementFailedData, type PaymentSettlementSucceededData, PaymentStream, type PaymentStreamOptions, type PaymentVerificationEvent, type PaymentVerificationFailedData, type PaymentVerificationSucceededData, type Payout, type PayoutCreateParams, type PayoutListParams, type PayoutSettings, type PayoutSettingsUpdateParams, type Price, type PriceCreateParams, type PriceRecurring, type ProcessorData, type Product, type ProductAccessParams, type ProductAccessResponse, type ProductCreateParams, type ProductFeature$1 as ProductFeature, type ProductListParams, type ProductPrice, type ReaderOptions, type ReceiptClaims, type ReceiverStreamMessage, type ServerConfig, type StateHandler, type StateStreamMessage, type StreamOptions, type Transaction, type TransactionCompletedData, type TransactionCompletedEvent, type TransactionHandler, type TransactionStreamMessage, type TransactionWithHook, type X402ClientConfig, buildEventStreamUrl, computeChannelId, createEventReader, createEventStream, createPaymentHook, createPaymentStream, fetchConfig, fetchPaymentConfig, getRpcUrl, isPaymentSettlementFailed, isPaymentSettlementSucceeded, isPaymentVerificationFailed, isPaymentVerificationSucceeded, isTransactionCompleted, parseCloudEvent };