@checkoutpage/sdk 0.1.30 → 0.1.32

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
@@ -67,14 +67,19 @@ var InvoiceResource = class {
67
67
  *
68
68
  * @example
69
69
  * const { data: invoice } = await client.invoices.get(invoiceId);
70
+ *
71
+ * @example
72
+ * // A test invoice
73
+ * const { data: testInvoice } = await client.invoices.get(invoiceId, { livemode: false });
70
74
  */
71
- async get(id) {
75
+ async get(id, options = {}) {
72
76
  if (!id) {
73
77
  throw new Error("Invoice ID is required");
74
78
  }
75
79
  return this.client.request({
76
80
  method: "GET",
77
- path: `/v1/invoices/${id}`
81
+ path: `/v1/invoices/${id}`,
82
+ query: { livemode: options.livemode?.toString() }
78
83
  });
79
84
  }
80
85
  async list(args = {}) {
@@ -88,7 +93,8 @@ var InvoiceResource = class {
88
93
  chargeId: args.chargeId,
89
94
  poNumber: args.poNumber,
90
95
  createdAfter: args.createdAfter,
91
- createdBefore: args.createdBefore
96
+ createdBefore: args.createdBefore,
97
+ livemode: args.livemode?.toString()
92
98
  };
93
99
  return this.client.request({
94
100
  method: "GET",
@@ -250,6 +256,8 @@ var CustomerResource = class {
250
256
  async list(args = {}) {
251
257
  const query = {
252
258
  search: args.search,
259
+ createdAfter: args.createdAfter,
260
+ createdBefore: args.createdBefore,
253
261
  limit: args.limit?.toString(),
254
262
  starting_after: args.starting_after,
255
263
  ending_before: args.ending_before
@@ -347,6 +355,9 @@ var CouponResource = class {
347
355
  if (params.appliesToSetupFee !== void 0) {
348
356
  body.appliesToSetupFee = params.appliesToSetupFee;
349
357
  }
358
+ if (params.appliesToTicketFees !== void 0) {
359
+ body.appliesToTicketFees = params.appliesToTicketFees;
360
+ }
350
361
  if (params.pageIds !== void 0) {
351
362
  body.pageIds = params.pageIds;
352
363
  }
@@ -384,20 +395,26 @@ var PaymentResource = class {
384
395
  *
385
396
  * @example
386
397
  * const { data: payment } = await client.payments.get(paymentId);
398
+ *
399
+ * @example
400
+ * // A test payment
401
+ * const { data: testPayment } = await client.payments.get(paymentId, { livemode: false });
387
402
  */
388
- async get(paymentId) {
403
+ async get(paymentId, options = {}) {
389
404
  if (!paymentId) {
390
405
  throw new Error("Payment ID is required");
391
406
  }
392
407
  return this.client.request({
393
408
  method: "GET",
394
- path: `/v1/payments/${paymentId}`
409
+ path: `/v1/payments/${paymentId}`,
410
+ query: { livemode: options.livemode?.toString() }
395
411
  });
396
412
  }
397
413
  async list(args = {}) {
398
414
  const query = {
399
415
  search: args.search,
400
416
  status: args.status,
417
+ orderStatus: args.orderStatus,
401
418
  pageId: args.pageId,
402
419
  customerId: args.customerId,
403
420
  orderId: args.orderId,
@@ -406,6 +423,7 @@ var PaymentResource = class {
406
423
  createdAfter: args.createdAfter,
407
424
  createdBefore: args.createdBefore,
408
425
  abandonmentStatus: args.abandonmentStatus,
426
+ livemode: args.livemode?.toString(),
409
427
  limit: args.limit?.toString(),
410
428
  starting_after: args.starting_after,
411
429
  ending_before: args.ending_before
@@ -428,21 +446,34 @@ var SubscriptionResource = class {
428
446
  *
429
447
  * @example
430
448
  * const { data: subscription } = await client.subscriptions.get(subscriptionId);
449
+ *
450
+ * @example
451
+ * // A test subscription
452
+ * const { data: testSubscription } = await client.subscriptions.get(subscriptionId, {
453
+ * livemode: false,
454
+ * });
431
455
  */
432
- async get(subscriptionId) {
456
+ async get(subscriptionId, options = {}) {
433
457
  if (!subscriptionId) {
434
458
  throw new Error("Subscription ID is required");
435
459
  }
436
460
  return this.client.request({
437
461
  method: "GET",
438
- path: `/v1/subscriptions/${subscriptionId}`
462
+ path: `/v1/subscriptions/${subscriptionId}`,
463
+ query: { livemode: options.livemode?.toString() }
439
464
  });
440
465
  }
441
466
  async list(args = {}) {
442
467
  const query = {
443
468
  search: args.search,
444
469
  pageId: args.pageId,
470
+ customerId: args.customerId,
471
+ orderId: args.orderId,
472
+ createdAfter: args.createdAfter,
473
+ createdBefore: args.createdBefore,
474
+ abandonmentStatus: args.abandonmentStatus,
445
475
  status: args.status,
476
+ livemode: args.livemode?.toString(),
446
477
  limit: args.limit?.toString(),
447
478
  starting_after: args.starting_after,
448
479
  ending_before: args.ending_before
@@ -487,14 +518,21 @@ var SubscriptionPaymentResource = class {
487
518
  *
488
519
  * @example
489
520
  * const { data: payment } = await client.subscriptionPayments.get(paymentId);
521
+ *
522
+ * @example
523
+ * // A test subscription payment
524
+ * const { data: testPayment } = await client.subscriptionPayments.get(paymentId, {
525
+ * livemode: false,
526
+ * });
490
527
  */
491
- async get(subscriptionPaymentId) {
528
+ async get(subscriptionPaymentId, options = {}) {
492
529
  if (!subscriptionPaymentId) {
493
530
  throw new Error("Subscription payment ID is required");
494
531
  }
495
532
  return this.client.request({
496
533
  method: "GET",
497
- path: `/v1/subscription-payments/${subscriptionPaymentId}`
534
+ path: `/v1/subscription-payments/${subscriptionPaymentId}`,
535
+ query: { livemode: options.livemode?.toString() }
498
536
  });
499
537
  }
500
538
  async list(args = {}) {
@@ -510,7 +548,8 @@ var SubscriptionPaymentResource = class {
510
548
  refunded: args.refunded,
511
549
  billingReason: args.billingReason,
512
550
  createdAfter: args.createdAfter,
513
- createdBefore: args.createdBefore
551
+ createdBefore: args.createdBefore,
552
+ livemode: args.livemode?.toString()
514
553
  };
515
554
  return this.client.request({
516
555
  method: "GET",
@@ -525,20 +564,70 @@ var BookingResource = class {
525
564
  constructor(client) {
526
565
  this.client = client;
527
566
  }
567
+ /**
568
+ * Create an event booking without collecting card payment. This is a real
569
+ * booking: tickets are issued, the customer receives a confirmation email
570
+ * with the ticket PDF, live-mode bookings decrement capacity, and booking webhooks fire.
571
+ * There are two ways to settle it. With `paymentOption.manualType` the
572
+ * booking is recorded as `unpaid`, to be settled outside checkout via the
573
+ * chosen manual option; a free booking simply has nothing due. With
574
+ * `complimentary: true` the tickets are issued at no charge: the booking is
575
+ * recorded as `paid` with `amount`, `amountPaid` and `amountDue` of 0 and
576
+ * `isComplimentary: true`, while the ticket lines keep their face value and
577
+ * `complimentaryDiscountAmount` records what they would have cost.
578
+ * `complimentary` is mutually exclusive with `paymentOption` and `couponId`,
579
+ * and one of `paymentOption` or `complimentary` is required.
580
+ *
581
+ * Field entries carry a `fieldId` plus the value. Every required field on
582
+ * the event must be supplied, and a stock event requires name, email and a
583
+ * billing address. The ids come from `GET /v1/events/{eventId}/fields`,
584
+ * which this client does not yet wrap.
585
+ *
586
+ * @example
587
+ * const { data: booking } = await client.bookings.create({
588
+ * eventId,
589
+ * tickets: { [ticketTypeId]: 2 },
590
+ * fields: [
591
+ * { fieldId: emailFieldId, value: 'ada@example.com' },
592
+ * { fieldId: nameFieldId, value: 'Ada Lovelace' },
593
+ * ],
594
+ * paymentOption: { manualType: 'invoice' },
595
+ * });
596
+ *
597
+ * @example
598
+ * const { data: booking } = await client.bookings.create({
599
+ * eventId,
600
+ * tickets: { [ticketTypeId]: 2 },
601
+ * fields: [{ fieldId: emailFieldId, value: 'ada@example.com' }],
602
+ * complimentary: true,
603
+ * });
604
+ */
605
+ async create(params) {
606
+ return this.client.request({
607
+ method: "POST",
608
+ path: "/v1/bookings/",
609
+ body: params
610
+ });
611
+ }
528
612
  /**
529
613
  * Retrieve a single booking by ID. Only event bookings are returned —
530
614
  * a checkout charge is a payment, and 404s here.
531
615
  *
532
616
  * @example
533
617
  * const { data: booking } = await client.bookings.get(bookingId);
618
+ *
619
+ * @example
620
+ * // A test booking
621
+ * const { data: testBooking } = await client.bookings.get(bookingId, { livemode: false });
534
622
  */
535
- async get(bookingId) {
623
+ async get(bookingId, options = {}) {
536
624
  if (!bookingId) {
537
625
  throw new Error("Booking ID is required");
538
626
  }
539
627
  return this.client.request({
540
628
  method: "GET",
541
- path: `/v1/bookings/${bookingId}`
629
+ path: `/v1/bookings/${bookingId}`,
630
+ query: { livemode: options.livemode?.toString() }
542
631
  });
543
632
  }
544
633
  /**
@@ -550,20 +639,26 @@ var BookingResource = class {
550
639
  * @example
551
640
  * const pdf = await client.bookings.downloadTicketPdf(bookingId);
552
641
  * fs.writeFileSync('tickets.pdf', Buffer.from(pdf));
642
+ *
643
+ * @example
644
+ * // The tickets of a test booking
645
+ * const testPdf = await client.bookings.downloadTicketPdf(bookingId, { livemode: false });
553
646
  */
554
- async downloadTicketPdf(bookingId) {
647
+ async downloadTicketPdf(bookingId, options = {}) {
555
648
  if (!bookingId) {
556
649
  throw new Error("Booking ID is required");
557
650
  }
558
651
  return this.client.requestRaw({
559
652
  method: "GET",
560
- path: `/v1/bookings/${bookingId}/ticket-pdf`
653
+ path: `/v1/bookings/${bookingId}/ticket-pdf`,
654
+ query: { livemode: options.livemode?.toString() }
561
655
  });
562
656
  }
563
657
  async list(args = {}) {
564
658
  const query = {
565
659
  search: args.search,
566
660
  status: args.status,
661
+ orderStatus: args.orderStatus,
567
662
  pageId: args.pageId,
568
663
  customerId: args.customerId,
569
664
  orderId: args.orderId,
@@ -571,6 +666,8 @@ var BookingResource = class {
571
666
  createdAfter: args.createdAfter,
572
667
  createdBefore: args.createdBefore,
573
668
  abandonmentStatus: args.abandonmentStatus,
669
+ isComplimentary: args.isComplimentary,
670
+ livemode: args.livemode?.toString(),
574
671
  limit: args.limit?.toString(),
575
672
  starting_after: args.starting_after,
576
673
  ending_before: args.ending_before
@@ -600,6 +697,7 @@ var TicketResource = class {
600
697
  createdAfter: args.createdAfter,
601
698
  createdBefore: args.createdBefore,
602
699
  search: args.search,
700
+ livemode: args.livemode?.toString(),
603
701
  limit: args.limit?.toString(),
604
702
  starting_after: args.starting_after,
605
703
  ending_before: args.ending_before
@@ -646,6 +744,20 @@ var ProductResource = class {
646
744
  constructor(client) {
647
745
  this.client = client;
648
746
  }
747
+ async list(args = {}) {
748
+ const query = {
749
+ limit: args.limit?.toString(),
750
+ starting_after: args.starting_after,
751
+ ending_before: args.ending_before,
752
+ role: args.role,
753
+ search: args.search
754
+ };
755
+ return this.client.request({
756
+ method: "GET",
757
+ path: "/v1/products/",
758
+ query
759
+ });
760
+ }
649
761
  async get(productId) {
650
762
  if (!productId) {
651
763
  throw new Error("Product ID is required");
@@ -702,6 +814,9 @@ var ProductResource = class {
702
814
  if (params.limitSubscriptions !== void 0) {
703
815
  body.limitSubscriptions = params.limitSubscriptions;
704
816
  }
817
+ if (params.limitPayments !== void 0) {
818
+ body.limitPayments = params.limitPayments;
819
+ }
705
820
  if (params.enableFileAccessForInactiveSubscriptions !== void 0) {
706
821
  body.enableFileAccessForInactiveSubscriptions = params.enableFileAccessForInactiveSubscriptions;
707
822
  }
@@ -717,6 +832,9 @@ var ProductResource = class {
717
832
  if (params.defaultPriceId !== void 0) {
718
833
  body.defaultPriceId = params.defaultPriceId;
719
834
  }
835
+ if (params.pricePicker !== void 0) {
836
+ body.pricePicker = params.pricePicker;
837
+ }
720
838
  return this.client.request({
721
839
  method: "PATCH",
722
840
  path: `/v1/products/${productId}`,
@@ -822,11 +940,10 @@ var CheckoutPageFieldsResource = class {
822
940
  if (!fieldId) {
823
941
  throw new Error("Field ID is required");
824
942
  }
825
- const response = await this.client.request({
943
+ return this.client.request({
826
944
  method: "DELETE",
827
945
  path: `/v1/checkout-pages/${pageId}/fields/${fieldId}`
828
946
  });
829
- return response;
830
947
  }
831
948
  };
832
949
  var CheckoutPagesResource = class {
@@ -842,7 +959,8 @@ var CheckoutPagesResource = class {
842
959
  starting_after: args.starting_after,
843
960
  ending_before: args.ending_before,
844
961
  status: args.status,
845
- search: args.search
962
+ search: args.search,
963
+ testmode: args.testmode?.toString()
846
964
  };
847
965
  return this.client.request({
848
966
  method: "GET",
@@ -1102,7 +1220,8 @@ var EventsResource = class {
1102
1220
  starting_after: args.starting_after,
1103
1221
  ending_before: args.ending_before,
1104
1222
  status: args.status,
1105
- search: args.search
1223
+ search: args.search,
1224
+ testmode: args.testmode?.toString()
1106
1225
  };
1107
1226
  return this.client.request({
1108
1227
  method: "GET",
@@ -1221,7 +1340,8 @@ var FormsResource = class {
1221
1340
  starting_after: args.starting_after,
1222
1341
  ending_before: args.ending_before,
1223
1342
  status: args.status,
1224
- search: args.search
1343
+ search: args.search,
1344
+ testmode: args.testmode?.toString()
1225
1345
  };
1226
1346
  return this.client.request({
1227
1347
  method: "GET",
@@ -1271,13 +1391,14 @@ var SubmissionResource = class {
1271
1391
  constructor(client) {
1272
1392
  this.client = client;
1273
1393
  }
1274
- async get(submissionId) {
1394
+ async get(submissionId, options = {}) {
1275
1395
  if (!submissionId) {
1276
1396
  throw new Error("Submission ID is required");
1277
1397
  }
1278
1398
  return this.client.request({
1279
1399
  method: "GET",
1280
- path: `/v1/submissions/${submissionId}`
1400
+ path: `/v1/submissions/${submissionId}`,
1401
+ query: { livemode: options.livemode?.toString() }
1281
1402
  });
1282
1403
  }
1283
1404
  async list(args = {}) {
@@ -1288,6 +1409,7 @@ var SubmissionResource = class {
1288
1409
  status: args.status,
1289
1410
  createdAfter: args.createdAfter,
1290
1411
  createdBefore: args.createdBefore,
1412
+ livemode: args.livemode?.toString(),
1291
1413
  limit: args.limit?.toString(),
1292
1414
  starting_after: args.starting_after,
1293
1415
  ending_before: args.ending_before
@@ -1343,6 +1465,16 @@ var TaxRateResource = class {
1343
1465
  body
1344
1466
  });
1345
1467
  }
1468
+ /** Removes the rate from list(); pages and products that used it stop charging that tax. */
1469
+ async delete(taxRateId) {
1470
+ if (!taxRateId) {
1471
+ throw new Error("Tax rate ID is required");
1472
+ }
1473
+ return this.client.request({
1474
+ method: "DELETE",
1475
+ path: `/v1/tax-rates/${taxRateId}`
1476
+ });
1477
+ }
1346
1478
  };
1347
1479
 
1348
1480
  // src/resources/webhooks/webhooks.ts
@@ -1391,6 +1523,45 @@ var WebhookResource = class {
1391
1523
  body: params
1392
1524
  });
1393
1525
  }
1526
+ /**
1527
+ * Retrieve a webhook endpoint by id, with its events, status and delivery
1528
+ * counters. The signing `secret` is not returned.
1529
+ *
1530
+ * @example
1531
+ * const { data: webhook } = await client.webhooks.get('6a1f0c2e9b1d4a0012345678');
1532
+ */
1533
+ async get(webhookId) {
1534
+ if (!webhookId) {
1535
+ throw new Error("Webhook ID is required");
1536
+ }
1537
+ return this.client.request({
1538
+ method: "GET",
1539
+ path: `/v1/webhooks/${encodeURIComponent(webhookId)}`
1540
+ });
1541
+ }
1542
+ /**
1543
+ * Update a webhook endpoint. Only the fields you send change; `events` and
1544
+ * `customHeaders` replace the existing values. Set `status` to `'inactive'`
1545
+ * to pause deliveries and `'active'` to resume. A new `url` must use https
1546
+ * and must not already be registered on another of your webhooks. The
1547
+ * signing secret cannot be changed here.
1548
+ *
1549
+ * @example
1550
+ * const { data: webhook } = await client.webhooks.update(webhookId, {
1551
+ * events: ['payment.paid', 'checkout_page.updated'],
1552
+ * status: 'inactive',
1553
+ * });
1554
+ */
1555
+ async update(webhookId, params) {
1556
+ if (!webhookId) {
1557
+ throw new Error("Webhook ID is required");
1558
+ }
1559
+ return this.client.request({
1560
+ method: "PATCH",
1561
+ path: `/v1/webhooks/${encodeURIComponent(webhookId)}`,
1562
+ body: params
1563
+ });
1564
+ }
1394
1565
  /**
1395
1566
  * Delete a webhook endpoint. Deliveries stop immediately; the returned
1396
1567
  * object is its final state. The webhook no longer appears in `list()`,
@@ -1407,6 +1578,105 @@ var WebhookResource = class {
1407
1578
  }
1408
1579
  };
1409
1580
 
1581
+ // src/resources/themes/themes.ts
1582
+ var ThemeResource = class {
1583
+ constructor(client) {
1584
+ this.client = client;
1585
+ }
1586
+ /**
1587
+ * List the themes your pages can use, newest first: your own themes and the
1588
+ * built-in (`global`) ones. A retired built-in theme is only listed while one
1589
+ * of your pages uses it.
1590
+ *
1591
+ * @example
1592
+ * const { data: themes, has_more } = await client.themes.list({ scope: 'seller' });
1593
+ */
1594
+ async list(args = {}) {
1595
+ const query = {
1596
+ scope: args.scope,
1597
+ limit: args.limit?.toString(),
1598
+ starting_after: args.starting_after,
1599
+ ending_before: args.ending_before
1600
+ };
1601
+ return this.client.request({
1602
+ method: "GET",
1603
+ path: "/v1/themes/",
1604
+ query
1605
+ });
1606
+ }
1607
+ /**
1608
+ * Retrieve one of your themes or a built-in theme.
1609
+ *
1610
+ * @example
1611
+ * const { data: theme } = await client.themes.get(themeId);
1612
+ */
1613
+ async get(themeId) {
1614
+ if (!themeId) {
1615
+ throw new Error("Theme ID is required");
1616
+ }
1617
+ return this.client.request({
1618
+ method: "GET",
1619
+ path: `/v1/themes/${encodeURIComponent(themeId)}`
1620
+ });
1621
+ }
1622
+ /**
1623
+ * Create a theme. Pass `baseThemeId` to start from a copy of one of your
1624
+ * themes or a built-in theme, then set what should differ in `variables`.
1625
+ * `variables` takes the same shape as a page's `themeOverrides`. A copy of a
1626
+ * built-in theme does not follow your store's brand colour, so set
1627
+ * `tokens.colorPrimary` if you want it.
1628
+ *
1629
+ * @example
1630
+ * const { data: theme } = await client.themes.create({
1631
+ * name: 'Brand',
1632
+ * baseThemeId: builtInThemeId,
1633
+ * variables: { tokens: { colorPrimary: { light: '#4f46e5' } } },
1634
+ * });
1635
+ */
1636
+ async create(params) {
1637
+ return this.client.request({
1638
+ method: "POST",
1639
+ path: "/v1/themes/",
1640
+ body: params
1641
+ });
1642
+ }
1643
+ /**
1644
+ * Update one of your themes. Every page that uses it changes too. Keys left
1645
+ * out of `variables` keep their value, and `null` resets a property or
1646
+ * everything under a key. Built-in themes are read-only.
1647
+ *
1648
+ * @example
1649
+ * const { data: theme } = await client.themes.update(themeId, {
1650
+ * variables: { tokens: { colorPrimary: { light: '#0f766e' } } },
1651
+ * });
1652
+ */
1653
+ async update(themeId, params) {
1654
+ if (!themeId) {
1655
+ throw new Error("Theme ID is required");
1656
+ }
1657
+ return this.client.request({
1658
+ method: "PATCH",
1659
+ path: `/v1/themes/${encodeURIComponent(themeId)}`,
1660
+ body: params
1661
+ });
1662
+ }
1663
+ /**
1664
+ * Delete one of your themes and return its final state. A theme that any of
1665
+ * your pages uses, archived ones included, or that is your store's default
1666
+ * theme, can't be deleted (a `ConflictError`): move those pages to another
1667
+ * theme with `themeId` first.
1668
+ */
1669
+ async delete(themeId) {
1670
+ if (!themeId) {
1671
+ throw new Error("Theme ID is required");
1672
+ }
1673
+ return this.client.request({
1674
+ method: "DELETE",
1675
+ path: `/v1/themes/${encodeURIComponent(themeId)}`
1676
+ });
1677
+ }
1678
+ };
1679
+
1410
1680
  // src/index.ts
1411
1681
  var CheckoutPageClient = class {
1412
1682
  accounts;
@@ -1426,6 +1696,7 @@ var CheckoutPageClient = class {
1426
1696
  taxRates;
1427
1697
  invoices;
1428
1698
  webhooks;
1699
+ themes;
1429
1700
  client;
1430
1701
  constructor(options) {
1431
1702
  this.client = new CheckoutPageApiClient(options);
@@ -1446,6 +1717,7 @@ var CheckoutPageClient = class {
1446
1717
  this.taxRates = new TaxRateResource(this.client);
1447
1718
  this.invoices = new InvoiceResource(this.client);
1448
1719
  this.webhooks = new WebhookResource(this.client);
1720
+ this.themes = new ThemeResource(this.client);
1449
1721
  }
1450
1722
  };
1451
1723
  var createCheckoutPageClient = (options) => {