@checkoutpage/sdk 0.1.14 → 0.1.30

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.mjs CHANGED
@@ -53,34 +53,109 @@ var APIError = class _APIError extends CheckoutPageError {
53
53
  }
54
54
  };
55
55
 
56
+ // src/resources/invoices/invoices.ts
57
+ var InvoiceResource = class {
58
+ constructor(client) {
59
+ this.client = client;
60
+ }
61
+ /**
62
+ * Retrieve a single invoice by ID. The returned `invoiceUrl` is a freshly
63
+ * signed link to the hosted PDF and expires an hour later — re-fetch to
64
+ * mint a new one.
65
+ *
66
+ * @example
67
+ * const { data: invoice } = await client.invoices.get(invoiceId);
68
+ */
69
+ async get(id) {
70
+ if (!id) {
71
+ throw new Error("Invoice ID is required");
72
+ }
73
+ return this.client.request({
74
+ method: "GET",
75
+ path: `/v1/invoices/${id}`
76
+ });
77
+ }
78
+ async list(args = {}) {
79
+ const query = {
80
+ limit: args.limit?.toString(),
81
+ starting_after: args.starting_after,
82
+ ending_before: args.ending_before,
83
+ search: args.search,
84
+ status: args.status,
85
+ customerId: args.customerId,
86
+ chargeId: args.chargeId,
87
+ poNumber: args.poNumber,
88
+ createdAfter: args.createdAfter,
89
+ createdBefore: args.createdBefore
90
+ };
91
+ return this.client.request({
92
+ method: "GET",
93
+ path: "/v1/invoices/",
94
+ query
95
+ });
96
+ }
97
+ async regenerate(id) {
98
+ const response = await this.client.request({
99
+ method: "POST",
100
+ path: `/v1/invoices/${id}/regenerate`
101
+ });
102
+ return response.data;
103
+ }
104
+ };
105
+
56
106
  // src/client.ts
57
107
  var CheckoutPageApiClient = class {
58
108
  apiKey;
59
109
  baseUrl;
110
+ invoices;
60
111
  constructor(options) {
61
112
  if (!options.apiKey) {
62
113
  throw new Error("API key is required");
63
114
  }
64
115
  this.apiKey = options.apiKey;
65
116
  this.baseUrl = options.baseUrl || "https://api.checkoutpage.com";
117
+ this.invoices = new InvoiceResource(this);
66
118
  }
67
119
  async request(options) {
68
120
  const url = this.buildUrl(options.path, options.query);
69
121
  const headers = {
70
122
  Authorization: `Bearer ${this.apiKey}`,
71
- "Content-Type": "application/json",
72
123
  "User-Agent": "@checkoutpage/sdk/0.1.0"
73
124
  };
125
+ if (!options.formData) {
126
+ headers["Content-Type"] = "application/json";
127
+ }
74
128
  const fetchOptions = {
75
129
  method: options.method,
76
130
  headers
77
131
  };
78
- if (options.body) {
132
+ if (options.formData) {
133
+ fetchOptions.body = options.formData;
134
+ } else if (options.body) {
79
135
  fetchOptions.body = JSON.stringify(options.body);
80
136
  }
81
137
  const response = await fetch(url, fetchOptions);
82
138
  return await this.handleResponse(response);
83
139
  }
140
+ /**
141
+ * Perform a request whose successful response is a binary file rather than
142
+ * JSON (e.g. a ticket PDF). Errors are parsed and thrown the same way as
143
+ * request().
144
+ */
145
+ async requestRaw(options) {
146
+ const url = this.buildUrl(options.path, options.query);
147
+ const response = await fetch(url, {
148
+ method: options.method,
149
+ headers: {
150
+ Authorization: `Bearer ${this.apiKey}`,
151
+ "User-Agent": "@checkoutpage/sdk/0.1.0"
152
+ }
153
+ });
154
+ if (!response.ok) {
155
+ await this.handleResponse(response);
156
+ }
157
+ return await response.arrayBuffer();
158
+ }
84
159
  buildUrl(path, query) {
85
160
  const url = new URL(path, this.baseUrl);
86
161
  if (query) {
@@ -135,6 +210,27 @@ var CheckoutPageApiClient = class {
135
210
  }
136
211
  };
137
212
 
213
+ // src/resources/accounts/accounts.ts
214
+ var AccountResource = class {
215
+ constructor(client) {
216
+ this.client = client;
217
+ }
218
+ /**
219
+ * Retrieve the seller account the API key belongs to: store slug, display
220
+ * name and logo.
221
+ *
222
+ * The endpoint wraps the account in a `data` envelope (the OpenAPI spec
223
+ * documents the bare object); this unwraps it so callers get the account.
224
+ */
225
+ async get() {
226
+ const response = await this.client.request({
227
+ method: "GET",
228
+ path: "/v1/account/"
229
+ });
230
+ return response.data;
231
+ }
232
+ };
233
+
138
234
  // src/resources/customers/customers.ts
139
235
  var CustomerResource = class {
140
236
  constructor(client) {
@@ -162,6 +258,38 @@ var CustomerResource = class {
162
258
  path: "/v1/customers/"
163
259
  });
164
260
  }
261
+ async update(customerId, params) {
262
+ if (!customerId) {
263
+ throw new Error("Customer ID is required");
264
+ }
265
+ const body = {};
266
+ if (params.name !== void 0) {
267
+ body.name = params.name;
268
+ }
269
+ if (params.companyName !== void 0) {
270
+ body.companyName = params.companyName;
271
+ }
272
+ if (params.email !== void 0) {
273
+ body.email = params.email;
274
+ }
275
+ if (params.phone !== void 0) {
276
+ body.phone = params.phone;
277
+ }
278
+ if (params.billingEmail !== void 0) {
279
+ body.billingEmail = params.billingEmail;
280
+ }
281
+ if (params.address !== void 0) {
282
+ body.address = params.address;
283
+ }
284
+ if (params.shipping !== void 0) {
285
+ body.shipping = params.shipping;
286
+ }
287
+ return this.client.request({
288
+ method: "PATCH",
289
+ path: `/v1/customers/${customerId}`,
290
+ body
291
+ });
292
+ }
165
293
  };
166
294
 
167
295
  // src/resources/coupons/coupons.ts
@@ -182,6 +310,29 @@ var CouponResource = class {
182
310
  path: "/v1/coupons/"
183
311
  });
184
312
  }
