@checkoutpage/sdk 0.1.31 → 0.1.33
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/README.md +334 -2
- package/dist/index.d.mts +15290 -5286
- package/dist/index.d.ts +15290 -5286
- package/dist/index.js +421 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +421 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
|
@@ -315,8 +323,10 @@ var CouponResource = class {
|
|
|
315
323
|
/**
|
|
316
324
|
* Update an existing coupon. Only the fields you supply are changed.
|
|
317
325
|
*
|
|
318
|
-
* `
|
|
319
|
-
*
|
|
326
|
+
* `rules` replaces every stored rule rather than merging; an empty list makes
|
|
327
|
+
* the coupon work on every checkout page and event. `pageIds` and
|
|
328
|
+
* `ticketTypeIds` are deprecated: they are accepted only without `rules`, and
|
|
329
|
+
* the API refuses them with a 400 when the coupon has rules they can't express.
|
|
320
330
|
*
|
|
321
331
|
* The discount itself (`code`, `amountOff`, `percentOff`, `currency`,
|
|
322
332
|
* `duration`) is fixed once the coupon is mirrored into Stripe. To change a
|
|
@@ -335,6 +345,24 @@ var CouponResource = class {
|
|
|
335
345
|
body: params
|
|
336
346
|
});
|
|
337
347
|
}
|
|
348
|
+
/**
|
|
349
|
+
* Create a coupon. `rules` says where it works and what it discounts, one rule
|
|
350
|
+
* per checkout page or event; omit it for a coupon that discounts the whole
|
|
351
|
+
* order everywhere. `pageIds` and `ticketTypeIds` are deprecated in favour of
|
|
352
|
+
* `rules` and cannot be sent with it.
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
* await client.coupons.create({
|
|
356
|
+
* type: 'percent',
|
|
357
|
+
* label: 'Monthly plus workbook',
|
|
358
|
+
* code: 'BUNDLE20',
|
|
359
|
+
* percentOff: 20,
|
|
360
|
+
* duration: 'once',
|
|
361
|
+
* rules: [
|
|
362
|
+
* { pageId, appliesTo: 'pricesAndBumps', priceIds: [monthlyPriceId], bumpProductIds: [workbookId] },
|
|
363
|
+
* ],
|
|
364
|
+
* });
|
|
365
|
+
*/
|
|
338
366
|
async create(params) {
|
|
339
367
|
const body = {
|
|
340
368
|
label: params.label,
|
|
@@ -347,6 +375,12 @@ var CouponResource = class {
|
|
|
347
375
|
if (params.appliesToSetupFee !== void 0) {
|
|
348
376
|
body.appliesToSetupFee = params.appliesToSetupFee;
|
|
349
377
|
}
|
|
378
|
+
if (params.appliesToTicketFees !== void 0) {
|
|
379
|
+
body.appliesToTicketFees = params.appliesToTicketFees;
|
|
380
|
+
}
|
|
381
|
+
if (params.rules !== void 0) {
|
|
382
|
+
body.rules = params.rules;
|
|
383
|
+
}
|
|
350
384
|
if (params.pageIds !== void 0) {
|
|
351
385
|
body.pageIds = params.pageIds;
|
|
352
386
|
}
|
|
@@ -384,20 +418,26 @@ var PaymentResource = class {
|
|
|
384
418
|
*
|
|
385
419
|
* @example
|
|
386
420
|
* const { data: payment } = await client.payments.get(paymentId);
|
|
421
|
+
*
|
|
422
|
+
* @example
|
|
423
|
+
* // A test payment
|
|
424
|
+
* const { data: testPayment } = await client.payments.get(paymentId, { livemode: false });
|
|
387
425
|
*/
|
|
388
|
-
async get(paymentId) {
|
|
426
|
+
async get(paymentId, options = {}) {
|
|
389
427
|
if (!paymentId) {
|
|
390
428
|
throw new Error("Payment ID is required");
|
|
391
429
|
}
|
|
392
430
|
return this.client.request({
|
|
393
431
|
method: "GET",
|
|
394
|
-
path: `/v1/payments/${paymentId}
|
|
432
|
+
path: `/v1/payments/${paymentId}`,
|
|
433
|
+
query: { livemode: options.livemode?.toString() }
|
|
395
434
|
});
|
|
396
435
|
}
|
|
397
436
|
async list(args = {}) {
|
|
398
437
|
const query = {
|
|
399
438
|
search: args.search,
|
|
400
439
|
status: args.status,
|
|
440
|
+
orderStatus: args.orderStatus,
|
|
401
441
|
pageId: args.pageId,
|
|
402
442
|
customerId: args.customerId,
|
|
403
443
|
orderId: args.orderId,
|
|
@@ -406,6 +446,7 @@ var PaymentResource = class {
|
|
|
406
446
|
createdAfter: args.createdAfter,
|
|
407
447
|
createdBefore: args.createdBefore,
|
|
408
448
|
abandonmentStatus: args.abandonmentStatus,
|
|
449
|
+
livemode: args.livemode?.toString(),
|
|
409
450
|
limit: args.limit?.toString(),
|
|
410
451
|
starting_after: args.starting_after,
|
|
411
452
|
ending_before: args.ending_before
|
|
@@ -428,21 +469,34 @@ var SubscriptionResource = class {
|
|
|
428
469
|
*
|
|
429
470
|
* @example
|
|
430
471
|
* const { data: subscription } = await client.subscriptions.get(subscriptionId);
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* // A test subscription
|
|
475
|
+
* const { data: testSubscription } = await client.subscriptions.get(subscriptionId, {
|
|
476
|
+
* livemode: false,
|
|
477
|
+
* });
|
|
431
478
|
*/
|
|
432
|
-
async get(subscriptionId) {
|
|
479
|
+
async get(subscriptionId, options = {}) {
|
|
433
480
|
if (!subscriptionId) {
|
|
434
481
|
throw new Error("Subscription ID is required");
|
|
435
482
|
}
|
|
436
483
|
return this.client.request({
|
|
437
484
|
method: "GET",
|
|
438
|
-
path: `/v1/subscriptions/${subscriptionId}
|
|
485
|
+
path: `/v1/subscriptions/${subscriptionId}`,
|
|
486
|
+
query: { livemode: options.livemode?.toString() }
|
|
439
487
|
});
|
|
440
488
|
}
|
|
441
489
|
async list(args = {}) {
|
|
442
490
|
const query = {
|
|
443
491
|
search: args.search,
|
|
444
492
|
pageId: args.pageId,
|
|
493
|
+
customerId: args.customerId,
|
|
494
|
+
orderId: args.orderId,
|
|
495
|
+
createdAfter: args.createdAfter,
|
|
496
|
+
createdBefore: args.createdBefore,
|
|
497
|
+
abandonmentStatus: args.abandonmentStatus,
|
|
445
498
|
status: args.status,
|
|
499
|
+
livemode: args.livemode?.toString(),
|
|
446
500
|
limit: args.limit?.toString(),
|
|
447
501
|
starting_after: args.starting_after,
|
|
448
502
|
ending_before: args.ending_before
|
|
@@ -487,14 +541,21 @@ var SubscriptionPaymentResource = class {
|
|
|
487
541
|
*
|
|
488
542
|
* @example
|
|
489
543
|
* const { data: payment } = await client.subscriptionPayments.get(paymentId);
|
|
544
|
+
*
|
|
545
|
+
* @example
|
|
546
|
+
* // A test subscription payment
|
|
547
|
+
* const { data: testPayment } = await client.subscriptionPayments.get(paymentId, {
|
|
548
|
+
* livemode: false,
|
|
549
|
+
* });
|
|
490
550
|
*/
|
|
491
|
-
async get(subscriptionPaymentId) {
|
|
551
|
+
async get(subscriptionPaymentId, options = {}) {
|
|
492
552
|
if (!subscriptionPaymentId) {
|
|
493
553
|
throw new Error("Subscription payment ID is required");
|
|
494
554
|
}
|
|
495
555
|
return this.client.request({
|
|
496
556
|
method: "GET",
|
|
497
|
-
path: `/v1/subscription-payments/${subscriptionPaymentId}
|
|
557
|
+
path: `/v1/subscription-payments/${subscriptionPaymentId}`,
|
|
558
|
+
query: { livemode: options.livemode?.toString() }
|
|
498
559
|
});
|
|
499
560
|
}
|
|
500
561
|
async list(args = {}) {
|
|
@@ -510,7 +571,8 @@ var SubscriptionPaymentResource = class {
|
|
|
510
571
|
refunded: args.refunded,
|
|
511
572
|
billingReason: args.billingReason,
|
|
512
573
|
createdAfter: args.createdAfter,
|
|
513
|
-
createdBefore: args.createdBefore
|
|
574
|
+
createdBefore: args.createdBefore,
|
|
575
|
+
livemode: args.livemode?.toString()
|
|
514
576
|
};
|
|
515
577
|
return this.client.request({
|
|
516
578
|
method: "GET",
|
|
@@ -525,20 +587,70 @@ var BookingResource = class {
|
|
|
525
587
|
constructor(client) {
|
|
526
588
|
this.client = client;
|
|
527
589
|
}
|
|
590
|
+
/**
|
|
591
|
+
* Create an event booking without collecting card payment. This is a real
|
|
592
|
+
* booking: tickets are issued, the customer receives a confirmation email
|
|
593
|
+
* with the ticket PDF, live-mode bookings decrement capacity, and booking webhooks fire.
|
|
594
|
+
* There are two ways to settle it. With `paymentOption.manualType` the
|
|
595
|
+
* booking is recorded as `unpaid`, to be settled outside checkout via the
|
|
596
|
+
* chosen manual option; a free booking simply has nothing due. With
|
|
597
|
+
* `complimentary: true` the tickets are issued at no charge: the booking is
|
|
598
|
+
* recorded as `paid` with `amount`, `amountPaid` and `amountDue` of 0 and
|
|
599
|
+
* `isComplimentary: true`, while the ticket lines keep their face value and
|
|
600
|
+
* `complimentaryDiscountAmount` records what they would have cost.
|
|
601
|
+
* `complimentary` is mutually exclusive with `paymentOption` and `couponId`,
|
|
602
|
+
* and one of `paymentOption` or `complimentary` is required.
|
|
603
|
+
*
|
|
604
|
+
* Field entries carry a `fieldId` plus the value. Every required field on
|
|
605
|
+
* the event must be supplied, and a stock event requires name, email and a
|
|
606
|
+
* billing address. The ids come from `GET /v1/events/{eventId}/fields`,
|
|
607
|
+
* which this client does not yet wrap.
|
|
608
|
+
*
|
|
609
|
+
* @example
|
|
610
|
+
* const { data: booking } = await client.bookings.create({
|
|
611
|
+
* eventId,
|
|
612
|
+
* tickets: { [ticketTypeId]: 2 },
|
|
613
|
+
* fields: [
|
|
614
|
+
* { fieldId: emailFieldId, value: 'ada@example.com' },
|
|
615
|
+
* { fieldId: nameFieldId, value: 'Ada Lovelace' },
|
|
616
|
+
* ],
|
|
617
|
+
* paymentOption: { manualType: 'invoice' },
|
|
618
|
+
* });
|
|
619
|
+
*
|
|
620
|
+
* @example
|
|
621
|
+
* const { data: booking } = await client.bookings.create({
|
|
622
|
+
* eventId,
|
|
623
|
+
* tickets: { [ticketTypeId]: 2 },
|
|
624
|
+
* fields: [{ fieldId: emailFieldId, value: 'ada@example.com' }],
|
|
625
|
+
* complimentary: true,
|
|
626
|
+
* });
|
|
627
|
+
*/
|
|
628
|
+
async create(params) {
|
|
629
|
+
return this.client.request({
|
|
630
|
+
method: "POST",
|
|
631
|
+
path: "/v1/bookings/",
|
|
632
|
+
body: params
|
|
633
|
+
});
|
|
634
|
+
}
|
|
528
635
|
/**
|
|
529
636
|
* Retrieve a single booking by ID. Only event bookings are returned —
|
|
530
637
|
* a checkout charge is a payment, and 404s here.
|
|
531
638
|
*
|
|
532
639
|
* @example
|
|
533
640
|
* const { data: booking } = await client.bookings.get(bookingId);
|
|
641
|
+
*
|
|
642
|
+
* @example
|
|
643
|
+
* // A test booking
|
|
644
|
+
* const { data: testBooking } = await client.bookings.get(bookingId, { livemode: false });
|
|
534
645
|
*/
|
|
535
|
-
async get(bookingId) {
|
|
646
|
+
async get(bookingId, options = {}) {
|
|
536
647
|
if (!bookingId) {
|
|
537
648
|
throw new Error("Booking ID is required");
|
|
538
649
|
}
|
|
539
650
|
return this.client.request({
|
|
540
651
|
method: "GET",
|
|
541
|
-
path: `/v1/bookings/${bookingId}
|
|
652
|
+
path: `/v1/bookings/${bookingId}`,
|
|
653
|
+
query: { livemode: options.livemode?.toString() }
|
|
542
654
|
});
|
|
543
655
|
}
|
|
544
656
|
/**
|
|
@@ -550,20 +662,26 @@ var BookingResource = class {
|
|
|
550
662
|
* @example
|
|
551
663
|
* const pdf = await client.bookings.downloadTicketPdf(bookingId);
|
|
552
664
|
* fs.writeFileSync('tickets.pdf', Buffer.from(pdf));
|
|
665
|
+
*
|
|
666
|
+
* @example
|
|
667
|
+
* // The tickets of a test booking
|
|
668
|
+
* const testPdf = await client.bookings.downloadTicketPdf(bookingId, { livemode: false });
|
|
553
669
|
*/
|
|
554
|
-
async downloadTicketPdf(bookingId) {
|
|
670
|
+
async downloadTicketPdf(bookingId, options = {}) {
|
|
555
671
|
if (!bookingId) {
|
|
556
672
|
throw new Error("Booking ID is required");
|
|
557
673
|
}
|
|
558
674
|
return this.client.requestRaw({
|
|
559
675
|
method: "GET",
|
|
560
|
-
path: `/v1/bookings/${bookingId}/ticket-pdf
|
|
676
|
+
path: `/v1/bookings/${bookingId}/ticket-pdf`,
|
|
677
|
+
query: { livemode: options.livemode?.toString() }
|
|
561
678
|
});
|
|
562
679
|
}
|
|
563
680
|
async list(args = {}) {
|
|
564
681
|
const query = {
|
|
565
682
|
search: args.search,
|
|
566
683
|
status: args.status,
|
|
684
|
+
orderStatus: args.orderStatus,
|
|
567
685
|
pageId: args.pageId,
|
|
568
686
|
customerId: args.customerId,
|
|
569
687
|
orderId: args.orderId,
|
|
@@ -571,6 +689,8 @@ var BookingResource = class {
|
|
|
571
689
|
createdAfter: args.createdAfter,
|
|
572
690
|
createdBefore: args.createdBefore,
|
|
573
691
|
abandonmentStatus: args.abandonmentStatus,
|
|
692
|
+
isComplimentary: args.isComplimentary,
|
|
693
|
+
livemode: args.livemode?.toString(),
|
|
574
694
|
limit: args.limit?.toString(),
|
|
575
695
|
starting_after: args.starting_after,
|
|
576
696
|
ending_before: args.ending_before
|
|
@@ -600,6 +720,7 @@ var TicketResource = class {
|
|
|
600
720
|
createdAfter: args.createdAfter,
|
|
601
721
|
createdBefore: args.createdBefore,
|
|
602
722
|
search: args.search,
|
|
723
|
+
livemode: args.livemode?.toString(),
|
|
603
724
|
limit: args.limit?.toString(),
|
|
604
725
|
starting_after: args.starting_after,
|
|
605
726
|
ending_before: args.ending_before
|
|
@@ -642,10 +763,59 @@ var TicketResource = class {
|
|
|
642
763
|
};
|
|
643
764
|
|
|
644
765
|
// src/resources/products/products.ts
|
|
766
|
+
var ORDER_BUMP_CARD_FIELDS = [
|
|
767
|
+
"shortDescription",
|
|
768
|
+
"callToActionText",
|
|
769
|
+
"headingText",
|
|
770
|
+
"features",
|
|
771
|
+
"calloutText",
|
|
772
|
+
"calloutIcon"
|
|
773
|
+
];
|
|
645
774
|
var ProductResource = class {
|
|
646
775
|
constructor(client) {
|
|
647
776
|
this.client = client;
|
|
648
777
|
}
|
|
778
|
+
async list(args = {}) {
|
|
779
|
+
const query = {
|
|
780
|
+
limit: args.limit?.toString(),
|
|
781
|
+
starting_after: args.starting_after,
|
|
782
|
+
ending_before: args.ending_before,
|
|
783
|
+
role: args.role,
|
|
784
|
+
search: args.search
|
|
785
|
+
};
|
|
786
|
+
return this.client.request({
|
|
787
|
+
method: "GET",
|
|
788
|
+
path: "/v1/products/",
|
|
789
|
+
query
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Creates an order bump product (`role: 'orderbump'`). Order bump products use
|
|
794
|
+
* a single one-time price; page products are created with their page.
|
|
795
|
+
*/
|
|
796
|
+
async create(params) {
|
|
797
|
+
return this.client.request({
|
|
798
|
+
method: "POST",
|
|
799
|
+
path: "/v1/products/",
|
|
800
|
+
body: params
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Deletes an order bump product that has never been bought. Pass
|
|
805
|
+
* `fromAllPages: true` to remove it from the pages offering it first.
|
|
806
|
+
*/
|
|
807
|
+
async delete(productId, options = {}) {
|
|
808
|
+
if (!productId) {
|
|
809
|
+
throw new Error("Product ID is required");
|
|
810
|
+
}
|
|
811
|
+
return this.client.request({
|
|
812
|
+
method: "DELETE",
|
|
813
|
+
path: `/v1/products/${productId}`,
|
|
814
|
+
query: {
|
|
815
|
+
fromAllPages: options.fromAllPages === void 0 ? void 0 : String(options.fromAllPages)
|
|
816
|
+
}
|
|
817
|
+
});
|
|
818
|
+
}
|
|
649
819
|
async get(productId) {
|
|
650
820
|
if (!productId) {
|
|
651
821
|
throw new Error("Product ID is required");
|
|
@@ -702,6 +872,9 @@ var ProductResource = class {
|
|
|
702
872
|
if (params.limitSubscriptions !== void 0) {
|
|
703
873
|
body.limitSubscriptions = params.limitSubscriptions;
|
|
704
874
|
}
|
|
875
|
+
if (params.limitPayments !== void 0) {
|
|
876
|
+
body.limitPayments = params.limitPayments;
|
|
877
|
+
}
|
|
705
878
|
if (params.enableFileAccessForInactiveSubscriptions !== void 0) {
|
|
706
879
|
body.enableFileAccessForInactiveSubscriptions = params.enableFileAccessForInactiveSubscriptions;
|
|
707
880
|
}
|
|
@@ -717,6 +890,14 @@ var ProductResource = class {
|
|
|
717
890
|
if (params.defaultPriceId !== void 0) {
|
|
718
891
|
body.defaultPriceId = params.defaultPriceId;
|
|
719
892
|
}
|
|
893
|
+
if (params.pricePicker !== void 0) {
|
|
894
|
+
body.pricePicker = params.pricePicker;
|
|
895
|
+
}
|
|
896
|
+
for (const field of ORDER_BUMP_CARD_FIELDS) {
|
|
897
|
+
if (params[field] !== void 0) {
|
|
898
|
+
body[field] = params[field];
|
|
899
|
+
}
|
|
900
|
+
}
|
|
720
901
|
return this.client.request({
|
|
721
902
|
method: "PATCH",
|
|
722
903
|
path: `/v1/products/${productId}`,
|
|
@@ -766,6 +947,66 @@ var FileResource = class {
|
|
|
766
947
|
}
|
|
767
948
|
};
|
|
768
949
|
|
|
950
|
+
// src/resources/order-bumps/order-bumps.ts
|
|
951
|
+
var OrderBumpsResource = class {
|
|
952
|
+
constructor(client, pageResource) {
|
|
953
|
+
this.client = client;
|
|
954
|
+
this.pageResource = pageResource;
|
|
955
|
+
}
|
|
956
|
+
basePath(pageId) {
|
|
957
|
+
if (!pageId) {
|
|
958
|
+
throw new Error("Page ID is required");
|
|
959
|
+
}
|
|
960
|
+
return `/v1/${this.pageResource}/${pageId}/order-bumps`;
|
|
961
|
+
}
|
|
962
|
+
/** Lists the order bumps on the page in display order, including unavailable ones. */
|
|
963
|
+
async list(pageId) {
|
|
964
|
+
return this.client.request({
|
|
965
|
+
method: "GET",
|
|
966
|
+
path: this.basePath(pageId)
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
/** Offers an order bump product on the page. It is added last. */
|
|
970
|
+
async create(pageId, params) {
|
|
971
|
+
return this.client.request({
|
|
972
|
+
method: "POST",
|
|
973
|
+
path: this.basePath(pageId),
|
|
974
|
+
body: params
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
/** Updates how the order bump is offered on the page. `showHideLogic` is replaced whole. */
|
|
978
|
+
async update(pageId, productId, params) {
|
|
979
|
+
const path = this.basePath(pageId);
|
|
980
|
+
if (!productId) {
|
|
981
|
+
throw new Error("Product ID is required");
|
|
982
|
+
}
|
|
983
|
+
return this.client.request({
|
|
984
|
+
method: "PATCH",
|
|
985
|
+
path: `${path}/${productId}`,
|
|
986
|
+
body: params
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
/** Stops offering the order bump on the page. The product is kept. */
|
|
990
|
+
async delete(pageId, productId) {
|
|
991
|
+
const path = this.basePath(pageId);
|
|
992
|
+
if (!productId) {
|
|
993
|
+
throw new Error("Product ID is required");
|
|
994
|
+
}
|
|
995
|
+
return this.client.request({
|
|
996
|
+
method: "DELETE",
|
|
997
|
+
path: `${path}/${productId}`
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
/** Sets the display order. `productIds` must list every order bump on the page exactly once. */
|
|
1001
|
+
async reorder(pageId, params) {
|
|
1002
|
+
return this.client.request({
|
|
1003
|
+
method: "POST",
|
|
1004
|
+
path: `${this.basePath(pageId)}/reorder`,
|
|
1005
|
+
body: params
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
};
|
|
1009
|
+
|
|
769
1010
|
// src/resources/checkout-pages/checkout-pages.ts
|
|
770
1011
|
var CheckoutPageFieldsResource = class {
|
|
771
1012
|
constructor(client) {
|
|
@@ -830,10 +1071,12 @@ var CheckoutPageFieldsResource = class {
|
|
|
830
1071
|
};
|
|
831
1072
|
var CheckoutPagesResource = class {
|
|
832
1073
|
fields;
|
|
1074
|
+
orderBumps;
|
|
833
1075
|
client;
|
|
834
1076
|
constructor(client) {
|
|
835
1077
|
this.client = client;
|
|
836
1078
|
this.fields = new CheckoutPageFieldsResource(client);
|
|
1079
|
+
this.orderBumps = new OrderBumpsResource(client, "checkout-pages");
|
|
837
1080
|
}
|
|
838
1081
|
async list(args = {}) {
|
|
839
1082
|
const query = {
|
|
@@ -841,7 +1084,8 @@ var CheckoutPagesResource = class {
|
|
|
841
1084
|
starting_after: args.starting_after,
|
|
842
1085
|
ending_before: args.ending_before,
|
|
843
1086
|
status: args.status,
|
|
844
|
-
search: args.search
|
|
1087
|
+
search: args.search,
|
|
1088
|
+
testmode: args.testmode?.toString()
|
|
845
1089
|
};
|
|
846
1090
|
return this.client.request({
|
|
847
1091
|
method: "GET",
|
|
@@ -1092,16 +1336,19 @@ var EventsResource = class {
|
|
|
1092
1336
|
this.client = client;
|
|
1093
1337
|
this.ticketGroups = new EventTicketGroupsResource(client);
|
|
1094
1338
|
this.fields = new EventFieldsResource(client);
|
|
1339
|
+
this.orderBumps = new OrderBumpsResource(client, "events");
|
|
1095
1340
|
}
|
|
1096
1341
|
ticketGroups;
|
|
1097
1342
|
fields;
|
|
1343
|
+
orderBumps;
|
|
1098
1344
|
async list(args = {}) {
|
|
1099
1345
|
const query = {
|
|
1100
1346
|
limit: args.limit?.toString(),
|
|
1101
1347
|
starting_after: args.starting_after,
|
|
1102
1348
|
ending_before: args.ending_before,
|
|
1103
1349
|
status: args.status,
|
|
1104
|
-
search: args.search
|
|
1350
|
+
search: args.search,
|
|
1351
|
+
testmode: args.testmode?.toString()
|
|
1105
1352
|
};
|
|
1106
1353
|
return this.client.request({
|
|
1107
1354
|
method: "GET",
|
|
@@ -1220,7 +1467,8 @@ var FormsResource = class {
|
|
|
1220
1467
|
starting_after: args.starting_after,
|
|
1221
1468
|
ending_before: args.ending_before,
|
|
1222
1469
|
status: args.status,
|
|
1223
|
-
search: args.search
|
|
1470
|
+
search: args.search,
|
|
1471
|
+
testmode: args.testmode?.toString()
|
|
1224
1472
|
};
|
|
1225
1473
|
return this.client.request({
|
|
1226
1474
|
method: "GET",
|
|
@@ -1270,13 +1518,14 @@ var SubmissionResource = class {
|
|
|
1270
1518
|
constructor(client) {
|
|
1271
1519
|
this.client = client;
|
|
1272
1520
|
}
|
|
1273
|
-
async get(submissionId) {
|
|
1521
|
+
async get(submissionId, options = {}) {
|
|
1274
1522
|
if (!submissionId) {
|
|
1275
1523
|
throw new Error("Submission ID is required");
|
|
1276
1524
|
}
|
|
1277
1525
|
return this.client.request({
|
|
1278
1526
|
method: "GET",
|
|
1279
|
-
path: `/v1/submissions/${submissionId}
|
|
1527
|
+
path: `/v1/submissions/${submissionId}`,
|
|
1528
|
+
query: { livemode: options.livemode?.toString() }
|
|
1280
1529
|
});
|
|
1281
1530
|
}
|
|
1282
1531
|
async list(args = {}) {
|
|
@@ -1287,6 +1536,7 @@ var SubmissionResource = class {
|
|
|
1287
1536
|
status: args.status,
|
|
1288
1537
|
createdAfter: args.createdAfter,
|
|
1289
1538
|
createdBefore: args.createdBefore,
|
|
1539
|
+
livemode: args.livemode?.toString(),
|
|
1290
1540
|
limit: args.limit?.toString(),
|
|
1291
1541
|
starting_after: args.starting_after,
|
|
1292
1542
|
ending_before: args.ending_before
|
|
@@ -1342,6 +1592,16 @@ var TaxRateResource = class {
|
|
|
1342
1592
|
body
|
|
1343
1593
|
});
|
|
1344
1594
|
}
|
|
1595
|
+
/** Removes the rate from list(); pages and products that used it stop charging that tax. */
|
|
1596
|
+
async delete(taxRateId) {
|
|
1597
|
+
if (!taxRateId) {
|
|
1598
|
+
throw new Error("Tax rate ID is required");
|
|
1599
|
+
}
|
|
1600
|
+
return this.client.request({
|
|
1601
|
+
method: "DELETE",
|
|
1602
|
+
path: `/v1/tax-rates/${taxRateId}`
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1345
1605
|
};
|
|
1346
1606
|
|
|
1347
1607
|
// src/resources/webhooks/webhooks.ts
|
|
@@ -1390,6 +1650,45 @@ var WebhookResource = class {
|
|
|
1390
1650
|
body: params
|
|
1391
1651
|
});
|
|
1392
1652
|
}
|
|
1653
|
+
/**
|
|
1654
|
+
* Retrieve a webhook endpoint by id, with its events, status and delivery
|
|
1655
|
+
* counters. The signing `secret` is not returned.
|
|
1656
|
+
*
|
|
1657
|
+
* @example
|
|
1658
|
+
* const { data: webhook } = await client.webhooks.get('6a1f0c2e9b1d4a0012345678');
|
|
1659
|
+
*/
|
|
1660
|
+
async get(webhookId) {
|
|
1661
|
+
if (!webhookId) {
|
|
1662
|
+
throw new Error("Webhook ID is required");
|
|
1663
|
+
}
|
|
1664
|
+
return this.client.request({
|
|
1665
|
+
method: "GET",
|
|
1666
|
+
path: `/v1/webhooks/${encodeURIComponent(webhookId)}`
|
|
1667
|
+
});
|
|
1668
|
+
}
|
|
1669
|
+
/**
|
|
1670
|
+
* Update a webhook endpoint. Only the fields you send change; `events` and
|
|
1671
|
+
* `customHeaders` replace the existing values. Set `status` to `'inactive'`
|
|
1672
|
+
* to pause deliveries and `'active'` to resume. A new `url` must use https
|
|
1673
|
+
* and must not already be registered on another of your webhooks. The
|
|
1674
|
+
* signing secret cannot be changed here.
|
|
1675
|
+
*
|
|
1676
|
+
* @example
|
|
1677
|
+
* const { data: webhook } = await client.webhooks.update(webhookId, {
|
|
1678
|
+
* events: ['payment.paid', 'checkout_page.updated'],
|
|
1679
|
+
* status: 'inactive',
|
|
1680
|
+
* });
|
|
1681
|
+
*/
|
|
1682
|
+
async update(webhookId, params) {
|
|
1683
|
+
if (!webhookId) {
|
|
1684
|
+
throw new Error("Webhook ID is required");
|
|
1685
|
+
}
|
|
1686
|
+
return this.client.request({
|
|
1687
|
+
method: "PATCH",
|
|
1688
|
+
path: `/v1/webhooks/${encodeURIComponent(webhookId)}`,
|
|
1689
|
+
body: params
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1393
1692
|
/**
|
|
1394
1693
|
* Delete a webhook endpoint. Deliveries stop immediately; the returned
|
|
1395
1694
|
* object is its final state. The webhook no longer appears in `list()`,
|
|
@@ -1406,6 +1705,105 @@ var WebhookResource = class {
|
|
|
1406
1705
|
}
|
|
1407
1706
|
};
|
|
1408
1707
|
|
|
1708
|
+
// src/resources/themes/themes.ts
|
|
1709
|
+
var ThemeResource = class {
|
|
1710
|
+
constructor(client) {
|
|
1711
|
+
this.client = client;
|
|
1712
|
+
}
|
|
1713
|
+
/**
|
|
1714
|
+
* List the themes your pages can use, newest first: your own themes and the
|
|
1715
|
+
* built-in (`global`) ones. A retired built-in theme is only listed while one
|
|
1716
|
+
* of your pages uses it.
|
|
1717
|
+
*
|
|
1718
|
+
* @example
|
|
1719
|
+
* const { data: themes, has_more } = await client.themes.list({ scope: 'seller' });
|
|
1720
|
+
*/
|
|
1721
|
+
async list(args = {}) {
|
|
1722
|
+
const query = {
|
|
1723
|
+
scope: args.scope,
|
|
1724
|
+
limit: args.limit?.toString(),
|
|
1725
|
+
starting_after: args.starting_after,
|
|
1726
|
+
ending_before: args.ending_before
|
|
1727
|
+
};
|
|
1728
|
+
return this.client.request({
|
|
1729
|
+
method: "GET",
|
|
1730
|
+
path: "/v1/themes/",
|
|
1731
|
+
query
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
/**
|
|
1735
|
+
* Retrieve one of your themes or a built-in theme.
|
|
1736
|
+
*
|
|
1737
|
+
* @example
|
|
1738
|
+
* const { data: theme } = await client.themes.get(themeId);
|
|
1739
|
+
*/
|
|
1740
|
+
async get(themeId) {
|
|
1741
|
+
if (!themeId) {
|
|
1742
|
+
throw new Error("Theme ID is required");
|
|
1743
|
+
}
|
|
1744
|
+
return this.client.request({
|
|
1745
|
+
method: "GET",
|
|
1746
|
+
path: `/v1/themes/${encodeURIComponent(themeId)}`
|
|
1747
|
+
});
|
|
1748
|
+
}
|
|
1749
|
+
/**
|
|
1750
|
+
* Create a theme. Pass `baseThemeId` to start from a copy of one of your
|
|
1751
|
+
* themes or a built-in theme, then set what should differ in `variables`.
|
|
1752
|
+
* `variables` takes the same shape as a page's `themeOverrides`. A copy of a
|
|
1753
|
+
* built-in theme does not follow your store's brand colour, so set
|
|
1754
|
+
* `tokens.colorPrimary` if you want it.
|
|
1755
|
+
*
|
|
1756
|
+
* @example
|
|
1757
|
+
* const { data: theme } = await client.themes.create({
|
|
1758
|
+
* name: 'Brand',
|
|
1759
|
+
* baseThemeId: builtInThemeId,
|
|
1760
|
+
* variables: { tokens: { colorPrimary: { light: '#4f46e5' } } },
|
|
1761
|
+
* });
|
|
1762
|
+
*/
|
|
1763
|
+
async create(params) {
|
|
1764
|
+
return this.client.request({
|
|
1765
|
+
method: "POST",
|
|
1766
|
+
path: "/v1/themes/",
|
|
1767
|
+
body: params
|
|
1768
|
+
});
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* Update one of your themes. Every page that uses it changes too. Keys left
|
|
1772
|
+
* out of `variables` keep their value, and `null` resets a property or
|
|
1773
|
+
* everything under a key. Built-in themes are read-only.
|
|
1774
|
+
*
|
|
1775
|
+
* @example
|
|
1776
|
+
* const { data: theme } = await client.themes.update(themeId, {
|
|
1777
|
+
* variables: { tokens: { colorPrimary: { light: '#0f766e' } } },
|
|
1778
|
+
* });
|
|
1779
|
+
*/
|
|
1780
|
+
async update(themeId, params) {
|
|
1781
|
+
if (!themeId) {
|
|
1782
|
+
throw new Error("Theme ID is required");
|
|
1783
|
+
}
|
|
1784
|
+
return this.client.request({
|
|
1785
|
+
method: "PATCH",
|
|
1786
|
+
path: `/v1/themes/${encodeURIComponent(themeId)}`,
|
|
1787
|
+
body: params
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1790
|
+
/**
|
|
1791
|
+
* Delete one of your themes and return its final state. A theme that any of
|
|
1792
|
+
* your pages uses, archived ones included, or that is your store's default
|
|
1793
|
+
* theme, can't be deleted (a `ConflictError`): move those pages to another
|
|
1794
|
+
* theme with `themeId` first.
|
|
1795
|
+
*/
|
|
1796
|
+
async delete(themeId) {
|
|
1797
|
+
if (!themeId) {
|
|
1798
|
+
throw new Error("Theme ID is required");
|
|
1799
|
+
}
|
|
1800
|
+
return this.client.request({
|
|
1801
|
+
method: "DELETE",
|
|
1802
|
+
path: `/v1/themes/${encodeURIComponent(themeId)}`
|
|
1803
|
+
});
|
|
1804
|
+
}
|
|
1805
|
+
};
|
|
1806
|
+
|
|
1409
1807
|
// src/index.ts
|
|
1410
1808
|
var CheckoutPageClient = class {
|
|
1411
1809
|
accounts;
|
|
@@ -1425,6 +1823,7 @@ var CheckoutPageClient = class {
|
|
|
1425
1823
|
taxRates;
|
|
1426
1824
|
invoices;
|
|
1427
1825
|
webhooks;
|
|
1826
|
+
themes;
|
|
1428
1827
|
client;
|
|
1429
1828
|
constructor(options) {
|
|
1430
1829
|
this.client = new CheckoutPageApiClient(options);
|
|
@@ -1445,6 +1844,7 @@ var CheckoutPageClient = class {
|
|
|
1445
1844
|
this.taxRates = new TaxRateResource(this.client);
|
|
1446
1845
|
this.invoices = new InvoiceResource(this.client);
|
|
1447
1846
|
this.webhooks = new WebhookResource(this.client);
|
|
1847
|
+
this.themes = new ThemeResource(this.client);
|
|
1448
1848
|
}
|
|
1449
1849
|
};
|
|
1450
1850
|
var createCheckoutPageClient = (options) => {
|