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