@solvapay/server 1.2.0 → 1.2.1-preview-e89fa52f99b6d0c7bf9834fcf2d1403141051fa0

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.
@@ -76,6 +76,7 @@ function handleRouteError(error, operationName, defaultMessage) {
76
76
  }
77
77
 
78
78
  // src/helpers/auth.ts
79
+ var import_auth = require("@solvapay/auth");
79
80
  function base64UrlDecode(input) {
80
81
  const padded = input.replace(/-/g, "+").replace(/_/g, "/");
81
82
  const padding = padded.length % 4 === 0 ? "" : "=".repeat(4 - padded.length % 4);
@@ -152,7 +153,7 @@ async function getAuthenticatedUserCore(request, options = {}) {
152
153
  try {
153
154
  const includeEmail = options.includeEmail !== false;
154
155
  const includeName = options.includeName !== false;
155
- const headerUserId = request.headers.get("x-user-id");
156
+ const headerUserId = request.headers.get(import_auth.SOLVAPAY_USER_ID_HEADER);
156
157
  if (headerUserId) {
157
158
  let email = null;
158
159
  let name = null;
@@ -231,7 +232,9 @@ function createSolvaPayClient(opts) {
231
232
  if (!res.ok) {
232
233
  const error = await res.text();
233
234
  log(`\u274C API Error: ${res.status} - ${error}`);
234
- throw new import_core2.SolvaPayError(`Check limits failed (${res.status}): ${error}`, { status: res.status });
235
+ throw new import_core2.SolvaPayError(`Check limits failed (${res.status}): ${error}`, {
236
+ status: res.status
237
+ });
235
238
  }
236
239
  const result = await res.json();
237
240
  return result;
@@ -247,8 +250,28 @@ function createSolvaPayClient(opts) {
247
250
  if (!res.ok) {
248
251
  const error = await res.text();
249
252
  log(`\u274C API Error: ${res.status} - ${error}`);
250
- throw new import_core2.SolvaPayError(`Track usage failed (${res.status}): ${error}`, { status: res.status });
253
+ throw new import_core2.SolvaPayError(`Track usage failed (${res.status}): ${error}`, {
254
+ status: res.status
255
+ });
251
256
  }
257
+ return await res.json();
258
+ },
259
+ // POST: /v1/sdk/usages/bulk
260
+ async trackUsageBulk(params) {
261
+ const url = `${base}/v1/sdk/usages/bulk`;
262
+ const res = await fetch(url, {
263
+ method: "POST",
264
+ headers,
265
+ body: JSON.stringify(params)
266
+ });
267
+ if (!res.ok) {
268
+ const error = await res.text();
269
+ log(`\u274C API Error: ${res.status} - ${error}`);
270
+ throw new import_core2.SolvaPayError(`Track usage bulk failed (${res.status}): ${error}`, {
271
+ status: res.status
272
+ });
273
+ }
274
+ return await res.json();
252
275
  },
253
276
  // POST: /v1/sdk/customers
254
277
  async createCustomer(params) {
@@ -261,7 +284,9 @@ function createSolvaPayClient(opts) {
261
284
  if (!res.ok) {
262
285
  const error = await res.text();
263
286
  log(`\u274C API Error: ${res.status} - ${error}`);
264
- throw new import_core2.SolvaPayError(`Create customer failed (${res.status}): ${error}`, { status: res.status });
287
+ throw new import_core2.SolvaPayError(`Create customer failed (${res.status}): ${error}`, {
288
+ status: res.status
289
+ });
265
290
  }
266
291
  const result = await res.json();
267
292
  return {
@@ -279,7 +304,9 @@ function createSolvaPayClient(opts) {
279
304
  if (!res.ok) {
280
305
  const error = await res.text();
281
306
  log(`\u274C API Error: ${res.status} - ${error}`);
282
- throw new import_core2.SolvaPayError(`Update customer failed (${res.status}): ${error}`, { status: res.status });
307
+ throw new import_core2.SolvaPayError(`Update customer failed (${res.status}): ${error}`, {
308
+ status: res.status
309
+ });
283
310
  }
284
311
  const result = await res.json();
285
312
  return {
@@ -309,7 +336,9 @@ function createSolvaPayClient(opts) {
309
336
  if (!res.ok) {
310
337
  const error = await res.text();
311
338
  log(`\u274C API Error: ${res.status} - ${error}`);
312
- throw new import_core2.SolvaPayError(`Get customer failed (${res.status}): ${error}`, { status: res.status });
339
+ throw new import_core2.SolvaPayError(`Get customer failed (${res.status}): ${error}`, {
340
+ status: res.status
341
+ });
313
342
  }
314
343
  const result = await res.json();
315
344
  let customer = result;
@@ -330,6 +359,27 @@ function createSolvaPayClient(opts) {
330
359
  purchases: customer.purchases || []
331
360
  };
332
361
  },
362
+ // POST: /v1/sdk/customers/{reference}/credits
363
+ async assignCredits(params) {
364
+ const { customerRef, idempotencyKey, ...body } = params;
365
+ const url = `${base}/v1/sdk/customers/${encodeURIComponent(customerRef)}/credits`;
366
+ const res = await fetch(url, {
367
+ method: "POST",
368
+ headers: {
369
+ ...headers,
370
+ ...idempotencyKey ? { "Idempotency-Key": idempotencyKey } : {}
371
+ },
372
+ body: JSON.stringify(body)
373
+ });
374
+ if (!res.ok) {
375
+ const error = await res.text();
376
+ log(`\u274C API Error: ${res.status} - ${error}`);
377
+ throw new import_core2.SolvaPayError(`Assign credits failed (${res.status}): ${error}`, {
378
+ status: res.status
379
+ });
380
+ }
381
+ return await res.json();
382
+ },
333
383
  // GET: /v1/sdk/merchant
334
384
  async getMerchant() {
335
385
  const url = `${base}/v1/sdk/merchant`;
@@ -340,7 +390,9 @@ function createSolvaPayClient(opts) {
340
390
  if (!res.ok) {
341
391
  const error = await res.text();
342
392
  log(`\u274C API Error: ${res.status} - ${error}`);
343
- throw new import_core2.SolvaPayError(`Get merchant failed (${res.status}): ${error}`, { status: res.status });
393
+ throw new import_core2.SolvaPayError(`Get merchant failed (${res.status}): ${error}`, {
394
+ status: res.status
395
+ });
344
396
  }
345
397
  return res.json();
346
398
  },
@@ -354,7 +406,9 @@ function createSolvaPayClient(opts) {
354
406
  if (!res.ok) {
355
407
  const error = await res.text();
356
408
  log(`\u274C API Error: ${res.status} - ${error}`);
357
- throw new import_core2.SolvaPayError(`Get platform config failed (${res.status}): ${error}`, { status: res.status });
409
+ throw new import_core2.SolvaPayError(`Get platform config failed (${res.status}): ${error}`, {
410
+ status: res.status
411
+ });
358
412
  }
359
413
  return res.json();
360
414
  },
@@ -368,7 +422,9 @@ function createSolvaPayClient(opts) {
368
422
  if (!res.ok) {
369
423
  const error = await res.text();
370
424
  log(`\u274C API Error: ${res.status} - ${error}`);
371
- throw new import_core2.SolvaPayError(`Get product failed (${res.status}): ${error}`, { status: res.status });
425
+ throw new import_core2.SolvaPayError(`Get product failed (${res.status}): ${error}`, {
426
+ status: res.status
427
+ });
372
428
  }
373
429
  const result = await res.json();
374
430
  const data = result.data || {};
@@ -385,7 +441,9 @@ function createSolvaPayClient(opts) {
385
441
  if (!res.ok) {
386
442
  const error = await res.text();
387
443
  log(`\u274C API Error: ${res.status} - ${error}`);
388
- throw new import_core2.SolvaPayError(`List products failed (${res.status}): ${error}`, { status: res.status });
444
+ throw new import_core2.SolvaPayError(`List products failed (${res.status}): ${error}`, {
445
+ status: res.status
446
+ });
389
447
  }
390
448
  const result = await res.json();
391
449
  const products = Array.isArray(result) ? result : result.products || [];
@@ -405,7 +463,9 @@ function createSolvaPayClient(opts) {
405
463
  if (!res.ok) {
406
464
  const error = await res.text();
407
465
  log(`\u274C API Error: ${res.status} - ${error}`);
408
- throw new import_core2.SolvaPayError(`Create product failed (${res.status}): ${error}`, { status: res.status });
466
+ throw new import_core2.SolvaPayError(`Create product failed (${res.status}): ${error}`, {
467
+ status: res.status
468
+ });
409
469
  }
410
470
  const result = await res.json();
411
471
  return result;
@@ -421,7 +481,9 @@ function createSolvaPayClient(opts) {
421
481
  if (!res.ok) {
422
482
  const error = await res.text();
423
483
  log(`\u274C API Error: ${res.status} - ${error}`);
424
- throw new import_core2.SolvaPayError(`Bootstrap MCP product failed (${res.status}): ${error}`, { status: res.status });
484
+ throw new import_core2.SolvaPayError(`Bootstrap MCP product failed (${res.status}): ${error}`, {
485
+ status: res.status
486
+ });
425
487
  }
426
488
  return await res.json();
427
489
  },
@@ -436,7 +498,9 @@ function createSolvaPayClient(opts) {
436
498
  if (!res.ok) {
437
499
  const error = await res.text();
438
500
  log(`\u274C API Error: ${res.status} - ${error}`);
439
- throw new import_core2.SolvaPayError(`Configure MCP plans failed (${res.status}): ${error}`, { status: res.status });
501
+ throw new import_core2.SolvaPayError(`Configure MCP plans failed (${res.status}): ${error}`, {
502
+ status: res.status
503
+ });
440
504
  }
441
505
  return await res.json();
442
506
  },
@@ -450,7 +514,9 @@ function createSolvaPayClient(opts) {
450
514
  if (!res.ok && res.status !== 404) {
451
515
  const error = await res.text();
452
516
  log(`\u274C API Error: ${res.status} - ${error}`);
453
- throw new import_core2.SolvaPayError(`Delete product failed (${res.status}): ${error}`, { status: res.status });
517
+ throw new import_core2.SolvaPayError(`Delete product failed (${res.status}): ${error}`, {
518
+ status: res.status
519
+ });
454
520
  }
455
521
  },
456
522
  // POST: /v1/sdk/products/{productRef}/clone
@@ -464,7 +530,9 @@ function createSolvaPayClient(opts) {
464
530
  if (!res.ok) {
465
531
  const error = await res.text();
466
532
  log(`\u274C API Error: ${res.status} - ${error}`);
467
- throw new import_core2.SolvaPayError(`Clone product failed (${res.status}): ${error}`, { status: res.status });
533
+ throw new import_core2.SolvaPayError(`Clone product failed (${res.status}): ${error}`, {
534
+ status: res.status
535
+ });
468
536
  }
469
537
  return await res.json();
470
538
  },
@@ -478,7 +546,9 @@ function createSolvaPayClient(opts) {
478
546
  if (!res.ok) {
479
547
  const error = await res.text();
480
548
  log(`\u274C API Error: ${res.status} - ${error}`);
481
- throw new import_core2.SolvaPayError(`List plans failed (${res.status}): ${error}`, { status: res.status });
549
+ throw new import_core2.SolvaPayError(`List plans failed (${res.status}): ${error}`, {
550
+ status: res.status
551
+ });
482
552
  }
483
553
  const result = await res.json();
484
554
  const plans = Array.isArray(result) ? result : result.plans || [];
@@ -505,7 +575,9 @@ function createSolvaPayClient(opts) {
505
575
  if (!res.ok) {
506
576
  const error = await res.text();
507
577
  log(`\u274C API Error: ${res.status} - ${error}`);
508
- throw new import_core2.SolvaPayError(`Create plan failed (${res.status}): ${error}`, { status: res.status });
578
+ throw new import_core2.SolvaPayError(`Create plan failed (${res.status}): ${error}`, {
579
+ status: res.status
580
+ });
509
581
  }
510
582
  const result = await res.json();
511
583
  return result;
@@ -521,7 +593,9 @@ function createSolvaPayClient(opts) {
521
593
  if (!res.ok) {
522
594
  const error = await res.text();
523
595
  log(`\u274C API Error: ${res.status} - ${error}`);
524
- throw new import_core2.SolvaPayError(`Update plan failed (${res.status}): ${error}`, { status: res.status });
596
+ throw new import_core2.SolvaPayError(`Update plan failed (${res.status}): ${error}`, {
597
+ status: res.status
598
+ });
525
599
  }
526
600
  return await res.json();
527
601
  },
@@ -535,7 +609,9 @@ function createSolvaPayClient(opts) {
535
609
  if (!res.ok && res.status !== 404) {
536
610
  const error = await res.text();
537
611
  log(`\u274C API Error: ${res.status} - ${error}`);
538
- throw new import_core2.SolvaPayError(`Delete plan failed (${res.status}): ${error}`, { status: res.status });
612
+ throw new import_core2.SolvaPayError(`Delete plan failed (${res.status}): ${error}`, {
613
+ status: res.status
614
+ });
539
615
  }
540
616
  },
541
617
  // POST: /payment-intents
@@ -551,13 +627,16 @@ function createSolvaPayClient(opts) {
551
627
  body: JSON.stringify({
552
628
  productRef: params.productRef,
553
629
  planRef: params.planRef,
554
- customerRef: params.customerRef
630
+ customerRef: params.customerRef,
631
+ ...params.currency && { currency: params.currency }
555
632
  })
556
633
  });
557
634
  if (!res.ok) {
558
635
  const error = await res.text();
559
636
  log(`\u274C API Error: ${res.status} - ${error}`);
560
- throw new import_core2.SolvaPayError(`Create payment intent failed (${res.status}): ${error}`, { status: res.status });
637
+ throw new import_core2.SolvaPayError(`Create payment intent failed (${res.status}): ${error}`, {
638
+ status: res.status
639
+ });
561
640
  }
562
641
  return await res.json();
563
642
  },
@@ -582,7 +661,9 @@ function createSolvaPayClient(opts) {
582
661
  if (!res.ok) {
583
662
  const error = await res.text();
584
663
  log(`\u274C API Error: ${res.status} - ${error}`);
585
- throw new import_core2.SolvaPayError(`Create topup payment intent failed (${res.status}): ${error}`, { status: res.status });
664
+ throw new import_core2.SolvaPayError(`Create topup payment intent failed (${res.status}): ${error}`, {
665
+ status: res.status
666
+ });
586
667
  }
587
668
  return await res.json();
588
669
  },
@@ -604,7 +685,9 @@ function createSolvaPayClient(opts) {
604
685
  if (!res.ok) {
605
686
  const error = await res.text();
606
687
  log(`\u274C API Error: ${res.status} - ${error}`);
607
- throw new import_core2.SolvaPayError(`Process payment failed (${res.status}): ${error}`, { status: res.status });
688
+ throw new import_core2.SolvaPayError(`Process payment failed (${res.status}): ${error}`, {
689
+ status: res.status
690
+ });
608
691
  }
609
692
  const result = await res.json();
610
693
  return result;
@@ -632,7 +715,9 @@ function createSolvaPayClient(opts) {
632
715
  { status: 400 }
633
716
  );
634
717
  }
635
- throw new import_core2.SolvaPayError(`Cancel purchase failed (${res.status}): ${error}`, { status: res.status });
718
+ throw new import_core2.SolvaPayError(`Cancel purchase failed (${res.status}): ${error}`, {
719
+ status: res.status
720
+ });
636
721
  }
637
722
  const responseText = await res.text();
638
723
  let responseData;
@@ -676,12 +761,11 @@ function createSolvaPayClient(opts) {
676
761
  throw new import_core2.SolvaPayError(`Purchase not found: ${error}`, { status: 404 });
677
762
  }
678
763
  if (res.status === 400) {
679
- throw new import_core2.SolvaPayError(
680
- `Purchase cannot be reactivated: ${error}`,
681
- { status: 400 }
682
- );
764
+ throw new import_core2.SolvaPayError(`Purchase cannot be reactivated: ${error}`, { status: 400 });
683
765
  }
684
- throw new import_core2.SolvaPayError(`Reactivate purchase failed (${res.status}): ${error}`, { status: res.status });
766
+ throw new import_core2.SolvaPayError(`Reactivate purchase failed (${res.status}): ${error}`, {
767
+ status: res.status
768
+ });
685
769
  }
686
770
  const responseText = await res.text();
687
771
  let responseData;
@@ -722,7 +806,9 @@ function createSolvaPayClient(opts) {
722
806
  if (!res.ok) {
723
807
  const error = await res.text();
724
808
  log(`\u274C API Error: ${res.status} - ${error}`);
725
- throw new import_core2.SolvaPayError(`Get user info failed (${res.status}): ${error}`, { status: res.status });
809
+ throw new import_core2.SolvaPayError(`Get user info failed (${res.status}): ${error}`, {
810
+ status: res.status
811
+ });
726
812
  }
727
813
  return await res.json();
728
814
  },
@@ -736,7 +822,9 @@ function createSolvaPayClient(opts) {
736
822
  if (!res.ok) {
737
823
  const error = await res.text();
738
824
  log(`\u274C API Error: ${res.status} - ${error}`);
739
- throw new import_core2.SolvaPayError(`Get customer balance failed (${res.status}): ${error}`, { status: res.status });
825
+ throw new import_core2.SolvaPayError(`Get customer balance failed (${res.status}): ${error}`, {
826
+ status: res.status
827
+ });
740
828
  }
741
829
  return await res.json();
742
830
  },
@@ -751,7 +839,9 @@ function createSolvaPayClient(opts) {
751
839
  if (!res.ok) {
752
840
  const error = await res.text();
753
841
  log(`\u274C API Error: ${res.status} - ${error}`);
754
- throw new import_core2.SolvaPayError(`Create checkout session failed (${res.status}): ${error}`, { status: res.status });
842
+ throw new import_core2.SolvaPayError(`Create checkout session failed (${res.status}): ${error}`, {
843
+ status: res.status
844
+ });
755
845
  }
756
846
  const result = await res.json();
757
847
  return result;
@@ -767,7 +857,9 @@ function createSolvaPayClient(opts) {
767
857
  if (!res.ok) {
768
858
  const error = await res.text();
769
859
  log(`\u274C API Error: ${res.status} - ${error}`);
770
- throw new import_core2.SolvaPayError(`Create customer session failed (${res.status}): ${error}`, { status: res.status });
860
+ throw new import_core2.SolvaPayError(`Create customer session failed (${res.status}): ${error}`, {
861
+ status: res.status
862
+ });
771
863
  }
772
864
  const result = await res.json();
773
865
  return result;
@@ -783,7 +875,9 @@ function createSolvaPayClient(opts) {
783
875
  if (!res.ok) {
784
876
  const error = await res.text();
785
877
  log(`\u274C API Error: ${res.status} - ${error}`);
786
- throw new import_core2.SolvaPayError(`Activate plan failed (${res.status}): ${error}`, { status: res.status });
878
+ throw new import_core2.SolvaPayError(`Activate plan failed (${res.status}): ${error}`, {
879
+ status: res.status
880
+ });
787
881
  }
788
882
  return await res.json();
789
883
  },
@@ -794,7 +888,9 @@ function createSolvaPayClient(opts) {
794
888
  if (!res.ok) {
795
889
  const error = await res.text();
796
890
  log(`\u274C API Error: ${res.status} - ${error}`);
797
- throw new import_core2.SolvaPayError(`Get payment method failed (${res.status}): ${error}`, { status: res.status });
891
+ throw new import_core2.SolvaPayError(`Get payment method failed (${res.status}): ${error}`, {
892
+ status: res.status
893
+ });
798
894
  }
799
895
  return await res.json();
800
896
  }
@@ -2069,6 +2165,12 @@ function createSolvaPay(config) {
2069
2165
  trackUsage(params) {
2070
2166
  return apiClient.trackUsage(params);
2071
2167
  },
2168
+ trackUsageBulk(params) {
2169
+ if (!apiClient.trackUsageBulk) {
2170
+ throw new import_core3.SolvaPayError("trackUsageBulk is not available on this API client");
2171
+ }
2172
+ return apiClient.trackUsageBulk(params);
2173
+ },
2072
2174
  createCustomer(params) {
2073
2175
  if (!apiClient.createCustomer) {
2074
2176
  throw new import_core3.SolvaPayError("createCustomer is not available on this API client");
@@ -2078,6 +2180,12 @@ function createSolvaPay(config) {
2078
2180
  getCustomer(params) {
2079
2181
  return apiClient.getCustomer(params);
2080
2182
  },
2183
+ assignCredits(params) {
2184
+ if (!apiClient.assignCredits) {
2185
+ throw new import_core3.SolvaPayError("assignCredits is not available on this API client");
2186
+ }
2187
+ return apiClient.assignCredits(params);
2188
+ },
2081
2189
  getCustomerBalance(params) {
2082
2190
  if (!apiClient.getCustomerBalance) {
2083
2191
  throw new import_core3.SolvaPayError("getCustomerBalance is not available on this API client");
@@ -2163,7 +2271,9 @@ function createSolvaPay(config) {
2163
2271
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2164
2272
  async function(businessLogic) {
2165
2273
  const getCustomerRef = (args) => {
2166
- const configuredRef = options.getCustomerRef?.(args);
2274
+ const configuredRef = options.getCustomerRef?.(
2275
+ args
2276
+ );
2167
2277
  if (typeof configuredRef === "string") {
2168
2278
  return configuredRef;
2169
2279
  }
@@ -2182,9 +2292,7 @@ function createSolvaPay(config) {
2182
2292
  );
2183
2293
  if (decision.outcome === "gate") {
2184
2294
  const errorMessage = decision.gate.kind === "activation_required" ? "Activation required" : "Payment required";
2185
- const body = paywallErrorToClientPayload(
2186
- new PaywallError(errorMessage, decision.gate)
2187
- );
2295
+ const body = paywallErrorToClientPayload(new PaywallError(errorMessage, decision.gate));
2188
2296
  const response = new Response(JSON.stringify(body), {
2189
2297
  status: 402,
2190
2298
  headers: { "content-type": "application/json" }
@@ -2311,7 +2419,8 @@ async function createPaymentIntentCore(request, body, options = {}) {
2311
2419
  const paymentIntent = await solvaPay.createPaymentIntent({
2312
2420
  productRef: body.productRef,
2313
2421
  planRef: body.planRef,
2314
- customerRef
2422
+ customerRef,
2423
+ ...body.currency && { currency: body.currency }
2315
2424
  });
2316
2425
  return {
2317
2426
  processorPaymentId: paymentIntent.processorPaymentId,
@@ -2841,15 +2950,16 @@ async function trackUsageCore(request, body, options = {}) {
2841
2950
  email: email || void 0,
2842
2951
  name: name || void 0
2843
2952
  });
2844
- await solvaPay.trackUsage({
2953
+ const result = await solvaPay.trackUsage({
2845
2954
  customerRef,
2846
2955
  actionType: body.actionType,
2847
2956
  units: body.units,
2848
2957
  productRef: body.productRef,
2849
2958
  description: body.description,
2850
- metadata: body.metadata
2959
+ metadata: body.metadata,
2960
+ idempotencyKey: body.idempotencyKey
2851
2961
  });
2852
- return { success: true };
2962
+ return result;
2853
2963
  } catch (error) {
2854
2964
  return handleRouteError(error, "Track usage", "Track usage failed");
2855
2965
  }
@@ -29,6 +29,15 @@ interface components {
29
29
  * @example usd
30
30
  */
31
31
  defaultCurrency?: string;
32
+ /**
33
+ * Full set of currencies a customer may pay credit topups in, including the default currency. Omitted/single-entry means single-currency behavior.
34
+ * @example [
35
+ * "USD",
36
+ * "EUR",
37
+ * "GBP"
38
+ * ]
39
+ */
40
+ supportedTopupCurrencies?: string[];
32
41
  /**
33
42
  * Descriptor appearing on the customer card statement
34
43
  * @example ACME INC
@@ -246,6 +255,33 @@ interface components {
246
255
  */
247
256
  checkoutUrl: string;
248
257
  };
258
+ PlanPricingOptionDto: {
259
+ /**
260
+ * ISO 4217 currency code
261
+ * @example USD
262
+ */
263
+ currency: string;
264
+ /**
265
+ * Price in smallest currency unit (e.g. cents)
266
+ * @example 2999
267
+ */
268
+ price: number;
269
+ /**
270
+ * Base price in smallest currency unit (hybrid plans)
271
+ * @example 1999
272
+ */
273
+ basePrice?: number;
274
+ /**
275
+ * One-time setup fee in smallest currency unit
276
+ * @example 500
277
+ */
278
+ setupFee?: number;
279
+ /**
280
+ * Whether this is the default currency option for the plan
281
+ * @example true
282
+ */
283
+ default?: boolean;
284
+ };
249
285
  Plan: {
250
286
  /**
251
287
  * Plan type exposed in SDK
@@ -283,6 +319,8 @@ interface components {
283
319
  * @example USD
284
320
  */
285
321
  currency: string;
322
+ /** @description Per-currency price options for this plan */
323
+ pricingOptions?: components["schemas"]["PlanPricingOptionDto"][];
286
324
  /**
287
325
  * Currency symbol (derived from currency)
288
326
  * @example $
@@ -376,6 +414,13 @@ interface components {
376
414
  price?: number;
377
415
  creditsPerUnit?: number;
378
416
  currency?: string;
417
+ pricingOptions?: {
418
+ currency: string;
419
+ price: number;
420
+ basePrice?: number;
421
+ setupFee?: number;
422
+ default?: boolean;
423
+ }[];
379
424
  /** @enum {string} */
380
425
  billingModel?: "pre-paid" | "post-paid";
381
426
  freeUnits?: number;
@@ -414,6 +459,13 @@ interface components {
414
459
  price?: number;
415
460
  creditsPerUnit?: number;
416
461
  currency?: string;
462
+ pricingOptions?: {
463
+ currency: string;
464
+ price: number;
465
+ basePrice?: number;
466
+ setupFee?: number;
467
+ default?: boolean;
468
+ }[];
417
469
  /** @enum {string} */
418
470
  billingModel?: "pre-paid" | "post-paid";
419
471
  freeUnits?: number;
@@ -658,6 +710,13 @@ interface components {
658
710
  name: string;
659
711
  price: number;
660
712
  currency: string;
713
+ pricingOptions?: {
714
+ currency: string;
715
+ price: number;
716
+ basePrice?: number;
717
+ setupFee?: number;
718
+ default?: boolean;
719
+ }[];
661
720
  /** @enum {string} */
662
721
  billingCycle?: "weekly" | "monthly" | "quarterly" | "yearly" | "custom";
663
722
  /** @enum {string} */
@@ -726,6 +785,13 @@ interface components {
726
785
  name: string;
727
786
  price: number;
728
787
  currency: string;
788
+ pricingOptions?: {
789
+ currency: string;
790
+ price: number;
791
+ basePrice?: number;
792
+ setupFee?: number;
793
+ default?: boolean;
794
+ }[];
729
795
  /** @enum {string} */
730
796
  billingCycle?: "weekly" | "monthly" | "quarterly" | "yearly" | "custom";
731
797
  /** @enum {string} */
@@ -759,6 +825,52 @@ interface components {
759
825
  CloneProductDto: {
760
826
  name?: string;
761
827
  };
828
+ CreditDebitSuccessResponse: {
829
+ /** @enum {number} */
830
+ debited: true;
831
+ /**
832
+ * Credits debited for this usage event
833
+ * @example 10
834
+ */
835
+ amount: number;
836
+ /**
837
+ * Estimated remaining units after debit
838
+ * @example 99
839
+ */
840
+ unitsRemaining: number;
841
+ };
842
+ CreditDebitSkippedResponse: {
843
+ /** @enum {number} */
844
+ debited: false;
845
+ /**
846
+ * Reason no credit debit was recorded
847
+ * @example duplicate
848
+ * @enum {string}
849
+ */
850
+ reason: "duplicate" | "no_product_ref" | "customer_not_found" | "no_active_purchase" | "plan_not_credit_based";
851
+ };
852
+ UsageRecordResponse: {
853
+ /** @example true */
854
+ success: boolean;
855
+ /** @example usage_A1B2C3D4 */
856
+ reference: string;
857
+ creditDebit?: components["schemas"]["CreditDebitSuccessResponse"] | components["schemas"]["CreditDebitSkippedResponse"];
858
+ };
859
+ BulkUsageResultResponse: {
860
+ /** @example usage_A1B2C3D4 */
861
+ reference: string;
862
+ creditDebit?: components["schemas"]["CreditDebitSuccessResponse"] | components["schemas"]["CreditDebitSkippedResponse"];
863
+ };
864
+ BulkUsageResponse: {
865
+ /** @example true */
866
+ success: boolean;
867
+ /**
868
+ * Number of usage events inserted
869
+ * @example 2
870
+ */
871
+ inserted: number;
872
+ results: components["schemas"]["BulkUsageResultResponse"][];
873
+ };
762
874
  CreateUsageRequest: {
763
875
  customerRef: string;
764
876
  /**
@@ -1028,6 +1140,8 @@ interface components {
1028
1140
  creditsPerUnit?: number;
1029
1141
  billingModel?: string;
1030
1142
  billingCycle?: string;
1143
+ /** @description Per-currency price options for this plan */
1144
+ pricingOptions?: components["schemas"]["PlanPricingOptionDto"][];
1031
1145
  };
1032
1146
  LimitBalanceDto: {
1033
1147
  /** @description Credit balance in mils */
@@ -1111,6 +1225,22 @@ interface components {
1111
1225
  };
1112
1226
  externalRef?: string;
1113
1227
  };
1228
+ GrantCustomerCreditsRequest: {
1229
+ credits: number;
1230
+ reason?: string;
1231
+ };
1232
+ GrantCustomerCreditsResponse: {
1233
+ /** @description Whether the grant was recorded */
1234
+ success: boolean;
1235
+ /** @description Customer reference identifier */
1236
+ customerRef: string;
1237
+ /** @description Granted credit amount */
1238
+ credits: number;
1239
+ /** @description Customer credit balance after the grant */
1240
+ balance: number;
1241
+ /** @description Machine-readable grant reason */
1242
+ reason?: string;
1243
+ };
1114
1244
  CreateCustomerSessionRequest: {
1115
1245
  customerRef: string;
1116
1246
  productRef?: string;