@beep-it/sdk-core 0.2.0 → 0.3.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.
@@ -1,8 +1,8 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { BeepPurchaseAsset, CheckPaymentStatusPayload, CheckPaymentStatusResponse, IssuePaymentPayload, IssuePaymentResponse, PauseStreamingPayload, PauseStreamingResponse, PaymentRequestData, RequestAndPurchaseAssetRequestParams, SignSolanaTransactionData, SignSolanaTransactionParams, StartStreamingPayload, StartStreamingResponse, StopStreamingPayload, StopStreamingResponse } from '../types';
2
+ import { BeepPurchaseAsset, CheckPaymentStatusPayload, CheckPaymentStatusResponse, IssuePaymentPayload, IssuePaymentResponse, PauseStreamingPayload, PauseStreamingResponse, PaymentRequestData, RequestAndPurchaseAssetRequestParams, StartStreamingPayload, StartStreamingResponse, StopStreamingPayload, StopStreamingResponse } from '../types';
3
3
  /**
4
- * Module for handling payment operations including asset purchases and Solana transactions
5
- * Provides methods for creating payment requests and signing blockchain transactions
4
+ * Module for handling payment operations including asset purchases and SUI transactions
5
+ * Provides methods for creating payment requests and processing blockchain transactions
6
6
  */
