This repository was archived by the owner on Nov 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinterfaces.ts
950 lines (678 loc) · 28 KB
/
interfaces.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
import {
RawPaddleEnumCountries as PaddleSdkCountry,
RawPaddleEnumCurrencies as PaddleSdkCurrency,
} from './__generated__/enums'
// ----------------------------------------------------------------------------
// ENUMS
// ----------------------------------------------------------------------------
/** A type of a webhook event */
export const PaddleSdkWebhookEventType = {
PAYMENT_SUCCEEDED: 'PAYMENT_SUCCEEDED',
PAYMENT_REFUNDED: 'PAYMENT_REFUNDED',
SUBSCRIPTION_CREATED: 'SUBSCRIPTION_CREATED',
SUBSCRIPTION_UPDATED: 'SUBSCRIPTION_UPDATED',
SUBSCRIPTION_CANCELLED: 'SUBSCRIPTION_CANCELLED',
SUBSCRIPTION_PAYMENT_SUCCEEDED: 'SUBSCRIPTION_PAYMENT_SUCCEEDED',
} as const
export type PaddleSdkWebhookEventType =
(typeof PaddleSdkWebhookEventType)[keyof typeof PaddleSdkWebhookEventType]
/**
* A status of a subscription
*
* - ACTIVE: Indicates an active subscription, payments are up-to-date.
* - TRIALING: Indicates the subscription is in the trial period, will change to ACTIVE once the first recurring payment is successfully completed.
* - PAST_DUE: Indicates a payment for this subscription has failed. The payment will be retried and the status will change to ACTIVE, PAUSED or CANCELLED depending on your dunning settings.
* - PAUSED: Indicates that this subscription has been paused. The customer will not be charged for subsequent payments. The status will change to ACTIVE once the subscription is restarted.
* - CANCELLED: Indicates that this subscription has been cancelled.
*/
export const PaddleSdkSubscriptionStatus = {
ACTIVE: 'ACTIVE',
TRIALING: 'TRIALING',
PAST_DUE: 'PAST_DUE',
PAUSED: 'PAUSED',
CANCELLED: 'CANCELLED',
} as const
export type PaddleSdkSubscriptionStatus =
(typeof PaddleSdkSubscriptionStatus)[keyof typeof PaddleSdkSubscriptionStatus]
/** A three-letter ISO currency code */
export { PaddleSdkCurrency }
/** A two letter ISO country code */
export { PaddleSdkCountry }
/**
* A reason why a subscription was paused
*
* - DELINQUENT: The payment failed and the rule specified in the dunning settings was to pause the subscription.
* - VOLUNTARY: The subscription was paused via the API.
*/
export const PaddleSdkPausedReason = {
DELINQUENT: 'DELINQUENT',
VOLUNTARY: 'VOLUNTARY',
} as const
export type PaddleSdkPausedReason =
(typeof PaddleSdkPausedReason)[keyof typeof PaddleSdkPausedReason]
/** A payment method used to make a transaction */
export const PaddleSdkPaymentMethod = {
CARD: 'CARD',
PAYPAL: 'PAYPAL',
APPLE_PAY: 'APPLE_PAY',
WIRE_TRANSFER: 'WIRE_TRANSFER',
FREE: 'FREE',
} as const
export type PaddleSdkPaymentMethod =
(typeof PaddleSdkPaymentMethod)[keyof typeof PaddleSdkPaymentMethod]
/** A brand of card used to make a transaction */
export const PaddleSdkCardBrand = {
AMERICAN_EXPRESS: 'AMERICAN_EXPRESS',
DINERS_CLUB: 'DINERS_CLUB',
DISCOVER: 'DISCOVER',
ELO: 'ELO',
JCB: 'JCB',
MAESTRO: 'MAESTRO',
MASTERCARD: 'MASTERCARD',
VISA: 'VISA',
UNKNOWN: 'UNKNOWN',
} as const
export type PaddleSdkCardBrand = (typeof PaddleSdkCardBrand)[keyof typeof PaddleSdkCardBrand]
/** Refund type */
export const PaddleSdkRefundType = {
FULL: 'FULL',
VAT: 'VAT',
PARTIAL: 'PARTIAL',
} as const
export type PaddleSdkRefundType = (typeof PaddleSdkRefundType)[keyof typeof PaddleSdkRefundType]
// ----------------------------------------------------------------------------
// WEBHOOKS
// ----------------------------------------------------------------------------
/** An event fired when a one-off purchase payment is made */
export type PaddleSdkPaymentSucceededEvent<TMetadata> = {
// EVENT ---
/** The type of this event */
eventType: typeof PaddleSdkWebhookEventType.PAYMENT_SUCCEEDED
/** The unique ID for this event */
eventId: number
/** The date and time the event was fired */
eventTime: Date
// ORDER ---
/** The value passed into the pay link / set via the API using the `metadata` parameter */
metadata: TMetadata
/** The unique order ID for this payment */
orderId: string
/** The unique checkout ID of the order */
checkoutId: string
/** The coupon code used on this order */
coupon: string
/** The URL containing the customer receipt for this order */
receiptUrl: string
/** The dashboard ID of the product purchased in this order */
productId: number
/** The name of the product included in the order */
productName: string
/** The number of products or in this order */
quantity: number
/** The payment method used to make the transaction */
paymentMethod: PaddleSdkPaymentMethod
/** The currency of the order */
currency: PaddleSdkCurrency
/** The total amount the customer was charged for this payment */
gross: number
/** The amount of tax paid for this payment */
tax: number
/** The amount of fees paid for this payment */
fee: number
/** The total amount (after taxes and fees) earned from this payment */
earnings: number
/** Whether the dashboard price was overridden */
usedPriceOverride: boolean
// CUSTOMER ---
/** The name of the customer */
customerName: string
/** The email address of the customer */
customerEmail: string
/** The country of the customer */
customerCountry: PaddleSdkCountry
/** Whether the customer has agreed to receive marketing messages */
hasMarketingConsent: boolean
// BALANCE ---
/** The currency of the vendor */
balanceCurrency: PaddleSdkCurrency
/** The total amount received from the customer (in the vendor's currency) */
balanceGross: number
/** The amount of tax received from the customer (in the vendor's currency) */
balanceTax: number
/** The amount of fees taken from the vendor (in the vendor's currency) */
balanceFee: number
/** The amount earned from this payment (in the vendor's currency) */
balanceEarnings: number
}
/** An event fired when a one-off purchase payment is refunded */
export type PaddleSdkPaymentRefundedEvent<TMetadata> = {
// EVENT ---
/** The type of this event */
eventType: typeof PaddleSdkWebhookEventType.PAYMENT_REFUNDED
/** The unique ID for this event */
eventId: number
/** The date and time the event was fired */
eventTime: Date
// ORDER ---
/** The value passed into the pay link / set via the API using the `metadata` parameter */
metadata: TMetadata
/** The unique order ID for this payment */
orderId: string
/** The unique checkout ID of the order */
checkoutId: string
/** The type of refund */
refundType: PaddleSdkRefundType
/** Refund reason note */
refundReason: string
/** The number of products or subscription seats sold in the transaction */
quantity: number
/** The currency of the order */
currency: PaddleSdkCurrency
/** The amount refunded, partial refunds are possible */
amount: number
/** The amount of tax returned to the customer, in the currency of the original transaction */
taxRefund: number
/** The fee amount returned to the vendor, in the currency of the original transaction */
feeRefund: number
/** The total amount returned to the customer as a result of this refund, in the currency of the original transaction */
grossRefund: number
/** The amount of revenue taken from the vendor’s earnings as a result of this refund, in the currency of the original transaction */
earningsDecrease: number
// CUSTOMER ---
/** The email address of the customer */
customerEmail: string
/** Whether the customer has agreed to receive marketing messages */
hasMarketingConsent: boolean
// BALANCE ---
/** The currency of the vendor */
balanceCurrency: PaddleSdkCurrency
/** The total amount returned to the customer as a result of this refund, in the vendor’s default currency at the time of the transaction */
balanceGrossRefund: number
/** The amount of tax returned to the customer, in the vendor’s default currency at the time of the transaction */
balanceTaxRefund: number
/** The fee amount returned to the vendor, in the vendor’s default currency at the time of the transaction */
balanceFeeRefund: number
/** The amount of revenue taken from the vendor’s earnings as a result of this refund, in the vendor’s default currency at the time of the transaction */
balanceEarningsDecrease: number
}
/** An event fired when a subscription is created */
export type PaddleSdkSubscriptionCreatedEvent<TMetadata> = {
// EVENT ---
/** The type of this event */
eventType: typeof PaddleSdkWebhookEventType.SUBSCRIPTION_CREATED
/** The unique ID for this event */
eventId: number
/** The date and time the event was fired */
eventTime: Date
// ORDER ---
/** The value passed into the pay link using the `metadata` parameter */
metadata: TMetadata
/** The unique checkout ID of the order */
checkoutId: string
/** The currency of the order */
currency: PaddleSdkCurrency
/** The referrer URL(s) from where the order originated from */
referrerUrl: string
// SUBSCRIPTION ---
/** The unique ID of the subscription */
subscriptionId: number
/** The ID of the product the subscription is for */
productId: number
/** The status of the subscription */
status: PaddleSdkSubscriptionStatus
/** The number of subscription seats */
quantity: number
/** The price per seat of the subscription */
unitPrice: number
/** The total price of the subscription */
price: number
/** The date the next payment is due for the subscription */
nextPaymentDate: Date
/** The URL of the "Update Billing Information" page for the subscription */
updateUrl: string
/** The URL of the "Cancellation" page for the subscription */
cancelUrl: string
// CUSTOMER ---
/** The unique ID of the customer */
customerId: number
/** The email address of the customer */
customerEmail: string
/** Whether the customer has agreed to receive marketing messages */
hasMarketingConsent: boolean
}
/** An event fired when a subscription is updated */
export type PaddleSdkSubscriptionUpdatedEvent<TMetadata> = {
// EVENT ---
/** The type of this event */
eventType: typeof PaddleSdkWebhookEventType.SUBSCRIPTION_UPDATED
/** The unique ID for this event */
eventId: number
/** The date and time the event was fired */
eventTime: Date
// ORDER ---
/** The value passed into the pay link / set via the API using the `metadata` parameter */
metadata: TMetadata
/** The unique checkout ID of the order */
checkoutId: string
/** The currency of the order */
currency: PaddleSdkCurrency
// SUBSCRIPTION ---
/** The unique ID of the subscription */
subscriptionId: number
/** The old ID of the product the subscription was for */
oldProductId: number
/** The ID of the product the subscription is for */
productId: number
/** The old status of the subscription */
oldStatus: PaddleSdkSubscriptionStatus
/** The status of the subscription */
status: PaddleSdkSubscriptionStatus
/** The old number of subscription seats */
oldQuantity: number
/** The number of subscription seats */
quantity: number
/** The old price per seat of the subscription */
oldUnitPrice: number
/** The price per seat of the subscription */
unitPrice: number
/** The old total price of the subscription */
oldPrice: number
/** The total price of the subscription */
price: number
/** The old date the next payment was due for the subscription */
oldNextPaymentDate: Date
/** The date the next payment is due for the subscription */
nextPaymentDate: Date
/** The URL of the "Update Billing Information" page for the subscription */
updateUrl: string
/** The URL of the "Cancellation" page for the subscription */
cancelUrl: string
/** The date and time when the subscription was requested to be paused */
pausedAt: Date | null
/**
* The date the pause comes into effect, taking the customer’s balance into account.
* The customer should be able to use the service they've subscribed to up until this date.
*/
pausedFrom: Date | null
/** The reason why the subscription is paused */
pausedReason: PaddleSdkPausedReason | null
// CUSTOMER ---
/** The unique ID of the customer */
customerId: number
/** The email address of the customer */
customerEmail: string
/** Whether the customer has agreed to receive marketing messages */
hasMarketingConsent: boolean
}
/** An event fired when a subscription is cancelled */
export type PaddleSdkSubscriptionCancelledEvent<TMetadata> = {
// EVENT ---
/** The type of this event */
eventType: typeof PaddleSdkWebhookEventType.SUBSCRIPTION_CANCELLED
/** The unique ID for this event */
eventId: number
/** The date and time the event was fired */
eventTime: Date
// ORDER ---
/** The value passed into the pay link / set via the API using the `metadata` parameter */
metadata: TMetadata
/** The unique checkout ID of the order */
checkoutId: string
/** The currency of the order */
currency: PaddleSdkCurrency
// SUBSCRIPTION ---
/** The unique ID of the subscription */
subscriptionId: number
/** The ID of the product the subscription is for */
productId: number
/** The status of the subscription */
status: PaddleSdkSubscriptionStatus
/** The number of subscription seats */
quantity: number
/** The price per seat of the subscription */
unitPrice: number
/** The total price of the subscription */
price: number
/**
* The date the cancellation comes into effect, taking the customer’s balance into account.
* The customer should be able to use the service they've subscribed to up until this date.
*/
cancelledFrom: Date
// CUSTOMER ---
/** The unique ID of the customer */
customerId: number
/** The email address of the customer */
customerEmail: string
/** Whether the customer has agreed to receive marketing messages */
hasMarketingConsent: boolean
}
/**
* An event fired when a subscription payment is made
* Both the normal recurring subscription payment as well as extra charges trigger this event
*/
export type PaddleSdkSubscriptionPaymentSucceededEvent<TMetadata> = {
// EVENT ---
/** The type of this event */
eventType: typeof PaddleSdkWebhookEventType.SUBSCRIPTION_PAYMENT_SUCCEEDED
/** The unique ID for this event */
eventId: number
/** The date and time the event was fired */
eventTime: Date
// ORDER ---
/** The value passed into the pay link / set via the API using the `metadata` parameter */
metadata: TMetadata
/** The unique order ID for this payment */
orderId: string
/** The unique checkout ID of the order */
checkoutId: string
/** The coupon code used on this order */
coupon: string
/** The URL containing the customer receipt for this order */
receiptUrl: string
/** Whether this is the customer’s first payment for this subscription */
isInitialPayment: boolean
/** The number of payments made to date */
installments: number
/** The payment method used to make the transaction */
paymentMethod: PaddleSdkPaymentMethod
/** The currency of the order */
currency: PaddleSdkCurrency
/** The total amount the customer was charged for this payment */
gross: number
/** The amount of tax paid for this payment */
tax: number
/** The amount of fees paid for this payment */
fee: number
/** The total amount (after taxes and fees) earned from this payment */
earnings: number
// SUBSCRIPTION ---
/** The unique ID of the subscription */
subscriptionId: number
/** The unique ID of the subscription payment */
subscriptionPaymentId: number
/** The ID of the product the subscription is for */
productId: number
/** The status of the subscription */
status: PaddleSdkSubscriptionStatus
/** The number of subscription seats */
quantity: number
/** The price per seat of the subscription */
unitPrice: number
/** The total price of the subscription */
price: number
/** The date the next payment is due for the subscription */
nextPaymentDate: Date
/** The total amount charged for the next payment of the subscription */
nextPaymentAmount: number
// CUSTOMER ---
/** The unique ID of the customer */
customerId: number
/** The name of the customer */
customerName: string
/** The email address of the customer */
customerEmail: string
/** The country of the customer */
customerCountry: PaddleSdkCountry
/** Whether the customer has agreed to receive marketing messages */
hasMarketingConsent: boolean
// BALANCE ---
/** The currency of the vendor */
balanceCurrency: PaddleSdkCurrency
/** The total amount received from the customer (in the vendor's currency) */
balanceGross: number
/** The amount of tax received from the customer (in the vendor's currency) */
balanceTax: number
/** The amount of fees taken from the vendor (in the vendor's currency) */
balanceFee: number
/** The amount earned from this payment (in the vendor's currency) */
balanceEarnings: number
}
// ----------------------------------------------------------------------------
// API REQUESTS
// ----------------------------------------------------------------------------
/** The API request parameters for creating a product pay link */
export type PaddleSdkCreateProductPayLinkRequest<TMetadata> = {
/** The ID of the product to base the pay link on */
productId?: number
/**
* The metadata stored with the checkout, will be sent with all events associated with the order
* This field is used to link payments/subscriptions to existing application entities
*/
metadata?: TMetadata
// CUSTOM PRODUCT ---
/** The name of the product / title of the checkout, required if `productId` is not set */
title?: string
/** The short message displayed below the product name on the checkout */
customMessage?: string
/** The URL for the product image displayed on the checkout */
imageUrl?: string
/** The URL called with events upon successful checkout, only valid and required if `productId` is not set */
webhookUrl?: string
/**
* The price(s) of the checkout for a one-time purchase or initial payment of a subscription.
*
* If `productId` is set, you must provide the price for the product’s default currency. If a
* given currency is enabled in the dashboard, it will default to a conversion of the product’s
* default currency price set in this field unless specified here as well.
*/
prices?: Array<[PaddleSdkCurrency, number]>
/**
* The recurring price(s) of the checkout (excluding the initial payment), only valid if the `productId`
* specified is a subscription.
*
* You must provide the price for the subscription’s default currency. If a given currency is enabled
* in the dashboard, it will default to a conversion of the subscription’s default currency
* price set in this field unless specified here as well.
*
* To override the initial payment and all recurring payment amounts, both `prices` and
* `recurringPrices` must be set.
*/
recurringPrices?: Array<[PaddleSdkCurrency, number]>
/** The number of days before charging the customer the recurring price, only valid for subscriptions */
trialDays?: number
/** Whether a coupon can be applied to the checkout */
isDiscountable?: boolean
/** The URL to redirect to once the checkout is completed */
returnUrl?: string
/** Whether the customer is allowed to alter the quantity of the checkout */
isQuantityVariable?: boolean
/** The expiration date of the checkout link should expire */
expirationDate?: Date
/** The other vendor IDs whom you would like to split the funds from this checkout with */
affiliates?: Array<number>
/**
* The number of times other vendors will receive funds from the recurring payments for subscription products
*
* The initial checkout payment is included in the limit. If this field is not set, a limit will not be applied.
* If your product has a trial period, set this to `2` or greater in order for your affiliates to correctly receive
* their commission on payments after the trial.
*/
recurringAffiliateLimit?: number
// POPULATE CHECKOUT ---
/**
* Populates the quantity selector on the checkout
* Free products & subscription products are fixed to a quantity of 1
*/
populateQuantity?: number
/** Populates the "Coupon" field on the checkout */
populateCoupon?: string
/** Populates whether the customer has agreed to receive marketing messages */
populateHasMarketingConsent?: boolean
/** Populates the "Email" field on the checkout, required if `populateHasMarketingConsent` if set */
populateCustomerEmail?: string
/** Populates the "Country" field on the checkout */
populateCustomerCountry?: PaddleSdkCountry
/**
* Populates the "Postcode" field on the checkout, required if the `populateCustomerCountry` requires a postcode
*
* See the [Supported Countries](https://developer.paddle.com/reference/platform-parameters/supported-countries#countries-requiring-postcode) for countries requiring this field.
*/
populateCustomerPostcode?: string
/** Populates the "VAT Number" field on the checkout */
populateVatNumber?: string
/** Populates the "VAT Company Name" field on the checkout, required if `populateVatNumber` is set */
populateVatCompanyName?: string
/** Populates the "VAT Street" field on the checkout, required if `populateVatNumber` is set */
populateVatStreet?: string
/** Populates the "VAT Town/City" field on the checkout, required if `populateVatNumber` is set */
populateVatCity?: string
/** Populates the "VAT State" field on the checkout */
populateVatState?: string
/** Populates the "VAT Country" field on the checkout, required if `populateVatNumber` is set */
populateVatCountry?: PaddleSdkCountry
/**
* Populates the "VAT Postcode" field on the checkout, required if `populateVatNumber` is set and
* the `populateVatCountry` requires a postcode
*
* See the [Supported Countries](https://developer.paddle.com/reference/platform-parameters/supported-countries#countries-requiring-postcode) for countries requiring this field.
*/
populateVatPostcode?: string
}
/** The API response for creating a product pay link */
export type PaddleSdkCreateProductPayLinkResponse = {
/** The generated product pay link URL */
url: string
}
/** The API request parameters for listing subscriptions */
export type PaddleSdkListSubscriptionsRequest = {
/** Filter by the unique ID of the subscription */
subscriptionId?: number
/** Filter by the ID of the product the subscription is for */
productId?: number
/** Filter by the subscription status */
status?: PaddleSdkSubscriptionStatus
/** The requested page of the result set */
page?: number
/** The number of records to return per page */
resultsPerPage?: number
}
/** The API response for listing subscriptions */
export type PaddleSdkListSubscriptionsResponse = Array<{
// ORDER ---
/** The payment method used to make the transaction */
paymentMethod: typeof PaddleSdkPaymentMethod.CARD | typeof PaddleSdkPaymentMethod.PAYPAL
/** The brand of the card, set if `paymentMethod` is "CARD" */
cardBrand: PaddleSdkCardBrand | null
/** The last four digits of the card, set if `paymentMethod` is "CARD" */
cardLastFour: string | null
/** The expiration date of the card, set if `paymentMethod` is "CARD" */
cardExpirationDate: Date | null
// SUBSCRIPTION ---
/** The unique ID of the subscription */
subscriptionId: number
/** The ID of the product the subscription is for */
productId: number
/** The status of the subscription */
status: PaddleSdkSubscriptionStatus
/** The number of subscription seats */
quantity: number
/** The date and time the subscription was created */
signupDate: Date
/** The date the last payment was due for the subscription */
lastPaymentDate: Date
/** The currency of the last payment of the subscription */
lastPaymentCurrency: PaddleSdkCurrency
/** The total amount charged for the last payment of the subscription */
lastPaymentAmount: number
/** The date the next payment is due for the subscription */
nextPaymentDate: Date | null
/** The currency of the next payment of the subscription */
nextPaymentCurrency: PaddleSdkCurrency | null
/** The total amount charged for the next payment of the subscription */
nextPaymentAmount: number | null
/** The URL of the "Update Billing Information" page for the subscription */
updateUrl: string
/** The URL of the "Cancellation" page for the subscription */
cancelUrl: string
/** The date and time when the subscription was requested to be paused */
pausedAt: Date | null
/**
* The date the pause comes into effect, taking the customer’s balance into account.
* The customer should be able to use the service they've subscribed to up until this date.
*/
pausedFrom: Date | null
// CUSTOMER ---
/** The unique ID of the customer */
customerId: number
/** The email address of the customer */
customerEmail: string
/** Whether the customer has agreed to receive marketing messages */
hasMarketingConsent: boolean
}>
/** The API request parameters for updating a subscription */
export type PaddleSdkUpdateSubscriptionRequest<TMetadata> = {
/** The unique ID of the subscription to be updated */
subscriptionId: number
/** The new ID of the product to move the subscription to */
productId?: number
/** The new number of subscription seats, only valid for quantity enabled subscriptions */
quantity?: number
/** The new price per unit to apply to a quantity enabled subscription */
unitPrice?: number
/**
* The currency of the unit price, required if `unitPrice` is set
* This must be the same as the currency of the existing subscription.
*/
currency?: PaddleSdkCurrency
/** Whether the subscription should make a payment for the next interval immediately */
shouldMakeImmediatePayment?: boolean
/** Whether the change in subscription should be prorated */
shouldProrate?: boolean
/** Whether to keep the existing modifiers on the subscription */
shouldKeepModifiers?: boolean
/**
* The metadata data stored with the checkout, will be sent with all events associated with the order
* This field is used to link payments/subscriptions to existing application entities
*/
metadata?: TMetadata
/**
* Whether a subscription should be paused (true) or restarted (false)
*
* If the subscription is paused, the status will be changed to "PAUSED" when the subscription's
* next payment date is reached.
*/
shouldPause?: boolean
}
/** The API response for updating a subscription */
export type PaddleSdkUpdateSubscriptionResponse = {
/** The unique ID of the subscription */
subscriptionId: number
/** The unique ID of the customer */
customerId: number
/** The ID of the product the subscription is for */
productId: number
/** The date the next payment is due for the subscription */
nextPaymentDate: Date | null
/** The currency of the next payment of the subscription */
nextPaymentCurrency: PaddleSdkCurrency | null
/** The total amount charged for the next payment of the subscription */
nextPaymentAmount: number | null
}
/** The API request parameters for creating a subscription modifier */
export type PaddleSdkCreateSubscriptionModifierRequest = {
/** The unique ID of the subscription to add a modifier for */
subscriptionId: number
/** Whether this modifier will be added to all future subscription payments */
isRecurring: boolean
/**
* The amount this modifier adds to (positive) or removes from (negative) the subscription payment,
* in the currency of the subscription
*/
amount: number
/** The text to be displayed on the buyer's receipt email and invoice */
description: string
}
/** The API response for creating a subscription modifier */
export type PaddleSdkCreateSubscriptionModifierResponse = {
/** The unique ID of the subscription */
subscriptionId: number
/** The unique ID of the modifier */
modifierId: number
}
/** The API request parameters for cancelling a subscription */
export type PaddleSdkCancelSubscriptionRequest = {
/** The unique ID of the subscription to be cancelled */
subscriptionId: number
}
/** The API response for cancelling a subscription */
export type PaddleSdkCancelSubscriptionResponse = void