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