313
+ /**
314
+ * Update an existing coupon. Only the fields you supply are changed.
315
+ *
316
+ * `pageIds` and `ticketTypeIds` replace the existing lists rather than
317
+ * merging — pass an empty array to clear one.
318
+ *
319
+ * The discount itself (`code`, `amountOff`, `percentOff`, `currency`,
320
+ * `duration`) is fixed once the coupon is mirrored into Stripe. To change a
321
+ * discount, soft delete this coupon and create a replacement.
322
+ *
323
+ * @example
324
+ * const { data: coupon } = await client.coupons.update(couponId, { deleted: true });
325
+ */
326
+ async update(couponId, params) {
327
+ if (!couponId) {
328
+ throw new Error("Coupon ID is required");
329
+ }
330
+ return this.client.request({
331
+ method: "PATCH",
332
+ path: `/v1/coupons/${couponId}`,
333
+ body: params
334
+ });
335
+ }
185
336
  async create(params) {
186
337
  const body = {
187
338
  label: params.label,
@@ -197,6 +348,9 @@ var CouponResource = class {
197
348
  if (params.pageIds !== void 0) {
198
349
  body.pageIds = params.pageIds;
199
350
  }
351
+ if (params.ticketTypeIds !== void 0) {
352
+ body.ticketTypeIds = params.ticketTypeIds;
353
+ }
200
354
  if (params.maxRedemptions !== void 0) {
201
355
  body.maxRedemptions = params.maxRedemptions;
202
356
  }
@@ -222,11 +376,34 @@ var PaymentResource = class {
222
376
  constructor(client) {
223
377
  this.client = client;
224
378
  }
379
+ /**
380
+ * Retrieve a single payment by ID. Only checkout payments are returned —
381
+ * an event charge is a booking, and 404s here.
382
+ *
383
+ * @example
384
+ * const { data: payment } = await client.payments.get(paymentId);
385
+ */
386
+ async get(paymentId) {
387
+ if (!paymentId) {
388
+ throw new Error("Payment ID is required");
389
+ }
390
+ return this.client.request({
391
+ method: "GET",
392
+ path: `/v1/payments/${paymentId}`
393
+ });
394
+ }
225
395
  async list(args = {}) {
226
396
  const query = {
227
397
  search: args.search,
228
398
  status: args.status,
229
399
  pageId: args.pageId,
400
+ customerId: args.customerId,
401
+ orderId: args.orderId,
402
+ couponCode: args.couponCode,
403
+ productId: args.productId,
404
+ createdAfter: args.createdAfter,
405
+ createdBefore: args.createdBefore,
406
+ abandonmentStatus: args.abandonmentStatus,
230
407
  limit: args.limit?.toString(),
231
408
  starting_after: args.starting_after,
232
409
  ending_before: args.ending_before
@@ -244,6 +421,21 @@ var SubscriptionResource = class {
244
421
  constructor(client) {
245
422
  this.client = client;
246
423
  }
424
+ /**
425
+ * Retrieve a single subscription by ID.
426
+ *
427
+ * @example
428
+ * const { data: subscription } = await client.subscriptions.get(subscriptionId);
429
+ */
430
+ async get(subscriptionId) {
431
+ if (!subscriptionId) {
432
+ throw new Error("Subscription ID is required");
433
+ }
434
+ return this.client.request({
435
+ method: "GET",
436
+ path: `/v1/subscriptions/${subscriptionId}`
437
+ });
438
+ }
247
439
  async list(args = {}) {
248
440
  const query = {
249
441
  search: args.search,
@@ -259,6 +451,71 @@ var SubscriptionResource = class {
259
451
  path: "/v1/subscriptions/"
260
452
  });
261
453
  }
454
+ /**
455
+ * Cancel a subscription. Provide exactly one of `cancelImmediately`,
456
+ * `cancelAtPeriodEnd`, or `cancelAt` — timing is explicit at the API
457
+ * boundary. Enforced both at the type level via the
458
+ * {@link SubscriptionCancelParams} discriminated union and at the server
459
+ * via zod. Cancellation is one-way; a canceled Stripe subscription cannot
460
+ * be un-canceled.
461
+ *
462
+ * @example
463
+ * await client.subscriptions.cancel(id, { cancelImmediately: true });
464
+ * await client.subscriptions.cancel(id, { cancelAtPeriodEnd: true, sendCancellationEmail: true });
465
+ * await client.subscriptions.cancel(id, { cancelAt: '2026-12-31T23:59:59.000Z' });
466
+ */
467
+ async cancel(subscriptionId, params) {
468
+ return this.client.request({
469
+ method: "POST",
470
+ path: `/v1/subscriptions/${subscriptionId}/cancel`,
471
+ body: params
472
+ });
473
+ }
474
+ };
475
+
476
+ // src/resources/subscription-payments/subscription-payments.ts
477
+ var SubscriptionPaymentResource = class {
478
+ constructor(client) {
479
+ this.client = client;
480
+ }
481
+ /**
482
+ * Retrieve a single subscription payment by ID — one charge within a
483
+ * subscription's billing cycle, not the subscription itself. For every
484
+ * payment on a subscription, use `list({ subscriptionId })`.
485
+ *
486
+ * @example
487
+ * const { data: payment } = await client.subscriptionPayments.get(paymentId);
488
+ */
489
+ async get(subscriptionPaymentId) {
490
+ if (!subscriptionPaymentId) {
491
+ throw new Error("Subscription payment ID is required");
492
+ }
493
+ return this.client.request({
494
+ method: "GET",
495
+ path: `/v1/subscription-payments/${subscriptionPaymentId}`
496
+ });
497
+ }
498
+ async list(args = {}) {
499
+ const query = {
500
+ limit: args.limit?.toString(),
501
+ starting_after: args.starting_after,
502
+ ending_before: args.ending_before,
503
+ subscriptionId: args.subscriptionId,
504
+ customerId: args.customerId,
505
+ pageId: args.pageId,
506
+ paymentStatus: args.paymentStatus,
507
+ paid: args.paid,
508
+ refunded: args.refunded,
509
+ billingReason: args.billingReason,
510
+ createdAfter: args.createdAfter,
511
+ createdBefore: args.createdBefore
512
+ };
513
+ return this.client.request({
514
+ method: "GET",
515
+ query,
516
+ path: "/v1/subscription-payments/"
517
+ });
518
+ }
262
519
  };
263
520
 
264
521
  // src/resources/bookings/bookings.ts
@@ -266,14 +523,55 @@ var BookingResource = class {
266
523
  constructor(client) {
267
524
  this.client = client;
268
525
  }
526
+ /**
527
+ * Retrieve a single booking by ID. Only event bookings are returned —
528
+ * a checkout charge is a payment, and 404s here.
529
+ *
530
+ * @example
531
+ * const { data: booking } = await client.bookings.get(bookingId);
532
+ */
533
+ async get(bookingId) {
534
+ if (!bookingId) {
535
+ throw new Error("Booking ID is required");
536
+ }
537
+ return this.client.request({
538
+ method: "GET",
539
+ path: `/v1/bookings/${bookingId}`
540
+ });
541
+ }
542
+ /**
543
+ * Download the booking's ticket PDF (every ticket in the booking) as raw
544
+ * bytes. The response reflects the current tickets, so attendee updates
545
+ * appear on the next download. Throws NotFoundError when no PDF exists,
546
+ * e.g. for unpaid or abandoned bookings.
547
+ *
548
+ * @example
549
+ * const pdf = await client.bookings.downloadTicketPdf(bookingId);
550
+ * fs.writeFileSync('tickets.pdf', Buffer.from(pdf));
551
+ */
552
+ async downloadTicketPdf(bookingId) {
553
+ if (!bookingId) {
554
+ throw new Error("Booking ID is required");
555
+ }
556
+ return this.client.requestRaw({
557
+ method: "GET",
558
+ path: `/v1/bookings/${bookingId}/ticket-pdf`
559
+ });
560
+ }
269
561
  async list(args = {}) {
270
562
  const query = {
271
563
  search: args.search,
564
+ status: args.status,
565
+ pageId: args.pageId,
566
+ customerId: args.customerId,
567
+ orderId: args.orderId,
568
+ couponCode: args.couponCode,
569
+ createdAfter: args.createdAfter,
570
+ createdBefore: args.createdBefore,
571
+ abandonmentStatus: args.abandonmentStatus,
272
572
  limit: args.limit?.toString(),
273
573
  starting_after: args.starting_after,
274
- ending_before: args.ending_before,
275
- status: args.status,
276
- pageId: args.pageId
574
+ ending_before: args.ending_before
277
575
  };
278
576
  return this.client.request({
279
577
  method: "GET",
@@ -283,21 +581,869 @@ var BookingResource = class {
283
581
  }
284
582
  };
285
583
 
584
+ // src/resources/tickets/tickets.ts
585
+ var TicketResource = class {
586
+ constructor(client) {
587
+ this.client = client;
588
+ }
589
+ async list(args = {}) {
590
+ const query = {
591
+ pageId: args.pageId,
592
+ bookingId: args.bookingId,
593
+ orderId: args.orderId,
594
+ customerId: args.customerId,
595
+ ticketTypeId: args.ticketTypeId,
596
+ status: args.status,
597
+ checkInStatus: args.checkInStatus,
598
+ createdAfter: args.createdAfter,
599
+ createdBefore: args.createdBefore,
600
+ search: args.search,
601
+ limit: args.limit?.toString(),
602
+ starting_after: args.starting_after,
603
+ ending_before: args.ending_before
604
+ };
605
+ return this.client.request({
606
+ method: "GET",
607
+ query,
608
+ path: "/v1/tickets/"
609
+ });
610
+ }
611
+ async update(ticketId, params) {
612
+ if (!ticketId) {
613
+ throw new Error("Ticket ID is required");
614
+ }
615
+ const body = {};
616
+ if (params.attendeeName !== void 0) {
617
+ body.attendeeName = params.attendeeName;
618
+ }
619
+ if (params.attendeeEmail !== void 0) {
620
+ body.attendeeEmail = params.attendeeEmail;
621
+ }
622
+ if (params.metadata !== void 0) {
623
+ body.metadata = params.metadata;
624
+ }
625
+ return this.client.request({
626
+ method: "PATCH",
627
+ path: `/v1/tickets/${ticketId}`,
628
+ body
629
+ });
630
+ }
631
+ async validate(qrCode, params) {
632
+ const body = params || {};
633
+ const response = await this.client.request({
634
+ method: "POST",
635
+ path: `/v1/tickets/validate/${qrCode}`,
636
+ body
637
+ });
638
+ return response.data;
639
+ }
640
+ };
641
+
642
+ // src/resources/products/products.ts
643
+ var ProductResource = class {
644
+ constructor(client) {
645
+ this.client = client;
646
+ }
647
+ async get(productId) {
648
+ if (!productId) {
649
+ throw new Error("Product ID is required");
650
+ }
651
+ return this.client.request({
652
+ method: "GET",
653
+ path: `/v1/products/${productId}`
654
+ });
655
+ }
656
+ async update(productId, params) {
657
+ if (!productId) {
658
+ throw new Error("Product ID is required");
659
+ }
660
+ const body = {};
661
+ if (params.title !== void 0) {
662
+ body.title = params.title;
663
+ }
664
+ if (params.description !== void 0) {
665
+ body.description = params.description;
666
+ }
667
+ if (params.price !== void 0) {
668
+ body.price = params.price;
669
+ }
670
+ if (params.sku !== void 0) {
671
+ body.sku = params.sku;
672
+ }
673
+ if (params.hasUnlimitedStock !== void 0) {
674
+ body.hasUnlimitedStock = params.hasUnlimitedStock;
675
+ }
676
+ if (params.stock !== void 0) {
677
+ body.stock = params.stock;
678
+ }
679
+ if (params.taxBehavior !== void 0) {
680
+ body.taxBehavior = params.taxBehavior;
681
+ }
682
+ if (params.taxCode !== void 0) {
683
+ body.taxCode = params.taxCode;
684
+ }
685
+ if (params.imageIds !== void 0) {
686
+ body.imageIds = params.imageIds;
687
+ }
688
+ if (params.fileIds !== void 0) {
689
+ body.fileIds = params.fileIds;
690
+ }
691
+ if (params.variantsRequired !== void 0) {
692
+ body.variantsRequired = params.variantsRequired;
693
+ }
694
+ if (params.variants !== void 0) {
695
+ body.variants = params.variants;
696
+ }
697
+ if (params.discounts !== void 0) {
698
+ body.discounts = params.discounts;
699
+ }
700
+ if (params.limitSubscriptions !== void 0) {
701
+ body.limitSubscriptions = params.limitSubscriptions;
702
+ }
703
+ if (params.enableFileAccessForInactiveSubscriptions !== void 0) {
704
+ body.enableFileAccessForInactiveSubscriptions = params.enableFileAccessForInactiveSubscriptions;
705
+ }
706
+ if (params.generateLicenseKeys !== void 0) {
707
+ body.generateLicenseKeys = params.generateLicenseKeys;
708
+ }
709
+ if (params.fixedTaxRateIds !== void 0) {
710
+ body.fixedTaxRateIds = params.fixedTaxRateIds;
711
+ }
712
+ if (params.prices !== void 0) {
713
+ body.prices = params.prices;
714
+ }
715
+ if (params.defaultPriceId !== void 0) {
716
+ body.defaultPriceId = params.defaultPriceId;
717
+ }
718
+ return this.client.request({
719
+ method: "PATCH",
720
+ path: `/v1/products/${productId}`,
721
+ body
722
+ });
723
+ }
724
+ };
725
+
726
+ // src/resources/files/files.ts
727
+ var FileResource = class {
728
+ constructor(client) {
729
+ this.client = client;
730
+ }
731
+ async upload(params) {
732
+ if (!params.file) {
733
+ throw new Error("File is required");
734
+ }
735
+ if (!params.purpose) {
736
+ throw new Error("Purpose is required");
737
+ }
738
+ const formData = new FormData();
739
+ formData.append("file", params.file);
740
+ formData.append("purpose", params.purpose);
741
+ return this.client.request({
742
+ method: "POST",
743
+ path: "/v1/files/upload",
744
+ formData
745
+ });
746
+ }
747
+ async delete(fileId) {
748
+ if (!fileId) {
749
+ throw new Error("File ID is required");
750
+ }
751
+ return this.client.request({
752
+ method: "DELETE",
753
+ path: `/v1/files/${fileId}`
754
+ });
755
+ }
756
+ async download(fileId) {
757
+ if (!fileId) {
758
+ throw new Error("File ID is required");
759
+ }
760
+ return this.client.request({
761
+ method: "GET",
762
+ path: `/v1/files/${fileId}/download`
763
+ });
764
+ }
765
+ };
766
+
767
+ // src/resources/checkout-pages/checkout-pages.ts
768
+ var CheckoutPageFieldsResource = class {
769
+ constructor(client) {
770
+ this.client = client;
771
+ }
772
+ async list(pageId) {
773
+ if (!pageId) {
774
+ throw new Error("Page ID is required");
775
+ }
776
+ return this.client.request({
777
+ method: "GET",
778
+ path: `/v1/checkout-pages/${pageId}/fields`
779
+ });
780
+ }
781
+ async create(pageId, params) {
782
+ if (!pageId) {
783
+ throw new Error("Page ID is required");
784
+ }
785
+ return this.client.request({
786
+ method: "POST",
787
+ path: `/v1/checkout-pages/${pageId}/fields`,
788
+ body: params
789
+ });
790
+ }
791
+ async get(pageId, fieldId) {
792
+ if (!pageId) {
793
+ throw new Error("Page ID is required");
794
+ }
795
+ if (!fieldId) {
796
+ throw new Error("Field ID is required");
797
+ }
798
+ return this.client.request({
799
+ method: "GET",
800
+ path: `/v1/checkout-pages/${pageId}/fields/${fieldId}`
801
+ });
802
+ }
803
+ async update(pageId, fieldId, params) {
804
+ if (!pageId) {
805
+ throw new Error("Page ID is required");
806
+ }
807
+ if (!fieldId) {
808
+ throw new Error("Field ID is required");
809
+ }
810
+ return this.client.request({
811
+ method: "PATCH",
812
+ path: `/v1/checkout-pages/${pageId}/fields/${fieldId}`,
813
+ body: params
814
+ });
815
+ }
816
+ async delete(pageId, fieldId) {
817
+ if (!pageId) {
818
+ throw new Error("Page ID is required");
819
+ }
820
+ if (!fieldId) {
821
+ throw new Error("Field ID is required");
822
+ }
823
+ const response = await this.client.request({
824
+ method: "DELETE",
825
+ path: `/v1/checkout-pages/${pageId}/fields/${fieldId}`
826
+ });
827
+ return response;
828
+ }
829
+ };
830
+ var CheckoutPagesResource = class {
831
+ fields;
832
+ client;
833
+ constructor(client) {
834
+ this.client = client;
835
+ this.fields = new CheckoutPageFieldsResource(client);
836
+ }
837
+ async list(args = {}) {
838
+ const query = {
839
+ limit: args.limit?.toString(),
840
+ starting_after: args.starting_after,
841
+ ending_before: args.ending_before,
842
+ status: args.status,
843
+ search: args.search
844
+ };
845
+ return this.client.request({
846
+ method: "GET",
847
+ path: "/v1/checkout-pages/",
848
+ query
849
+ });
850
+ }
851
+ async create(params) {
852
+ return this.client.request({
853
+ method: "POST",
854
+ path: "/v1/checkout-pages/",
855
+ body: params
856
+ });
857
+ }
858
+ async get(pageId) {
859
+ if (!pageId) {
860
+ throw new Error("Page ID is required");
861
+ }
862
+ return this.client.request({
863
+ method: "GET",
864
+ path: `/v1/checkout-pages/${pageId}`
865
+ });
866
+ }
867
+ async update(pageId, params) {
868
+ if (!pageId) {
869
+ throw new Error("Page ID is required");
870
+ }
871
+ return this.client.request({
872
+ method: "PATCH",
873
+ path: `/v1/checkout-pages/${pageId}`,
874
+ body: params
875
+ });
876
+ }
877
+ async delete(pageId) {
878
+ if (!pageId) {
879
+ throw new Error("Page ID is required");
880
+ }
881
+ return this.client.request({
882
+ method: "DELETE",
883
+ path: `/v1/checkout-pages/${pageId}`
884
+ });
885
+ }
886
+ };
887
+
888
+ // src/resources/events/events.ts
889
+ var EventFieldsResource = class {
890
+ constructor(client) {
891
+ this.client = client;
892
+ }
893
+ async list(pageId) {
894
+ if (!pageId) {
895
+ throw new Error("Page ID is required");
896
+ }
897
+ return this.client.request({
898
+ method: "GET",
899
+ path: `/v1/events/${pageId}/fields`
900
+ });
901
+ }
902
+ async create(pageId, params) {
903
+ if (!pageId) {
904
+ throw new Error("Page ID is required");
905
+ }
906
+ return this.client.request({
907
+ method: "POST",
908
+ path: `/v1/events/${pageId}/fields`,
909
+ body: params
910
+ });
911
+ }
912
+ async get(pageId, fieldId) {
913
+ if (!pageId) {
914
+ throw new Error("Page ID is required");
915
+ }
916
+ if (!fieldId) {
917
+ throw new Error("Field ID is required");
918
+ }
919
+ return this.client.request({
920
+ method: "GET",
921
+ path: `/v1/events/${pageId}/fields/${fieldId}`
922
+ });
923
+ }
924
+ async update(pageId, fieldId, params) {
925
+ if (!pageId) {
926
+ throw new Error("Page ID is required");
927
+ }
928
+ if (!fieldId) {
929
+ throw new Error("Field ID is required");
930
+ }
931
+ return this.client.request({
932
+ method: "PATCH",
933
+ path: `/v1/events/${pageId}/fields/${fieldId}`,
934
+ body: params
935
+ });
936
+ }
937
+ async delete(pageId, fieldId) {
938
+ if (!pageId) {
939
+ throw new Error("Page ID is required");
940
+ }
941
+ if (!fieldId) {
942
+ throw new Error("Field ID is required");
943
+ }
944
+ return this.client.request({
945
+ method: "DELETE",
946
+ path: `/v1/events/${pageId}/fields/${fieldId}`
947
+ });
948
+ }
949
+ };
950
+ var EventTicketTypesResource = class {
951
+ constructor(client) {
952
+ this.client = client;
953
+ }
954
+ async list(pageId, ticketGroupId) {
955
+ if (!pageId) {
956
+ throw new Error("Page ID is required");
957
+ }
958
+ if (!ticketGroupId) {
959
+ throw new Error("Ticket group ID is required");
960
+ }
961
+ return this.client.request({
962
+ method: "GET",
963
+ path: `/v1/events/${pageId}/ticket-groups/${ticketGroupId}/ticket-types`
964
+ });
965
+ }
966
+ async create(pageId, ticketGroupId, params) {
967
+ if (!pageId) {
968
+ throw new Error("Page ID is required");
969
+ }
970
+ if (!ticketGroupId) {
971
+ throw new Error("Ticket group ID is required");
972
+ }
973
+ return this.client.request({
974
+ method: "POST",
975
+ path: `/v1/events/${pageId}/ticket-groups/${ticketGroupId}/ticket-types`,
976
+ body: params
977
+ });
978
+ }
979
+ async get(pageId, ticketGroupId, ticketTypeId) {
980
+ if (!pageId) {
981
+ throw new Error("Page ID is required");
982
+ }
983
+ if (!ticketGroupId) {
984
+ throw new Error("Ticket group ID is required");
985
+ }
986
+ if (!ticketTypeId) {
987
+ throw new Error("Ticket type ID is required");
988
+ }
989
+ return this.client.request({
990
+ method: "GET",
991
+ path: `/v1/events/${pageId}/ticket-groups/${ticketGroupId}/ticket-types/${ticketTypeId}`
992
+ });
993
+ }
994
+ async update(pageId, ticketGroupId, ticketTypeId, params) {
995
+ if (!pageId) {
996
+ throw new Error("Page ID is required");
997
+ }
998
+ if (!ticketGroupId) {
999
+ throw new Error("Ticket group ID is required");
1000
+ }
1001
+ if (!ticketTypeId) {
1002
+ throw new Error("Ticket type ID is required");
1003
+ }
1004
+ return this.client.request({
1005
+ method: "PATCH",
1006
+ path: `/v1/events/${pageId}/ticket-groups/${ticketGroupId}/ticket-types/${ticketTypeId}`,
1007
+ body: params
1008
+ });
1009
+ }
1010
+ async delete(pageId, ticketGroupId, ticketTypeId) {
1011
+ if (!pageId) {
1012
+ throw new Error("Page ID is required");
1013
+ }
1014
+ if (!ticketGroupId) {
1015
+ throw new Error("Ticket group ID is required");
1016
+ }
1017
+ if (!ticketTypeId) {
1018
+ throw new Error("Ticket type ID is required");
1019
+ }
1020
+ return this.client.request({
1021
+ method: "DELETE",
1022
+ path: `/v1/events/${pageId}/ticket-groups/${ticketGroupId}/ticket-types/${ticketTypeId}`
1023
+ });
1024
+ }
1025
+ };
1026
+ var EventTicketGroupsResource = class {
1027
+ constructor(client) {
1028
+ this.client = client;
1029
+ this.ticketTypes = new EventTicketTypesResource(client);
1030
+ }
1031
+ ticketTypes;
1032
+ async list(pageId) {
1033
+ if (!pageId) {
1034
+ throw new Error("Page ID is required");
1035
+ }
1036
+ return this.client.request({
1037
+ method: "GET",
1038
+ path: `/v1/events/${pageId}/ticket-groups`
1039
+ });
1040
+ }
1041
+ async create(pageId, params) {
1042
+ if (!pageId) {
1043
+ throw new Error("Page ID is required");
1044
+ }
1045
+ return this.client.request({
1046
+ method: "POST",
1047
+ path: `/v1/events/${pageId}/ticket-groups`,
1048
+ body: params
1049
+ });
1050
+ }
1051
+ async get(pageId, ticketGroupId) {
1052
+ if (!pageId) {
1053
+ throw new Error("Page ID is required");
1054
+ }
1055
+ if (!ticketGroupId) {
1056
+ throw new Error("Ticket group ID is required");
1057
+ }
1058
+ return this.client.request({
1059
+ method: "GET",
1060
+ path: `/v1/events/${pageId}/ticket-groups/${ticketGroupId}`
1061
+ });
1062
+ }
1063
+ async update(pageId, ticketGroupId, params) {
1064
+ if (!pageId) {
1065
+ throw new Error("Page ID is required");
1066
+ }
1067
+ if (!ticketGroupId) {
1068
+ throw new Error("Ticket group ID is required");
1069
+ }
1070
+ return this.client.request({
1071
+ method: "PATCH",
1072
+ path: `/v1/events/${pageId}/ticket-groups/${ticketGroupId}`,
1073
+ body: params
1074
+ });
1075
+ }
1076
+ async delete(pageId, ticketGroupId) {
1077
+ if (!pageId) {
1078
+ throw new Error("Page ID is required");
1079
+ }
1080
+ if (!ticketGroupId) {
1081
+ throw new Error("Ticket group ID is required");
1082
+ }
1083
+ return this.client.request({
1084
+ method: "DELETE",
1085
+ path: `/v1/events/${pageId}/ticket-groups/${ticketGroupId}`
1086
+ });
1087
+ }
1088
+ };
1089
+ var EventsResource = class {
1090
+ constructor(client) {
1091
+ this.client = client;
1092
+ this.ticketGroups = new EventTicketGroupsResource(client);
1093
+ this.fields = new EventFieldsResource(client);
1094
+ }
1095
+ ticketGroups;
1096
+ fields;
1097
+ async list(args = {}) {
1098
+ const query = {
1099
+ limit: args.limit?.toString(),
1100
+ starting_after: args.starting_after,
1101
+ ending_before: args.ending_before,
1102
+ status: args.status,
1103
+ search: args.search
1104
+ };
1105
+ return this.client.request({
1106
+ method: "GET",
1107
+ path: "/v1/events/",
1108
+ query
1109
+ });
1110
+ }
1111
+ async create(params) {
1112
+ return this.client.request({
1113
+ method: "POST",
1114
+ path: "/v1/events/",
1115
+ body: params
1116
+ });
1117
+ }
1118
+ async get(pageId) {
1119
+ if (!pageId) {
1120
+ throw new Error("Page ID is required");
1121
+ }
1122
+ return this.client.request({
1123
+ method: "GET",
1124
+ path: `/v1/events/${pageId}`
1125
+ });
1126
+ }
1127
+ async update(pageId, params) {
1128
+ if (!pageId) {
1129
+ throw new Error("Page ID is required");
1130
+ }
1131
+ return this.client.request({
1132
+ method: "PATCH",
1133
+ path: `/v1/events/${pageId}`,
1134
+ body: params
1135
+ });
1136
+ }
1137
+ async delete(pageId) {
1138
+ if (!pageId) {
1139
+ throw new Error("Page ID is required");
1140
+ }
1141
+ return this.client.request({
1142
+ method: "DELETE",
1143
+ path: `/v1/events/${pageId}`
1144
+ });
1145
+ }
1146
+ };
1147
+
1148
+ // src/resources/forms/forms.ts
1149
+ var FormFieldsResource = class {
1150
+ constructor(client) {
1151
+ this.client = client;
1152
+ }
1153
+ async list(pageId) {
1154
+ if (!pageId) {
1155
+ throw new Error("Page ID is required");
1156
+ }
1157
+ return this.client.request({
1158
+ method: "GET",
1159
+ path: `/v1/forms/${pageId}/fields`
1160
+ });
1161
+ }
1162
+ async create(pageId, params) {
1163
+ if (!pageId) {
1164
+ throw new Error("Page ID is required");
1165
+ }
1166
+ return this.client.request({
1167
+ method: "POST",
1168
+ path: `/v1/forms/${pageId}/fields`,
1169
+ body: params
1170
+ });
1171
+ }
1172
+ async get(pageId, fieldId) {
1173
+ if (!pageId) {
1174
+ throw new Error("Page ID is required");
1175
+ }
1176
+ if (!fieldId) {
1177
+ throw new Error("Field ID is required");
1178
+ }
1179
+ return this.client.request({
1180
+ method: "GET",
1181
+ path: `/v1/forms/${pageId}/fields/${fieldId}`
1182
+ });
1183
+ }
1184
+ async update(pageId, fieldId, params) {
1185
+ if (!pageId) {
1186
+ throw new Error("Page ID is required");
1187
+ }
1188
+ if (!fieldId) {
1189
+ throw new Error("Field ID is required");
1190
+ }
1191
+ return this.client.request({
1192
+ method: "PATCH",
1193
+ path: `/v1/forms/${pageId}/fields/${fieldId}`,
1194
+ body: params
1195
+ });
1196
+ }
1197
+ async delete(pageId, fieldId) {
1198
+ if (!pageId) {
1199
+ throw new Error("Page ID is required");
1200
+ }
1201
+ if (!fieldId) {
1202
+ throw new Error("Field ID is required");
1203
+ }
1204
+ return this.client.request({
1205
+ method: "DELETE",
1206
+ path: `/v1/forms/${pageId}/fields/${fieldId}`
1207
+ });
1208
+ }
1209
+ };
1210
+ var FormsResource = class {
1211
+ constructor(client) {
1212
+ this.client = client;
1213
+ this.fields = new FormFieldsResource(client);
1214
+ }
1215
+ fields;
1216
+ async list(args = {}) {
1217
+ const query = {
1218
+ limit: args.limit?.toString(),
1219
+ starting_after: args.starting_after,
1220
+ ending_before: args.ending_before,
1221
+ status: args.status,
1222
+ search: args.search
1223
+ };
1224
+ return this.client.request({
1225
+ method: "GET",
1226
+ path: "/v1/forms/",
1227
+ query
1228
+ });
1229
+ }
1230
+ async create(params) {
1231
+ return this.client.request({
1232
+ method: "POST",
1233
+ path: "/v1/forms/",
1234
+ body: params
1235
+ });
1236
+ }
1237
+ async get(pageId) {
1238
+ if (!pageId) {
1239
+ throw new Error("Page ID is required");
1240
+ }
1241
+ return this.client.request({
1242
+ method: "GET",
1243
+ path: `/v1/forms/${pageId}`
1244
+ });
1245
+ }
1246
+ async update(pageId, params) {
1247
+ if (!pageId) {
1248
+ throw new Error("Page ID is required");
1249
+ }
1250
+ return this.client.request({
1251
+ method: "PATCH",
1252
+ path: `/v1/forms/${pageId}`,
1253
+ body: params
1254
+ });
1255
+ }
1256
+ async delete(pageId) {
1257
+ if (!pageId) {
1258
+ throw new Error("Page ID is required");
1259
+ }
1260
+ return this.client.request({
1261
+ method: "DELETE",
1262
+ path: `/v1/forms/${pageId}`
1263
+ });
1264
+ }
1265
+ };
1266
+
1267
+ // src/resources/submissions/submissions.ts
1268
+ var SubmissionResource = class {
1269
+ constructor(client) {
1270
+ this.client = client;
1271
+ }
1272
+ async get(submissionId) {
1273
+ if (!submissionId) {
1274
+ throw new Error("Submission ID is required");
1275
+ }
1276
+ return this.client.request({
1277
+ method: "GET",
1278
+ path: `/v1/submissions/${submissionId}`
1279
+ });
1280
+ }
1281
+ async list(args = {}) {
1282
+ const query = {
1283
+ search: args.search,
1284
+ pageId: args.pageId,
1285
+ customerId: args.customerId,
1286
+ status: args.status,
1287
+ createdAfter: args.createdAfter,
1288
+ createdBefore: args.createdBefore,
1289
+ limit: args.limit?.toString(),
1290
+ starting_after: args.starting_after,
1291
+ ending_before: args.ending_before
1292
+ };
1293
+ return this.client.request({
1294
+ method: "GET",
1295
+ path: "/v1/submissions/",
1296
+ query
1297
+ });
1298
+ }
1299
+ };
1300
+
1301
+ // src/resources/tax-rates/tax-rates.ts
1302
+ var TaxRateResource = class {
1303
+ constructor(client) {
1304
+ this.client = client;
1305
+ }
1306
+ async list() {
1307
+ return this.client.request({
1308
+ method: "GET",
1309
+ path: "/v1/tax-rates/"
1310
+ });
1311
+ }
1312
+ async create(params) {
1313
+ const body = {
1314
+ displayName: params.displayName,
1315
+ inclusive: params.inclusive,
1316
+ percentage: params.percentage
1317
+ };
1318
+ if (params.default !== void 0) {
1319
+ body.default = params.default;
1320
+ }
1321
+ return this.client.request({
1322
+ method: "POST",
1323
+ path: "/v1/tax-rates/",
1324
+ body
1325
+ });
1326
+ }
1327
+ async update(taxRateId, params) {
1328
+ if (!taxRateId) {
1329
+ throw new Error("Tax rate ID is required");
1330
+ }
1331
+ const body = {};
1332
+ if (params.displayName !== void 0) {
1333
+ body.displayName = params.displayName;
1334
+ }
1335
+ if (params.default !== void 0) {
1336
+ body.default = params.default;
1337
+ }
1338
+ return this.client.request({
1339
+ method: "PATCH",
1340
+ path: `/v1/tax-rates/${taxRateId}`,
1341
+ body
1342
+ });
1343
+ }
1344
+ };
1345
+
1346
+ // src/resources/webhooks/webhooks.ts
1347
+ var WebhookResource = class {
1348
+ constructor(client) {
1349
+ this.client = client;
1350
+ }
1351
+ /**
1352
+ * List webhook endpoints, newest first. Secrets are never returned.
1353
+ *
1354
+ * @example
1355
+ * const { data, has_more } = await client.webhooks.list({ event: 'payment.paid' });
1356
+ */
1357
+ async list(args = {}) {
1358
+ const query = {
1359
+ status: args.status,
1360
+ event: args.event,
1361
+ limit: args.limit?.toString(),
1362
+ starting_after: args.starting_after,
1363
+ ending_before: args.ending_before
1364
+ };
1365
+ return this.client.request({
1366
+ method: "GET",
1367
+ path: "/v1/webhooks/",
1368
+ query
1369
+ });
1370
+ }
1371
+ /**
1372
+ * Create a webhook endpoint. The `url` must use https.
1373
+ *
1374
+ * The response is the only place the signing `secret` is ever returned —
1375
+ * store it immediately. Omit `secret` to have one generated.
1376
+ *
1377
+ * @example
1378
+ * const { data: webhook } = await client.webhooks.create({
1379
+ * name: 'CRM sync',
1380
+ * url: 'https://example.com/hooks/checkoutpage',
1381
+ * events: ['payment.paid', 'subscription.created'],
1382
+ * });
1383
+ * saveSecret(webhook.secret);
1384
+ */
1385
+ async create(params) {
1386
+ return this.client.request({
1387
+ method: "POST",
1388
+ path: "/v1/webhooks/",
1389
+ body: params
1390
+ });
1391
+ }
1392
+ /**
1393
+ * Delete a webhook endpoint. Deliveries stop immediately; the returned
1394
+ * object is its final state. The webhook no longer appears in `list()`,
1395
+ * and deleting the same id again returns 404.
1396
+ */
1397
+ async delete(webhookId) {
1398
+ if (!webhookId) {
1399
+ throw new Error("Webhook ID is required");
1400
+ }
1401
+ return this.client.request({
1402
+ method: "DELETE",
1403
+ path: `/v1/webhooks/${encodeURIComponent(webhookId)}`
1404
+ });
1405
+ }
1406
+ };
1407
+
286
1408
  // src/index.ts
287
1409
  var CheckoutPageClient = class {
1410
+ accounts;
288
1411
  customers;
289
1412
  coupons;
290
1413
  payments;
291
1414
  subscriptions;
1415
+ subscriptionPayments;
292
1416
  bookings;
1417
+ tickets;
1418
+ products;
1419
+ files;
1420
+ checkoutPages;
1421
+ events;
1422
+ forms;
1423
+ submissions;
1424
+ taxRates;
1425
+ invoices;
1426
+ webhooks;
293
1427
  client;
294
1428
  constructor(options) {
295
1429
  this.client = new CheckoutPageApiClient(options);
1430
+ this.accounts = new AccountResource(this.client);
296
1431
  this.customers = new CustomerResource(this.client);
297
1432
  this.coupons = new CouponResource(this.client);
298
1433
  this.payments = new PaymentResource(this.client);
299
1434
  this.subscriptions = new SubscriptionResource(this.client);
1435
+ this.subscriptionPayments = new SubscriptionPaymentResource(this.client);
300
1436
  this.bookings = new BookingResource(this.client);
1437
+ this.tickets = new TicketResource(this.client);
1438
+ this.products = new ProductResource(this.client);
1439
+ this.files = new FileResource(this.client);
1440
+ this.checkoutPages = new CheckoutPagesResource(this.client);
1441
+ this.events = new EventsResource(this.client);
1442
+ this.forms = new FormsResource(this.client);
1443
+ this.submissions = new SubmissionResource(this.client);
1444
+ this.taxRates = new TaxRateResource(this.client);
1445
+ this.invoices = new InvoiceResource(this.client);
1446
+ this.webhooks = new WebhookResource(this.client);
301
1447
  }
302
1448
  };
303
1449
  var createCheckoutPageClient = (options) => {