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