@beep-it/sdk-core 0.1.1 → 0.1.2-beta.2

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.
@@ -19,6 +19,14 @@ export interface RequestAndPurchaseAssetRequestParams {
19
19
  /** Label to display on the payment request (e.g., merchant name) */
20
20
  paymentLabel?: string;
21
21
  }
22
+ /**
23
+ * 402 Flow semantics:
24
+ * - Phase 1 (no paymentReference): server responds with HTTP 402 Payment Required and a payload
25
+ * containing referenceKey/paymentUrl/qrCode. The SDK returns that payload so callers can show
26
+ * a QR or deep link to the user.
27
+ * - Phase 2 (with paymentReference): call again. When payment is complete, the response will NOT
28
+ * include referenceKey. If referenceKey is still present (or a 402 payload is returned), keep polling.
29
+ */
22
30
  /**
23
31
  * Payload for creating a payment request
24
32
  * This interface represents the data needed to initiate a payment flow
@@ -105,4 +113,207 @@ export interface SignSolanaTransactionData {
105
113
  /** Current status of the associated invoice */
106
114
  status: InvoiceStatus;
107
115
  }
116
+ /**
117
+ * Payload for issuing a payment request that creates a streaming payment session
118
+ *
119
+ * This interface is used for server-to-server payment issuance where one merchant
120
+ * (the paying party) creates a payment request for assets to be charged over time.
121
+ *
122
+ * **Important**: This functionality is only available with `BeepClient` using secret API keys.
123
+ * It is NOT supported with `BeepPublicClient` or publishable keys for security reasons.
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * // Only works with BeepClient (server-side)
128
+ * const beep = new BeepClient({ apiKey: 'secret_key_here' });
129
+ *
130
+ * const paymentRequest = await beep.payments.issuePayment({
131
+ * apiKey: 'secret_api_key',
132
+ * assetChunks: [
133
+ * { assetId: 'video-content-uuid', quantity: 1 },
134
+ * { assetId: 'api-access-uuid', quantity: 10 }
135
+ * ],
136
+ * payingMerchantId: 'merchant_abc123',
137
+ * invoiceId: 'existing_invoice_uuid' // optional
138
+ * });
139
+ * ```
140
+ */
141
+ export interface IssuePaymentPayload {
142
+ /**
143
+ * Secret API key for authentication
144
+ * @remarks Must be a secret key, not a publishable key
145
+ */
146
+ apiKey: string;
147
+ /**
148
+ * Array of asset chunks to be purchased in this payment request
149
+ * @remarks Each asset will be charged according to its configured pricing
150
+ */
151
+ assetChunks: BeepPurchaseAsset[];
152
+ /**
153
+ * ID of the merchant who will be charged for these assets
154
+ * @remarks This is the paying party, not the receiving party
155
+ */
156
+ payingMerchantId: string;
157
+ /**
158
+ * Optional existing invoice ID to associate with this payment
159
+ * @remarks If provided, assets will be added to the existing invoice
160
+ */
161
+ invoiceId?: string;
162
+ }
163
+ /**
164
+ * Response returned after successfully issuing a payment
165
+ *
166
+ * Contains the identifiers needed to track and manage the streaming payment session.
167
+ * The reference key can be used for status polling, and the invoice ID for payment management.
168
+ */
169
+ export interface IssuePaymentResponse {
170
+ /**
171
+ * Unique reference key for tracking this streaming payment session
172
+ * @remarks Use this key to poll payment status and manage the session
173
+ */
174
+ referenceKey: string;
175
+ /**
176
+ * UUID of the invoice created for this streaming payment
177
+ * @remarks Use this ID for starting, pausing, or stopping the streaming session
178
+ */
179
+ invoiceId: string;
180
+ }
181
+ /**
182
+ * Payload for starting a streaming payment session
183
+ *
184
+ * Initiates billing for a previously issued payment request. Once started,
185
+ * the merchant will begin being charged for asset usage according to the
186
+ * streaming payment configuration.
187
+ *
188
+ * **Important**: This functionality is only available with `BeepClient` using secret API keys.
189
+ * It is NOT supported with `BeepPublicClient` or publishable keys.
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * // Start charging for the streaming session
194
+ * const result = await beep.payments.startStreaming({
195
+ * apiKey: 'secret_api_key',
196
+ * invoiceId: 'invoice_uuid_from_issuePayment'
197
+ * });
198
+ * ```
199
+ */
200
+ export interface StartStreamingPayload {
201
+ /**
202
+ * Secret API key for authentication
203
+ * @remarks Must be a secret key, not a publishable key
204
+ */
205
+ apiKey: string;
206
+ /**
207
+ * UUID of the invoice to start streaming charges for
208
+ * @remarks This should be the invoiceId returned from issuePayment()
209
+ */
210
+ invoiceId: string;
211
+ }
212
+ /**
213
+ * Response returned after successfully starting a streaming payment session
214
+ *
215
+ * Confirms that the streaming session has been activated and charging has begun.
216
+ */
217
+ export interface StartStreamingResponse {
218
+ /**
219
+ * The UUID of the streaming invoice that was started
220
+ * @remarks Matches the invoiceId from the request for confirmation
221
+ */
222
+ invoiceId: string;
223
+ }
224
+ /**
225
+ * Payload for pausing an active streaming payment session
226
+ *
227
+ * Temporarily halts billing for a streaming session without terminating it.
228
+ * The session can be resumed later using startStreaming() with the same invoice ID.
229
+ *
230
+ * **Important**: This functionality is only available with `BeepClient` using secret API keys.
231
+ * It is NOT supported with `BeepPublicClient` or publishable keys.
232
+ *
233
+ * @example
234
+ * ```typescript
235
+ * // Temporarily pause billing
236
+ * const result = await beep.payments.pauseStreaming({
237
+ * apiKey: 'secret_api_key',
238
+ * invoiceId: 'active_invoice_uuid'
239
+ * });
240
+ *
241
+ * if (result.success) {
242
+ * console.log('Streaming paused successfully');
243
+ * }
244
+ * ```
245
+ */
246
+ export interface PauseStreamingPayload {
247
+ /**
248
+ * Secret API key for authentication
249
+ * @remarks Must be a secret key, not a publishable key
250
+ */
251
+ apiKey: string;
252
+ /**
253
+ * UUID of the invoice to pause streaming for
254
+ * @remarks Invoice must be in an active streaming state
255
+ */
256
+ invoiceId: string;
257
+ }
258
+ /**
259
+ * Response returned after attempting to pause a streaming payment session
260
+ *
261
+ * Indicates whether the pause operation was successful.
262
+ */
263
+ export interface PauseStreamingResponse {
264
+ /**
265
+ * Whether the streaming session was successfully paused
266
+ * @remarks If false, check that the invoice is in a valid state for pausing
267
+ */
268
+ success: boolean;
269
+ }
270
+ /**
271
+ * Payload for permanently stopping a streaming payment session
272
+ *
273
+ * Terminates a streaming session and finalizes all charges. This action cannot
274
+ * be undone - the session cannot be restarted after stopping.
275
+ *
276
+ * **Important**: This functionality is only available with `BeepClient` using secret API keys.
277
+ * It is NOT supported with `BeepPublicClient` or publishable keys.
278
+ *
279
+ * @example
280
+ * ```typescript
281
+ * // Permanently stop and finalize the streaming session
282
+ * const result = await beep.payments.stopStreaming({
283
+ * apiKey: 'secret_api_key',
284
+ * invoiceId: 'active_invoice_uuid'
285
+ * });
286
+ *
287
+ * console.log('Session stopped, reference keys:', result.referenceKeys);
288
+ * ```
289
+ */
290
+ export interface StopStreamingPayload {
291
+ /**
292
+ * Secret API key for authentication
293
+ * @remarks Must be a secret key, not a publishable key
294
+ */
295
+ apiKey: string;
296
+ /**
297
+ * UUID of the invoice to permanently stop streaming for
298
+ * @remarks This action will finalize all charges and cannot be undone
299
+ */
300
+ invoiceId: string;
301
+ }
302
+ /**
303
+ * Response returned after successfully stopping a streaming payment session
304
+ *
305
+ * Contains the final session details and all associated reference keys for record keeping.
306
+ */
307
+ export interface StopStreamingResponse {
308
+ /**
309
+ * The UUID of the invoice that was stopped
310
+ * @remarks Matches the invoiceId from the request for confirmation
311
+ */
312
+ invoiceId: string;
313
+ /**
314
+ * List of all reference keys associated with the streaming payments in this session
315
+ * @remarks Useful for reconciliation and record keeping of all charges made
316
+ */
317
+ referenceKeys: string[];
318
+ }
108
319
  //# sourceMappingURL=payment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../../src/types/payment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AAEH,MAAM,WAAW,oCAAoC;IACnD,8DAA8D;IAC9D,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,uDAAuD;IACvD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mCAAmC;IACnC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oEA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AM,CAAC;IACrB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB"}