7
7
  export declare class PaymentsModule {
8
8
  private client;
@@ -13,14 +13,16 @@ export declare class PaymentsModule {
13
13
  *
14
14
  * Notes:
15
15
  * - Do not pass walletId. The server derives the wallet based on your API key's merchant and requested chain.
16
- * - amount must be in smallest units for the token (e.g., 6‑decimals USDC amount as an integer string).
16
+ * - amount is a human-readable decimal string (e.g., "1.0" for 1 USDC, "0.5" for 0.5 SUI).
17
+ * The server converts to the token's base units internally.
18
+ * - Minimum: 0.01 per transaction. Maximum: 100,000 per transaction.
17
19
  * - This endpoint responds immediately with acceptance/rejection. Actual transfer executes asynchronously after funds are reserved.
18
20
  *
19
21
  * Example:
20
22
  * const res = await beep.payments.createPayout({
21
- * amount: '1000000', // 1.0 USDC with 6 decimals
23
+ * amount: '1.50', // 1.50 USDC (human-readable)
22
24
  * destinationWalletAddress: 'DEST_ADDRESS',
23
- * chain: 'SOLANA',
25
+ * chain: 'SUI',
24
26
  * token: 'USDC',
25
27
  * });
26
28
  */
@@ -61,7 +63,7 @@ export declare class PaymentsModule {
61
63
  *
62
64
  * Phase 1 – Request payment (no paymentReference):
63
65
  * - Server responds with HTTP 402 Payment Required and a payload containing:
64
- * referenceKey, paymentUrl (Solana Pay), optional qrCode, amount, expiresAt, status.
66
+ * referenceKey, paymentUrl, optional qrCode, amount, expiresAt, status.
65
67
  * - The SDK normalizes this by returning the payload (even when status code is 402).
66
68
  * - The caller must instruct the user to pay via their wallet using paymentUrl/qrCode.
67
69
  *
@@ -92,33 +94,6 @@ export declare class PaymentsModule {
92
94
  * const isPaid = !check?.referenceKey; // When no referenceKey is returned, payment is complete
93
95
  */
94
96
  requestAndPurchaseAsset(input: RequestAndPurchaseAssetRequestParams): Promise<PaymentRequestData | null>;
95
- /**
96
- * Signs a Solana transaction for direct blockchain payment processing
97
- *
98
- * @param input - Transaction parameters including addresses, amounts, and token details
99
- * @returns Promise that resolves to signed transaction data
100
- * @throws {Error} When transaction signing fails or required fields are missing
101
- *
102
- * @example
103
- * ```typescript
104
- * try {
105
- * const signedTx = await beep.payments.signSolanaTransaction({
106
- * senderAddress: 'sender_wallet_address',
107
- * recipientAddress: 'recipient_wallet_address',
108
- * tokenMintAddress: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
109
- * amount: 1000000, // 1.0 USDT in base units
110
- * decimals: 6
111
- * });
112
- *
113
- * if (signedTx) {
114
- * console.log('Transaction ready for broadcast:', signedTx.signedTransaction);
115
- * }
116
- * } catch (error) {
117
- * console.error('Transaction signing failed:', error);
118
- * }
119
- * ```
120
- */
121
- signSolanaTransaction(input: SignSolanaTransactionParams): Promise<SignSolanaTransactionData | null>;
122
97
  /**
123
98
  * Issues a payment request for streaming charges with specified asset chunks
124
99
  *
@@ -1 +1 @@
1
- {"version":3,"file":"payments.d.ts","sourceRo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QAAC,IAAI,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAA;KAAE,CAAC;IA+DhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACG,uBAAuB,CAC3B,KAAK,EAAE,oCAAoC,GAC1C,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IA2BrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACG,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAQ/E;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAKrF;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACG,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAKrF;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAKlF;;;;;OAKG;IAEG,kBAAkB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC;CAIjG"}
@@ -23,7 +23,7 @@ export declare class ProductsModule {
23
23
  * name: 'Premium License',
24
24
  * description: 'Lifetime access to premium features',
25
25
  * price: '99.99',
26
- * token: SupportedToken.USDT,
26
+ * token: SupportedToken.USDC,
27
27
  * isSubscription: false
28
28
  * });
29
29
  *
@@ -32,7 +32,7 @@ export declare class ProductsModule {
32
32
  * name: 'Monthly Pro Plan',
33
33
  * description: 'Monthly subscription with full access',
34
34
  * price: '19.99',
35
- * token: SupportedToken.USDT,
35
+ * token: SupportedToken.USDC,
36
36
  * isSubscription: true
37
37
  * });
38
38
  * ```
@@ -0,0 +1,197 @@
1
+ /**
2
+ * @fileoverview Common types and utilities used across the BEEP SDK
3
+ */
4
+ /**
5
+ * Represents a monetary amount as a decimal string
6
+ * @example "10.50" represents $10.50
7
+ * @example "0.99" represents $0.99
8
+ */
9
+ export type MoneyAmount = string;
10
+ /**
11
+ * UUID v4 string format
12
+ * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
13
+ * @example "123e4567-e89b-12d3-a456-426614174000"
14
+ */
15
+ export type UUID = string;
16
+ /**
17
+ * ISO 8601 datetime string
18
+ * @format date-time
19
+ * @example "2023-12-25T10:30:00Z"
20
+ */
21
+ export type ISODateTime = string;
22
+ /**
23
+ * Blockchain transaction signature
24
+ * @example "5J3mBbAH58CpQ3Y5RNJpUKPE62jPJzqiPbZ4FwFeMr4xdHkfqGoeKv"
25
+ */
26
+ export type TransactionSignature = string;
27
+ /**
28
+ * Blockchain wallet address
29
+ * @example "0x742d35Cc6634C0532925a3b844Bc9e7595f56789"
30
+ */
31
+ export type WalletAddress = string;
32
+ /**
33
+ * Supported blockchain networks in BEEP
34
+ */
35
+ export declare enum BlockchainNetwork {
36
+ /** SUI blockchain network */
37
+ SUI = "SUI",
38
+ /** Solana blockchain network */
39
+ SOLANA = "SOLANA"
40
+ }
41
+ /**
42
+ * Common API response wrapper
43
+ * @template T The type of data contained in the response
44
+ */
45
+ export interface ApiResponse<T> {
46
+ /** Indicates if the request was successful */
47
+ success: boolean;
48
+ /** Response data when successful */
49
+ data?: T;
50
+ /** Error message when unsuccessful */
51
+ error?: string;
52
+ /** Additional error details */
53
+ details?: Record<string, any>;
54
+ /** Request tracking ID for support */
55
+ requestId?: string;
56
+ }
57
+ /**
58
+ * Pagination parameters for list endpoints
59
+ */
60
+ export interface PaginationParams {
61
+ /** Maximum number of items to return (1-100) */
62
+ limit?: number;
63
+ /** Number of items to skip */
64
+ offset?: number;
65
+ /** Cursor for pagination */
66
+ cursor?: string;
67
+ }
68
+ /**
69
+ * Paginated response wrapper
70
+ * @template T The type of items in the list
71
+ */
72
+ export interface PaginatedResponse<T> extends ApiResponse<T[]> {
73
+ /** Total number of items available */
74
+ total?: number;
75
+ /** Pagination metadata */
76
+ pagination?: {
77
+ /** Current page number */
78
+ page: number;
79
+ /** Items per page */
80
+ limit: number;
81
+ /** Total number of pages */
82
+ totalPages: number;
83
+ /** Cursor for next page */
84
+ nextCursor?: string;
85
+ /** Cursor for previous page */
86
+ prevCursor?: string;
87
+ };
88
+ }
89
+ /**
90
+ * Sort order for list endpoints
91
+ */
92
+ export declare enum SortOrder {
93
+ /** Ascending order (oldest/smallest first) */
94
+ ASC = "asc",
95
+ /** Descending order (newest/largest first) */
96
+ DESC = "desc"
97
+ }
98
+ /**
99
+ * Common sorting parameters
100
+ */
101
+ export interface SortParams {
102
+ /** Field to sort by */
103
+ sortBy?: string;
104
+ /** Sort order */
105
+ sortOrder?: SortOrder;
106
+ }
107
+ /**
108
+ * Date range filter
109
+ */
110
+ export interface DateRangeFilter {
111
+ /** Start date (inclusive) */
112
+ from?: ISODateTime;
113
+ /** End date (inclusive) */
114
+ to?: ISODateTime;
115
+ }
116
+ /**
117
+ * Status indicator for various entities
118
+ */
119
+ export declare enum EntityStatus {
120
+ /** Entity is active and operational */
121
+ ACTIVE = "active",
122
+ /** Entity is temporarily disabled */
123
+ INACTIVE = "inactive",
124
+ /** Entity is pending activation */
125
+ PENDING = "pending",
126
+ /** Entity has been deleted */
127
+ DELETED = "deleted",
128
+ /** Entity is archived */
129
+ ARCHIVED = "archived"
130
+ }
131
+ /**
132
+ * Generic filter parameters for list endpoints
133
+ */
134
+ export interface FilterParams extends PaginationParams, SortParams {
135
+ /** Filter by status */
136
+ status?: EntityStatus | EntityStatus[];
137
+ /** Date range filter */
138
+ dateRange?: DateRangeFilter;
139
+ /** Search query */
140
+ search?: string;
141
+ /** Additional custom filters */
142
+ filters?: Record<string, any>;
143
+ }
144
+ /**
145
+ * Webhook event types
146
+ */
147
+ export declare enum WebhookEventType {
148
+ /** Payment completed successfully */
149
+ PAYMENT_COMPLETED = "payment.completed",
150
+ /** Payment failed */
151
+ PAYMENT_FAILED = "payment.failed",
152
+ /** Invoice paid */
153
+ INVOICE_PAID = "invoice.paid",
154
+ /** Invoice expired */
155
+ INVOICE_EXPIRED = "invoice.expired",
156
+ /** Product created */
157
+ PRODUCT_CREATED = "product.created",
158
+ /** Product updated */
159
+ PRODUCT_UPDATED = "product.updated",
160
+ /** Subscription activated */
161
+ SUBSCRIPTION_ACTIVATED = "subscription.activated",
162
+ /** Subscription cancelled */
163
+ SUBSCRIPTION_CANCELLED = "subscription.cancelled"
164
+ }
165
+ /**
166
+ * Webhook payload structure
167
+ * @template T The type of data in the webhook
168
+ */
169
+ export interface WebhookPayload<T> {
170
+ /** Unique event ID */
171
+ id: UUID;
172
+ /** Event type */
173
+ type: WebhookEventType;
174
+ /** Timestamp of the event */
175
+ timestamp: ISODateTime;
176
+ /** Event data */
177
+ data: T;
178
+ /** HMAC signature for verification */
179
+ signature: string;
180
+ }
181
+ /**
182
+ * Type guard to check if a value is a valid UUID
183
+ */
184
+ export declare function isUUID(value: any): value is UUID;
185
+ /**
186
+ * Type guard to check if a value is a valid money amount
187
+ */
188
+ export declare function isMoneyAmount(value: any): value is MoneyAmount;
189
+ /**
190
+ * Format a number as a money amount string
191
+ */
192
+ export declare function formatMoneyAmount(amount: number, decimals?: number): MoneyAmount;
193
+ /**
194
+ * Parse a money amount string to number
195
+ */
196
+ export declare function parseMoneyAmount(amount: MoneyAmount): number;
197
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC;;;;GAIG;AACH,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAE1B;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,CA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I,CAAC;IACT,iBAAiB;IACjB,IAAI,EAAE,gBAAgB,CAAC;IACvB,6BAA6B;IAC7B,SAAS,EAAE,WAAW,CAAC;IACvB,iBAAiB;IACjB,IAAI,EAAE,CAAC,CAAC;IACR,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,IAAI,CAIhD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,WAAW,CAI9D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,WAAW,CAEnF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAE5D"}
@@ -0,0 +1,311 @@
1
+ /**
2
+ * @fileoverview Enhanced payment types with comprehensive documentation and type safety
3
+ */
4
+ import { UUID, MoneyAmount, ISODateTime, TransactionSignature, WalletAddress } from './common';
5
+ import { InvoiceStatus } from './invoice';
6
+ import { SupportedToken } from './token';
7
+ /**
8
+ * Asset reference for purchasing existing products
9
+ * @example
10
+ * ```typescript
11
+ * const asset: BeepPurchaseAsset = {
12
+ * assetId: '123e4567-e89b-12d3-a456-426614174000',
13
+ * quantity: 2,
14
+ * name: 'Premium Coffee', // Optional override
15
+ * };
16
+ * ```
17
+ */
18
+ export interface BeepPurchaseAsset {
19
+ /** UUID of the existing product to purchase */
20
+ assetId: UUID;
21
+ /** Number of units to purchase (must be positive integer) */
22
+ quantity: number;
23
+ /** Optional name override for display purposes */
24
+ name?: string;
25
+ /** Optional description override for display purposes */
26
+ description?: string;
27
+ }
28
+ /**
29
+ * Parameters for requesting and purchasing assets
30
+ * @description Supports the 402 Payment Required flow for agent-compatible payments
31
+ * @example
32
+ * ```typescript
33
+ * // Initial request (no payment reference)
34
+ * const request: RequestAndPurchaseAssetParams = {
35
+ * assets: [{ assetId: 'product-uuid', quantity: 1 }],
36
+ * generateQrCode: true,
37
+ * paymentLabel: 'My Store',
38
+ * };
39
+ *
40
+ * // Polling request (with payment reference)
41
+ * const pollRequest: RequestAndPurchaseAssetParams = {
42
+ * assets: [{ assetId: 'product-uuid', quantity: 1 }],
43
+ * paymentReference: response.referenceKey,
44
+ * };
45
+ * ```
46
+ */
47
+ export interface RequestAndPurchaseAssetParams {
48
+ /** Array of assets to purchase */
49
+ assets: BeepPurchaseAsset[];
50
+ /**
51
+ * Payment reference from initial 402 response
52
+ * @description Include this when polling for payment completion
53
+ */
54
+ paymentReference?: string;
55
+ /**
56
+ * Generate QR code for mobile wallet payments
57
+ * @default true
58
+ */
59
+ generateQrCode?: boolean;
60
+ /**
61
+ * Label displayed in payment wallets
62
+ * @example "Coffee Shop - Downtown"
63
+ * @maxLength 50
64
+ */
65
+ paymentLabel?: string;
66
+ }
67
+ /**
68
+ * Payment request creation parameters
69
+ * @example
70
+ * ```typescript
71
+ * const payment: RequestPaymentPayload = {
72
+ * amount: 25.50,
73
+ * token: SupportedToken.USDC,
74
+ * description: 'Premium subscription - 1 month',
75
+ * metadata: {
76
+ * userId: 'user-123',
77
+ * plan: 'premium',
78
+ * }
79
+ * };
80
+ * ```
81
+ */
82
+ export interface RequestPaymentPayload {
83
+ /**
84
+ * Amount to charge in decimal format
85
+ * @min 0.01
86
+ * @example 10.50
87
+ */
88
+ amount: number;
89
+ /**
90
+ * Token type for payment
91
+ * @description Use either `token` or `splTokenAddress`, not both
92
+ */
93
+ token?: SupportedToken;
94
+ /**
95
+ * Custom token address
96
+ * @description Alternative to using the token enum
97
+ * @pattern ^[1-9A-HJ-NP-Za-km-z]{32,44}$
98
+ */
99
+ splTokenAddress?: string;
100
+ /**
101
+ * Human-readable payment description
102
+ * @maxLength 200
103
+ */
104
+ description?: string;
105
+ /**
106
+ * Custom metadata for your records
107
+ * @description This data is returned in webhooks and payment queries
108
+ */
109
+ metadata?: Record<string, any>;
110
+ /**
111
+ * Webhook URL for payment notifications
112
+ * @format uri
113
+ * @example "https://api.example.com/webhooks/beep"
114
+ */
115
+ webhookUrl?: string;
116
+ /**
117
+ * Payment expiration time in minutes
118
+ * @default 15
119
+ * @min 5
120
+ * @max 1440
121
+ */
122
+ expirationMinutes?: number;
123
+ }
124
+ /**
125
+ * Payment request data structure (402 response)
126
+ * @description Returned when payment is required (HTTP 402)
127
+ */
128
+ export interface PaymentRequestData {
129
+ /** Unique reference key for this payment request */
130
+ referenceKey: string;
131
+ /**
132
+ * Deep link URL for payment
133
+ * @format uri
134
+ * @example "sui:pay?recipient=..."
135
+ */
136
+ paymentUrl: string;
137
+ /**
138
+ * Base64-encoded QR code image
139
+ * @description Only present if generateQrCode was true
140
+ * @contentEncoding base64
141
+ * @contentMediaType image/png
142
+ */
143
+ qrCode?: string;
144
+ /** Total amount to be paid */
145
+ amount: MoneyAmount;
146
+ /** Token used for payment */
147
+ token: SupportedToken;
148
+ /** Recipient wallet address */
149
+ recipientAddress: WalletAddress;
150
+ /** Payment expiration timestamp */
151
+ expiresAt: ISODateTime;
152
+ /** Current payment status */
153
+ status: 'pending' | 'processing' | 'completed' | 'failed' | 'expired';
154
+ }
155
+ /**
156
+ * Successful payment response
157
+ * @description Returned when payment is completed successfully
158
+ */
159
+ export interface PaymentSuccessResponse {
160
+ /** Payment receipt information */
161
+ receipt: {
162
+ /** Transaction ID on the blockchain */
163
+ transactionId: TransactionSignature;
164
+ /** Amount paid */
165
+ amount: MoneyAmount;
166
+ /** Token used */
167
+ token: SupportedToken;
168
+ /** Payment timestamp */
169
+ timestamp: ISODateTime;
170
+ /** Payer wallet address */
171
+ payerAddress: WalletAddress;
172
+ /** Recipient wallet address */
173
+ recipientAddress: WalletAddress;
174
+ };
175
+ /** Blockchain transaction signature */
176
+ txSignature: TransactionSignature;
177
+ /** Invoice ID if payment was for an invoice */
178
+ invoiceId?: UUID;
179
+ /** Custom metadata passed during payment creation */
180
+ metadata?: Record<string, any>;
181
+ }
182
+ /**
183
+ * Combined response type for request and purchase asset endpoint
184
+ * @description Can be either a payment request (402) or success response (200)
185
+ */
186
+ export type RequestAndPurchaseAssetResponse = PaymentRequestData | PaymentSuccessResponse;
187
+ /**
188
+ * Type guard to check if response is a payment request (402)
189
+ * @example
190
+ * ```typescript
191
+ * const response = await beep.payments.requestAndPurchaseAsset(params);
192
+ * if (isPaymentRequest(response)) {
193
+ * // Show QR code to user
194
+ * displayQR(response.qrCode);
195
+ * } else {
196
+ * // Payment completed
197
+ * console.log('Transaction:', response.txSignature);
198
+ * }
199
+ * ```
200
+ */
201
+ export declare function isPaymentRequest(response: RequestAndPurchaseAssetResponse): response is PaymentRequestData;
202
+ /**
203
+ * Type guard to check if response is a payment success
204
+ */
205
+ export declare function isPaymentSuccess(response: RequestAndPurchaseAssetResponse): response is PaymentSuccessResponse;
206
+ /**
207
+ * Payment status check parameters
208
+ */
209
+ export interface CheckPaymentStatusPayload {
210
+ /** API key for authentication */
211
+ apiKey: string;
212
+ /**
213
+ * Invoice ID to check
214
+ * @description Provide either invoiceId or transactionReference
215
+ */
216
+ invoiceId?: UUID;
217
+ /**
218
+ * Transaction reference to check
219
+ * @description Provide either invoiceId or transactionReference
220
+ */
221
+ transactionReference?: string;
222
+ }
223
+ /**
224
+ * Payment status response
225
+ */
226
+ export interface CheckPaymentStatusResponse {
227
+ /** Current payment status */
228
+ status: InvoiceStatus;
229
+ /** Transaction signature if payment is completed */
230
+ transactionSignature?: TransactionSignature;
231
+ /** Payment completion timestamp */
232
+ completedAt?: ISODateTime;
233
+ /** Error message if payment failed */
234
+ errorMessage?: string;
235
+ /** Additional status details */
236
+ details?: {
237
+ /** Number of confirmations on blockchain */
238
+ confirmations?: number;
239
+ /** Estimated completion time for pending payments */
240
+ estimatedCompletionTime?: ISODateTime;
241
+ };
242
+ }
243
+ /**
244
+ * Streaming payment session parameters
245
+ * @description Used for pay-as-you-go services and metered billing
246
+ * @example
247
+ * ```typescript
248
+ * const session: IssuePaymentPayload = {
249
+ * apiKey: 'your_api_key',
250
+ * assetChunks: [
251
+ * { assetId: 'api-calls-product', quantity: 100 },
252
+ * { assetId: 'storage-gb-product', quantity: 10 }
253
+ * ],
254
+ * payingMerchantId: 'merchant-uuid'
255
+ * };
256
+ * ```
257
+ */
258
+ export interface IssuePaymentPayload {
259
+ /** API key for authentication */
260
+ apiKey: string;
261
+ /**
262
+ * Assets to be consumed during streaming session
263
+ * @description Each chunk represents a billable unit
264
+ */
265
+ assetChunks: BeepPurchaseAsset[];
266
+ /**
267
+ * Merchant ID who will be charged
268
+ * @description Must have sufficient balance or credit
269
+ */
270
+ payingMerchantId: UUID;
271
+ /**
272
+ * Maximum session duration in minutes
273
+ * @default 60
274
+ * @min 1
275
+ * @max 1440
276
+ */
277
+ maxDurationMinutes?: number;
278
+ /**
279
+ * Session metadata for tracking
280
+ */
281
+ metadata?: {
282
+ /** Session purpose or description */
283
+ purpose?: string;
284
+ /** Client application ID */
285
+ clientId?: string;
286
+ /** Additional custom fields */
287
+ [key: string]: any;
288
+ };
289
+ }
290
+ /**
291
+ * Streaming payment session response
292
+ */
293
+ export interface IssuePaymentResponse {
294
+ /** Unique session ID for streaming payment */
295
+ sessionId: UUID;
296
+ /** Invoice ID for the streaming session */
297
+ invoiceId: UUID;
298
+ /** Session expiration timestamp */
299
+ expiresAt: ISODateTime;
300
+ /** Current session status */
301
+ status: 'active' | 'paused' | 'stopped' | 'expired';
302
+ /** Estimated cost based on asset chunks */
303
+ estimatedCost: {
304
+ /** Minimum cost if session ends immediately */
305
+ minimum: MoneyAmount;
306
+ /** Maximum cost if session runs full duration */
307
+ maximum: MoneyAmount;
308
+ };
309
+ }
310
+ export * from './streaming-payments';
311
+ //# sourceMappingURL=enhanced-payment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enhanced-payment.d.ts","sourceRoot":"","sources":["../../src/types/enhanced-payment.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE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