@drawbridge/drawbridge-stripe 0.1.11 → 0.1.13

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.
Files changed (3) hide show
  1. package/dist/index.js +118 -74
  2. package/dist/index.mjs +118 -74
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -284,22 +284,32 @@ var require_subscription = __commonJS({
284
284
  const options = {
285
285
  headers: {
286
286
  "Authorization": "Bearer " + process.env.STRIPE_API_KEY,
287
- "Content-Type": "application/json",
288
- "Stripe-Version": "2026-01-28.preview"
287
+ "Content-Type": "application/x-www-form-urlencoded",
288
+ "Stripe-Version": "2026-03-25.preview"
289
289
  }
290
290
  };
291
+ const idem = (base, suffix) => {
292
+ if (!base) return void 0;
293
+ return {
294
+ idempotencyKey: base + ":" + suffix
295
+ };
296
+ };
291
297
  const createMeter = async ({
298
+ idempotencyKey,
292
299
  metadata,
293
300
  name
294
301
  }) => {
295
302
  const usage = (metadata == null ? void 0 : metadata.organization) + "_usage_" + name;
296
- const meter = await stripe2.billing.meters.create({
297
- default_aggregation: {
298
- formula: "sum"
303
+ const meter = await stripe2.billing.meters.create(
304
+ {
305
+ default_aggregation: {
306
+ formula: "sum"
307
+ },
308
+ display_name: usage,
309
+ event_name: usage
299
310
  },
300
- display_name: usage,
301
- event_name: usage
302
- });
311
+ idem(idempotencyKey, "meter.create." + name)
312
+ );
303
313
  return {
304
314
  meter: meter == null ? void 0 : meter.id,
305
315
  usage
@@ -307,6 +317,7 @@ var require_subscription = __commonJS({
307
317
  };
308
318
  const createTier = async ({
309
319
  currency,
320
+ idempotencyKey,
310
321
  interval,
311
322
  limit,
312
323
  metadata,
@@ -315,42 +326,49 @@ var require_subscription = __commonJS({
315
326
  overage
316
327
  }) => {
317
328
  const response = {};
318
- const product = await stripe2.products.create({
319
- metadata,
320
- name
321
- });
322
- response["product"] = product == null ? void 0 : product.id;
323
- const price = await stripe2.prices.create({
324
- billing_scheme: "tiered",
325
- currency,
326
- metadata,
327
- nickname: name,
328
- product: product == null ? void 0 : product.id,
329
- recurring: {
330
- interval,
331
- meter,
332
- usage_type: "metered"
329
+ const product = await stripe2.products.create(
330
+ {
331
+ metadata,
332
+ name
333
333
  },
334
- tax_behavior: "exclusive",
335
- tiers: [
336
- {
337
- flat_amount: "0",
338
- // included in the plan. Should not be a value.
339
- up_to: limit
334
+ idem(idempotencyKey, "product.create." + name)
335
+ );
336
+ response["product"] = product == null ? void 0 : product.id;
337
+ const price = await stripe2.prices.create(
338
+ {
339
+ billing_scheme: "tiered",
340
+ currency,
341
+ metadata,
342
+ nickname: name,
343
+ product: product == null ? void 0 : product.id,
344
+ recurring: {
345
+ interval,
346
+ meter,
347
+ usage_type: "metered"
340
348
  },
341
- {
342
- unit_amount_decimal: overage,
343
- up_to: "inf"
344
- }
345
- ],
346
- tiers_mode: "graduated"
347
- });
349
+ tax_behavior: "exclusive",
350
+ tiers: [
351
+ {
352
+ flat_amount: "0",
353
+ // included in the plan. Should not be a value.
354
+ up_to: limit
355
+ },
356
+ {
357
+ unit_amount_decimal: overage,
358
+ up_to: "inf"
359
+ }
360
+ ],
361
+ tiers_mode: "graduated"
362
+ },
363
+ idem(idempotencyKey, "price.create." + name)
364
+ );
348
365
  response["price"] = price == null ? void 0 : price.id;
349
366
  return response;
350
367
  ;
351
368
  };
352
369
  const createItem = async ({
353
370
  currency,
371
+ idempotencyKey,
354
372
  interval,
355
373
  limit,
356
374
  metadata,
@@ -361,6 +379,7 @@ var require_subscription = __commonJS({
361
379
  }) => {
362
380
  const response = {};
363
381
  const { meter, usage } = await createMeter({
382
+ idempotencyKey,
364
383
  metadata,
365
384
  name
366
385
  });
@@ -368,6 +387,7 @@ var require_subscription = __commonJS({
368
387
  response["usage"] = usage;
369
388
  const { price, product } = await createTier({
370
389
  currency,
390
+ idempotencyKey,
371
391
  interval,
372
392
  limit,
373
393
  metadata,
@@ -378,12 +398,15 @@ var require_subscription = __commonJS({
378
398
  response["price"] = price;
379
399
  response["product"] = product;
380
400
  if (subscription) {
381
- const { id } = await stripe2.subscriptionItems.create({
382
- metadata,
383
- price,
384
- proration_behavior,
385
- subscription
386
- });
401
+ const { id } = await stripe2.subscriptionItems.create(
402
+ {
403
+ metadata,
404
+ price,
405
+ proration_behavior,
406
+ subscription
407
+ },
408
+ idem(idempotencyKey, "subscriptionItem.create." + name)
409
+ );
387
410
  response["id"] = id;
388
411
  }
389
412
  ;
@@ -392,6 +415,7 @@ var require_subscription = __commonJS({
392
415
  return {
393
416
  change: async ({
394
417
  direction,
418
+ idempotencyKey,
395
419
  items,
396
420
  metadata,
397
421
  stripeSubscriptionId,
@@ -444,19 +468,26 @@ var require_subscription = __commonJS({
444
468
  proration_behavior: "none"
445
469
  }
446
470
  ];
447
- const schedule = await stripe2.subscriptionSchedules.create({
448
- from_subscription: stripeSubscriptionId
449
- });
471
+ const schedule = await stripe2.subscriptionSchedules.create(
472
+ {
473
+ from_subscription: stripeSubscriptionId
474
+ },
475
+ idem(idempotencyKey, "schedule.create")
476
+ );
450
477
  try {
451
478
  await stripe2.subscriptionSchedules.update(
452
479
  schedule.id,
453
480
  {
454
481
  end_behavior: "release",
455
482
  phases
456
- }
483
+ },
484
+ idem(idempotencyKey, "schedule.update")
457
485
  );
458
486
  } catch (error) {
459
- await stripe2.subscriptionSchedules.release(schedule.id).catch(() => {
487
+ await stripe2.subscriptionSchedules.release(
488
+ schedule.id,
489
+ idem(idempotencyKey, "schedule.release")
490
+ ).catch(() => {
460
491
  });
461
492
  throw error;
462
493
  }
@@ -479,7 +510,8 @@ var require_subscription = __commonJS({
479
510
  ...props,
480
511
  price: (_f = items == null ? void 0 : items.plan) == null ? void 0 : _f.price,
481
512
  proration_behavior: "always_invoice"
482
- }
513
+ },
514
+ idem(idempotencyKey, "plan.update")
483
515
  );
484
516
  let actions = (items == null ? void 0 : items.actions) || {};
485
517
  if ((actions == null ? void 0 : actions.id) && (actions == null ? void 0 : actions.price)) {
@@ -489,11 +521,13 @@ var require_subscription = __commonJS({
489
521
  ...props,
490
522
  price: actions.price,
491
523
  proration_behavior: "none"
492
- }
524
+ },
525
+ idem(idempotencyKey, "actions.update")
493
526
  ));
494
527
  } else {
495
528
  actions = await createItem({
496
529
  currency: to.currency,
530
+ idempotencyKey,
497
531
  interval: to.interval,
498
532
  limit: to.limits.organization.actions,
499
533
  metadata,
@@ -507,7 +541,8 @@ var require_subscription = __commonJS({
507
541
  stripeSubscriptionId,
508
542
  {
509
543
  metadata
510
- }
544
+ },
545
+ idem(idempotencyKey, "subscription.update")
511
546
  );
512
547
  return {
513
548
  items: {
@@ -591,20 +626,14 @@ var require_subscription = __commonJS({
591
626
  stripeSubscriptionId
592
627
  }) => {
593
628
  try {
629
+ const body = new URLSearchParams();
630
+ body.append("type", "subscription");
631
+ body.append("bill_for[unused_time_from][type]", "now");
632
+ body.append("bill_for[outstanding_usage_through][type]", "now");
633
+ body.append("invoicing_behavior", "pending_invoice_item");
594
634
  const { data } = await axios.post(
595
635
  subscriptions + "/" + stripeSubscriptionId + "/pause",
596
- {
597
- type: "subscription",
598
- bill_for: {
599
- unused_time_from: {
600
- type: "now"
601
- },
602
- outstanding_usage_through: {
603
- type: "now"
604
- }
605
- },
606
- invoicing_behavior: "pending_invoice_item"
607
- },
636
+ body,
608
637
  options
609
638
  );
610
639
  return data;
@@ -616,12 +645,12 @@ var require_subscription = __commonJS({
616
645
  stripeSubscriptionId
617
646
  }) => {
618
647
  try {
648
+ const body = new URLSearchParams();
649
+ body.append("billing_cycle_anchor", "unchanged");
650
+ body.append("proration_behavior", "create_prorations");
619
651
  const { data } = await axios.post(
620
652
  subscriptions + "/" + stripeSubscriptionId + "/resume",
621
- {
622
- billing_cycle_anchor: "unchanged",
623
- proration_behavior: "create_prorations"
624
- },
653
+ body,
625
654
  options
626
655
  );
627
656
  return data;
@@ -632,6 +661,7 @@ var require_subscription = __commonJS({
632
661
  update: async ({
633
662
  current,
634
663
  direction,
664
+ idempotencyKey,
635
665
  metadata,
636
666
  stripeSubscriptionId,
637
667
  to
@@ -644,6 +674,7 @@ var require_subscription = __commonJS({
644
674
  if ((_b = (_a = current == null ? void 0 : current.items) == null ? void 0 : _a.actions) == null ? void 0 : _b.meter) {
645
675
  actions2 = await createTier({
646
676
  currency: to.currency,
677
+ idempotencyKey,
647
678
  interval: to.interval,
648
679
  limit: to.limits.organization.actions,
649
680
  metadata,
@@ -654,6 +685,7 @@ var require_subscription = __commonJS({
654
685
  } else {
655
686
  const created = await createItem({
656
687
  currency: to.currency,
688
+ idempotencyKey,
657
689
  interval: to.interval,
658
690
  limit: to.limits.organization.actions,
659
691
  metadata,
@@ -707,19 +739,26 @@ var require_subscription = __commonJS({
707
739
  proration_behavior: "none"
708
740
  }
709
741
  ];
710
- const schedule = await stripe2.subscriptionSchedules.create({
711
- from_subscription: stripeSubscriptionId
712
- });
742
+ const schedule = await stripe2.subscriptionSchedules.create(
743
+ {
744
+ from_subscription: stripeSubscriptionId
745
+ },
746
+ idem(idempotencyKey, "schedule.create")
747
+ );
713
748
  try {
714
749
  await stripe2.subscriptionSchedules.update(
715
750
  schedule.id,
716
751
  {
717
752
  end_behavior: "release",
718
753
  phases
719
- }
754
+ },
755
+ idem(idempotencyKey, "schedule.update")
720
756
  );
721
757
  } catch (error) {
722
- await stripe2.subscriptionSchedules.release(schedule.id).catch(() => {
758
+ await stripe2.subscriptionSchedules.release(
759
+ schedule.id,
760
+ idem(idempotencyKey, "schedule.release")
761
+ ).catch(() => {
723
762
  });
724
763
  throw error;
725
764
  }
@@ -748,12 +787,14 @@ var require_subscription = __commonJS({
748
787
  ...props,
749
788
  price: to.stripePriceId,
750
789
  proration_behavior: "always_invoice"
751
- }
790
+ },
791
+ idem(idempotencyKey, "plan.update")
752
792
  );
753
793
  let actions;
754
794
  if (((_j = (_i = current == null ? void 0 : current.items) == null ? void 0 : _i.actions) == null ? void 0 : _j.id) && ((_l = (_k = current == null ? void 0 : current.items) == null ? void 0 : _k.actions) == null ? void 0 : _l.meter)) {
755
795
  actions = await createTier({
756
796
  currency: to.currency,
797
+ idempotencyKey,
757
798
  interval: to.interval,
758
799
  limit: to.limits.organization.actions,
759
800
  metadata,
@@ -767,11 +808,13 @@ var require_subscription = __commonJS({
767
808
  ...props,
768
809
  price: actions == null ? void 0 : actions.price,
769
810
  proration_behavior: "none"
770
- }
811
+ },
812
+ idem(idempotencyKey, "actions.update")
771
813
  ));
772
814
  } else {
773
815
  actions = await createItem({
774
816
  currency: to.currency,
817
+ idempotencyKey,
775
818
  interval: to.interval,
776
819
  limit: to.limits.organization.actions,
777
820
  metadata,
@@ -786,7 +829,8 @@ var require_subscription = __commonJS({
786
829
  stripeSubscriptionId,
787
830
  {
788
831
  metadata
789
- }
832
+ },
833
+ idem(idempotencyKey, "subscription.update")
790
834
  );
791
835
  return {
792
836
  items: {
package/dist/index.mjs CHANGED
@@ -290,22 +290,32 @@ var require_subscription = __commonJS({
290
290
  const options = {
291
291
  headers: {
292
292
  "Authorization": "Bearer " + process.env.STRIPE_API_KEY,
293
- "Content-Type": "application/json",
294
- "Stripe-Version": "2026-01-28.preview"
293
+ "Content-Type": "application/x-www-form-urlencoded",
294
+ "Stripe-Version": "2026-03-25.preview"
295
295
  }
296
296
  };
297
+ const idem = (base, suffix) => {
298
+ if (!base) return void 0;
299
+ return {
300
+ idempotencyKey: base + ":" + suffix
301
+ };
302
+ };
297
303
  const createMeter = async ({
304
+ idempotencyKey,
298
305
  metadata,
299
306
  name
300
307
  }) => {
301
308
  const usage = (metadata == null ? void 0 : metadata.organization) + "_usage_" + name;
302
- const meter = await stripe.billing.meters.create({
303
- default_aggregation: {
304
- formula: "sum"
309
+ const meter = await stripe.billing.meters.create(
310
+ {
311
+ default_aggregation: {
312
+ formula: "sum"
313
+ },
314
+ display_name: usage,
315
+ event_name: usage
305
316
  },
306
- display_name: usage,
307
- event_name: usage
308
- });
317
+ idem(idempotencyKey, "meter.create." + name)
318
+ );
309
319
  return {
310
320
  meter: meter == null ? void 0 : meter.id,
311
321
  usage
@@ -313,6 +323,7 @@ var require_subscription = __commonJS({
313
323
  };
314
324
  const createTier = async ({
315
325
  currency,
326
+ idempotencyKey,
316
327
  interval,
317
328
  limit,
318
329
  metadata,
@@ -321,42 +332,49 @@ var require_subscription = __commonJS({
321
332
  overage
322
333
  }) => {
323
334
  const response = {};
324
- const product = await stripe.products.create({
325
- metadata,
326
- name
327
- });
328
- response["product"] = product == null ? void 0 : product.id;
329
- const price = await stripe.prices.create({
330
- billing_scheme: "tiered",
331
- currency,
332
- metadata,
333
- nickname: name,
334
- product: product == null ? void 0 : product.id,
335
- recurring: {
336
- interval,
337
- meter,
338
- usage_type: "metered"
335
+ const product = await stripe.products.create(
336
+ {
337
+ metadata,
338
+ name
339
339
  },
340
- tax_behavior: "exclusive",
341
- tiers: [
342
- {
343
- flat_amount: "0",
344
- // included in the plan. Should not be a value.
345
- up_to: limit
340
+ idem(idempotencyKey, "product.create." + name)
341
+ );
342
+ response["product"] = product == null ? void 0 : product.id;
343
+ const price = await stripe.prices.create(
344
+ {
345
+ billing_scheme: "tiered",
346
+ currency,
347
+ metadata,
348
+ nickname: name,
349
+ product: product == null ? void 0 : product.id,
350
+ recurring: {
351
+ interval,
352
+ meter,
353
+ usage_type: "metered"
346
354
  },
347
- {
348
- unit_amount_decimal: overage,
349
- up_to: "inf"
350
- }
351
- ],
352
- tiers_mode: "graduated"
353
- });
355
+ tax_behavior: "exclusive",
356
+ tiers: [
357
+ {
358
+ flat_amount: "0",
359
+ // included in the plan. Should not be a value.
360
+ up_to: limit
361
+ },
362
+ {
363
+ unit_amount_decimal: overage,
364
+ up_to: "inf"
365
+ }
366
+ ],
367
+ tiers_mode: "graduated"
368
+ },
369
+ idem(idempotencyKey, "price.create." + name)
370
+ );
354
371
  response["price"] = price == null ? void 0 : price.id;
355
372
  return response;
356
373
  ;
357
374
  };
358
375
  const createItem = async ({
359
376
  currency,
377
+ idempotencyKey,
360
378
  interval,
361
379
  limit,
362
380
  metadata,
@@ -367,6 +385,7 @@ var require_subscription = __commonJS({
367
385
  }) => {
368
386
  const response = {};
369
387
  const { meter, usage } = await createMeter({
388
+ idempotencyKey,
370
389
  metadata,
371
390
  name
372
391
  });
@@ -374,6 +393,7 @@ var require_subscription = __commonJS({
374
393
  response["usage"] = usage;
375
394
  const { price, product } = await createTier({
376
395
  currency,
396
+ idempotencyKey,
377
397
  interval,
378
398
  limit,
379
399
  metadata,
@@ -384,12 +404,15 @@ var require_subscription = __commonJS({
384
404
  response["price"] = price;
385
405
  response["product"] = product;
386
406
  if (subscription) {
387
- const { id } = await stripe.subscriptionItems.create({
388
- metadata,
389
- price,
390
- proration_behavior,
391
- subscription
392
- });
407
+ const { id } = await stripe.subscriptionItems.create(
408
+ {
409
+ metadata,
410
+ price,
411
+ proration_behavior,
412
+ subscription
413
+ },
414
+ idem(idempotencyKey, "subscriptionItem.create." + name)
415
+ );
393
416
  response["id"] = id;
394
417
  }
395
418
  ;
@@ -398,6 +421,7 @@ var require_subscription = __commonJS({
398
421
  return {
399
422
  change: async ({
400
423
  direction,
424
+ idempotencyKey,
401
425
  items,
402
426
  metadata,
403
427
  stripeSubscriptionId,
@@ -450,19 +474,26 @@ var require_subscription = __commonJS({
450
474
  proration_behavior: "none"
451
475
  }
452
476
  ];
453
- const schedule = await stripe.subscriptionSchedules.create({
454
- from_subscription: stripeSubscriptionId
455
- });
477
+ const schedule = await stripe.subscriptionSchedules.create(
478
+ {
479
+ from_subscription: stripeSubscriptionId
480
+ },
481
+ idem(idempotencyKey, "schedule.create")
482
+ );
456
483
  try {
457
484
  await stripe.subscriptionSchedules.update(
458
485
  schedule.id,
459
486
  {
460
487
  end_behavior: "release",
461
488
  phases
462
- }
489
+ },
490
+ idem(idempotencyKey, "schedule.update")
463
491
  );
464
492
  } catch (error) {
465
- await stripe.subscriptionSchedules.release(schedule.id).catch(() => {
493
+ await stripe.subscriptionSchedules.release(
494
+ schedule.id,
495
+ idem(idempotencyKey, "schedule.release")
496
+ ).catch(() => {
466
497
  });
467
498
  throw error;
468
499
  }
@@ -485,7 +516,8 @@ var require_subscription = __commonJS({
485
516
  ...props,
486
517
  price: (_f = items == null ? void 0 : items.plan) == null ? void 0 : _f.price,
487
518
  proration_behavior: "always_invoice"
488
- }
519
+ },
520
+ idem(idempotencyKey, "plan.update")
489
521
  );
490
522
  let actions = (items == null ? void 0 : items.actions) || {};
491
523
  if ((actions == null ? void 0 : actions.id) && (actions == null ? void 0 : actions.price)) {
@@ -495,11 +527,13 @@ var require_subscription = __commonJS({
495
527
  ...props,
496
528
  price: actions.price,
497
529
  proration_behavior: "none"
498
- }
530
+ },
531
+ idem(idempotencyKey, "actions.update")
499
532
  ));
500
533
  } else {
501
534
  actions = await createItem({
502
535
  currency: to.currency,
536
+ idempotencyKey,
503
537
  interval: to.interval,
504
538
  limit: to.limits.organization.actions,
505
539
  metadata,
@@ -513,7 +547,8 @@ var require_subscription = __commonJS({
513
547
  stripeSubscriptionId,
514
548
  {
515
549
  metadata
516
- }
550
+ },
551
+ idem(idempotencyKey, "subscription.update")
517
552
  );
518
553
  return {
519
554
  items: {
@@ -597,20 +632,14 @@ var require_subscription = __commonJS({
597
632
  stripeSubscriptionId
598
633
  }) => {
599
634
  try {
635
+ const body = new URLSearchParams();
636
+ body.append("type", "subscription");
637
+ body.append("bill_for[unused_time_from][type]", "now");
638
+ body.append("bill_for[outstanding_usage_through][type]", "now");
639
+ body.append("invoicing_behavior", "pending_invoice_item");
600
640
  const { data } = await axios.post(
601
641
  subscriptions + "/" + stripeSubscriptionId + "/pause",
602
- {
603
- type: "subscription",
604
- bill_for: {
605
- unused_time_from: {
606
- type: "now"
607
- },
608
- outstanding_usage_through: {
609
- type: "now"
610
- }
611
- },
612
- invoicing_behavior: "pending_invoice_item"
613
- },
642
+ body,
614
643
  options
615
644
  );
616
645
  return data;
@@ -622,12 +651,12 @@ var require_subscription = __commonJS({
622
651
  stripeSubscriptionId
623
652
  }) => {
624
653
  try {
654
+ const body = new URLSearchParams();
655
+ body.append("billing_cycle_anchor", "unchanged");
656
+ body.append("proration_behavior", "create_prorations");
625
657
  const { data } = await axios.post(
626
658
  subscriptions + "/" + stripeSubscriptionId + "/resume",
627
- {
628
- billing_cycle_anchor: "unchanged",
629
- proration_behavior: "create_prorations"
630
- },
659
+ body,
631
660
  options
632
661
  );
633
662
  return data;
@@ -638,6 +667,7 @@ var require_subscription = __commonJS({
638
667
  update: async ({
639
668
  current,
640
669
  direction,
670
+ idempotencyKey,
641
671
  metadata,
642
672
  stripeSubscriptionId,
643
673
  to
@@ -650,6 +680,7 @@ var require_subscription = __commonJS({
650
680
  if ((_b = (_a = current == null ? void 0 : current.items) == null ? void 0 : _a.actions) == null ? void 0 : _b.meter) {
651
681
  actions2 = await createTier({
652
682
  currency: to.currency,
683
+ idempotencyKey,
653
684
  interval: to.interval,
654
685
  limit: to.limits.organization.actions,
655
686
  metadata,
@@ -660,6 +691,7 @@ var require_subscription = __commonJS({
660
691
  } else {
661
692
  const created = await createItem({
662
693
  currency: to.currency,
694
+ idempotencyKey,
663
695
  interval: to.interval,
664
696
  limit: to.limits.organization.actions,
665
697
  metadata,
@@ -713,19 +745,26 @@ var require_subscription = __commonJS({
713
745
  proration_behavior: "none"
714
746
  }
715
747
  ];
716
- const schedule = await stripe.subscriptionSchedules.create({
717
- from_subscription: stripeSubscriptionId
718
- });
748
+ const schedule = await stripe.subscriptionSchedules.create(
749
+ {
750
+ from_subscription: stripeSubscriptionId
751
+ },
752
+ idem(idempotencyKey, "schedule.create")
753
+ );
719
754
  try {
720
755
  await stripe.subscriptionSchedules.update(
721
756
  schedule.id,
722
757
  {
723
758
  end_behavior: "release",
724
759
  phases
725
- }
760
+ },
761
+ idem(idempotencyKey, "schedule.update")
726
762
  );
727
763
  } catch (error) {
728
- await stripe.subscriptionSchedules.release(schedule.id).catch(() => {
764
+ await stripe.subscriptionSchedules.release(
765
+ schedule.id,
766
+ idem(idempotencyKey, "schedule.release")
767
+ ).catch(() => {
729
768
  });
730
769
  throw error;
731
770
  }
@@ -754,12 +793,14 @@ var require_subscription = __commonJS({
754
793
  ...props,
755
794
  price: to.stripePriceId,
756
795
  proration_behavior: "always_invoice"
757
- }
796
+ },
797
+ idem(idempotencyKey, "plan.update")
758
798
  );
759
799
  let actions;
760
800
  if (((_j = (_i = current == null ? void 0 : current.items) == null ? void 0 : _i.actions) == null ? void 0 : _j.id) && ((_l = (_k = current == null ? void 0 : current.items) == null ? void 0 : _k.actions) == null ? void 0 : _l.meter)) {
761
801
  actions = await createTier({
762
802
  currency: to.currency,
803
+ idempotencyKey,
763
804
  interval: to.interval,
764
805
  limit: to.limits.organization.actions,
765
806
  metadata,
@@ -773,11 +814,13 @@ var require_subscription = __commonJS({
773
814
  ...props,
774
815
  price: actions == null ? void 0 : actions.price,
775
816
  proration_behavior: "none"
776
- }
817
+ },
818
+ idem(idempotencyKey, "actions.update")
777
819
  ));
778
820
  } else {
779
821
  actions = await createItem({
780
822
  currency: to.currency,
823
+ idempotencyKey,
781
824
  interval: to.interval,
782
825
  limit: to.limits.organization.actions,
783
826
  metadata,
@@ -792,7 +835,8 @@ var require_subscription = __commonJS({
792
835
  stripeSubscriptionId,
793
836
  {
794
837
  metadata
795
- }
838
+ },
839
+ idem(idempotencyKey, "subscription.update")
796
840
  );
797
841
  return {
798
842
  items: {
package/package.json CHANGED
@@ -24,5 +24,5 @@
24
24
  "build": "tsup ./index.js && npm publish"
25
25
  },
26
26
  "types": "dist/index.d.ts",
27
- "version": "0.1.11"
27
+ "version": "0.1.13"
28
28
  }