@@ -0,0 +1,34 @@
1
+ import { BeepPurchaseAsset } from './payment';
2
+ import { SupportedToken } from './token';
3
+ import { InvoiceStatus } from './invoice';
4
+ /**
5
+ * On-the-fly item sent from the browser. The server will create a corresponding product record
6
+ * during the payment-session so it is persisted for audit/reuse. Safe to send from clients.
7
+ */
8
+ export interface EphemeralItem {
9
+ name: string;
10
+ price: string;
11
+ quantity?: number;
12
+ token?: SupportedToken;
13
+ description?: string;
14
+ }
15
+ export type PublicAssetInput = BeepPurchaseAsset | EphemeralItem;
16
+ export interface PublicPaymentSessionRequest {
17
+ publishableKey: string;
18
+ assets: PublicAssetInput[];
19
+ paymentLabel?: string;
20
+ generateQrCode?: boolean;
21
+ }
22
+ export interface PublicPaymentSessionResponse {
23
+ referenceKey: string;
24
+ paymentUrl: string;
25
+ qrCode?: string;
26
+ amount: string;
27
+ expiresAt: string | Date;
28
+ status: InvoiceStatus | string;
29
+ }
30
+ export interface PublicPaymentStatusResponse {
31
+ paid: boolean;
32
+ status?: InvoiceStatus | string;
33
+ }
34
+ //# sourceMappingURL=public.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/types/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,GAAG,aAAa,CAAC;AAEjE,MAAM,WAAW,2BAA2B;IAC1C,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,4BAA4B;IAC3C,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,EAAE,aAAa,GAAG,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;CACjC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beep-it/sdk-core",
3
- "version": "0.1.1",
3
+ "version": "0.1.2-beta.2",
4
4
  "description": "Official TypeScript SDK for the BEEP Payment and Invoice Server",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",