@abacatepay/types 0.0.4 → 2.0.1

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.
@@ -0,0 +1,8 @@
1
+ export var SubscriptionStatus;
2
+ (function (SubscriptionStatus) {
3
+ SubscriptionStatus["Pending"] = "PENDING";
4
+ SubscriptionStatus["Active"] = "ACTIVE";
5
+ SubscriptionStatus["Cancelled"] = "CANCELLED";
6
+ SubscriptionStatus["Expired"] = "EXPIRED";
7
+ SubscriptionStatus["Failed"] = "FAILED";
8
+ })(SubscriptionStatus || (SubscriptionStatus = {}));
@@ -0,0 +1,12 @@
1
+ export * from './entities/checkout';
2
+ export * from './entities/coupon';
3
+ export * from './entities/customer';
4
+ export * from './entities/payout';
5
+ export * from './entities/pix';
6
+ export * from './entities/products';
7
+ export * from './entities/store';
8
+ export * from './entities/subscription';
9
+ export * from './rest';
10
+ export { Routes } from './routes';
11
+ export * from './utils';
12
+ export * from './webhook';
@@ -0,0 +1,12 @@
1
+ export * from './entities/checkout';
2
+ export * from './entities/coupon';
3
+ export * from './entities/customer';
4
+ export * from './entities/payout';
5
+ export * from './entities/pix';
6
+ export * from './entities/products';
7
+ export * from './entities/store';
8
+ export * from './entities/subscription';
9
+ export * from './rest';
10
+ export { Routes } from './routes';
11
+ export * from './utils';
12
+ export * from './webhook';
@@ -0,0 +1,681 @@
1
+ import type { APICheckout, APICoupon, APICustomer, APIPayout, APIQRCodePIX, APIStore, CouponDiscountKind, PaymentMethod, PaymentStatus } from '.';
2
+ import type { APIProduct } from './entities/products';
3
+ import type { APISubscription } from './entities/subscription';
4
+ /**
5
+ * Any response returned by the AbacatePay API.
6
+ */
7
+ export type APIResponse<Data> = {
8
+ /**
9
+ * The data of the response.
10
+ */
11
+ data: Data;
12
+ error: null;
13
+ } | {
14
+ data: null;
15
+ /**
16
+ * Error message returned from the API.
17
+ */
18
+ error: string;
19
+ };
20
+ /**
21
+ * Any response returned by the AbacatePay API that has a `pagination` field (Not cursor based).
22
+ */
23
+ export type APIResponseWithPagination<Data> = {
24
+ /**
25
+ * The data of the response.
26
+ */
27
+ data: Data;
28
+ error: null;
29
+ /**
30
+ * Pagination info.
31
+ */
32
+ pagination: {
33
+ /**
34
+ * Current page.
35
+ */
36
+ page: number;
37
+ /**
38
+ * Number of items per page.
39
+ */
40
+ limit: number;
41
+ /**
42
+ * Number of items.
43
+ */
44
+ items: number;
45
+ /**
46
+ * Number of pages.
47
+ */
48
+ totalPages: number;
49
+ };
50
+ } | {
51
+ data: null;
52
+ /**
53
+ * Error message returned from the API.
54
+ */
55
+ error: string;
56
+ };
57
+ /**
58
+ * Any response returned by the AbacatePay API that has a `pagination` field and is cursor-based.
59
+ */
60
+ export type APIResponseWithCursorBasedPagination<Data> = {
61
+ /**
62
+ * The data of the response.
63
+ */
64
+ data: Data;
65
+ error: null;
66
+ /**
67
+ * Pagination info.
68
+ */
69
+ pagination: {
70
+ /**
71
+ * Number of items per page.
72
+ */
73
+ limit: number;
74
+ /**
75
+ * Indicates whether there is a next page.
76
+ */
77
+ hasNext: boolean;
78
+ /**
79
+ * Indicates whether there is a previous page.
80
+ */
81
+ hasPrevious: boolean;
82
+ /**
83
+ * Cursor for the next page.
84
+ */
85
+ nextCursor: string | null;
86
+ };
87
+ } | {
88
+ data: null;
89
+ /**
90
+ * Error message returned from the API.
91
+ */
92
+ error: string;
93
+ };
94
+ /**
95
+ * https://api.abacatepay.com/v2/customers/create
96
+ *
97
+ * @reference https://docs.abacatepay.com/pages/client/create
98
+ */
99
+ export type RESTPostCreateCustomerBody = Pick<APICustomer, 'email'> & Partial<Pick<APICustomer, 'name' | 'taxId' | 'zipCode' | 'cellphone' | 'metadata'>>;
100
+ /**
101
+ * https://api.abacatepay.com/v2/customers/create
102
+ *
103
+ * @reference https://docs.abacatepay.com/pages/client/create
104
+ */
105
+ export type RESTPostCreateCustomerData = APICustomer;
106
+ /**
107
+ * https://api.abacatepay.com/v2/checkouts/create
108
+ *
109
+ * @reference https://docs.abacatepay.com/pages/checkout/create
110
+ */
111
+ export interface RESTPostCreateNewCheckoutBody {
112
+ /**
113
+ * Payment method that will be used.
114
+ *
115
+ * @see {@link PaymentMethod}
116
+ */
117
+ methods?: PaymentMethod;
118
+ /**
119
+ * URL to redirect the customer if they click on the "Back" option.
120
+ */
121
+ returnUrl?: string;
122
+ /**
123
+ * URL to redirect the customer when payment is completed.
124
+ */
125
+ completionUrl?: string;
126
+ /**
127
+ * The ID of a customer already registered in your store.
128
+ */
129
+ customerId?: string;
130
+ /**
131
+ * Your customer's data to create it.
132
+ * The customer object is not mandatory, but when entering any `customer` information, all `name`, `cellphone`, `email` and `taxId` fields are mandatory.
133
+ */
134
+ customer?: Pick<APICustomer, 'name' | 'email' | 'taxId' | 'cellphone'>;
135
+ /**
136
+ * List of coupons available for resem used with billing (0-50 max.).
137
+ */
138
+ coupons?: string[];
139
+ /**
140
+ * If you have a unique identifier for your billing application, completely optional.
141
+ */
142
+ externalId?: string;
143
+ /**
144
+ * Optional billing metadata.
145
+ */
146
+ metadata?: Record<string, object>;
147
+ /**
148
+ * List of items included in the charge.
149
+ * This is the only required field — the total value is calculated from these items.
150
+ */
151
+ items: APICheckout['items'];
152
+ }
153
+ /**
154
+ * https://api.abacatepay.com/v2/checkouts/create
155
+ *
156
+ * @reference https://docs.abacatepay.com/pages/checkouts/create
157
+ */
158
+ export type RESTPostCreateNewCheckoutData = APICheckout;
159
+ /**
160
+ * https://api.abacatepay.com/v2/transparents/create
161
+ *
162
+ * @reference https://docs.abacatepay.com/pages/transparents/create
163
+ */
164
+ export interface RESTPostCreateQRCodePixBody extends Pick<RESTPostCreateNewCheckoutBody, 'customer' | 'metadata'> {
165
+ /**
166
+ * Charge amount in cents.
167
+ */
168
+ amount: number;
169
+ /**
170
+ * Billing expiration time in seconds.
171
+ */
172
+ expiresIn?: number;
173
+ /**
174
+ * Message that will appear when paying the PIX.
175
+ */
176
+ description?: string;
177
+ }
178
+ /**
179
+ * https://api.abacatepay.com/v2/transparents/create
180
+ *
181
+ * @reference https://docs.abacatepay.com/pages/transparents/create
182
+ */
183
+ export type RESTPostCreateQRCodePixData = APIQRCodePIX;
184
+ /**
185
+ * https://api.abacatepay.com/v2/transparents/simulate-payment
186
+ *
187
+ * @reference https://docs.abacatepay.com/pages/transparents/simulate-payment
188
+ */
189
+ export interface RESTPostSimulateQRCodePixPaymentQueryParams {
190
+ /**
191
+ * QRCode Pix ID.
192
+ */
193
+ id: string;
194
+ }
195
+ /**
196
+ * https://api.abacatepay.com/v2/transparents/simulate-payment
197
+ *
198
+ * @reference https://docs.abacatepay.com/pages/transparents/simulate-payment
199
+ */
200
+ export interface RESTPostSimulateQRCodePixPaymentBody {
201
+ /**
202
+ * Optional metadata for the request.
203
+ */
204
+ metadata?: Record<string, object>;
205
+ }
206
+ /**
207
+ * https://api.abacatepay.com/v2/transparents/simulate-payment
208
+ *
209
+ * @reference https://docs.abacatepay.com/pages/transparents/simulate-payment
210
+ */
211
+ export type RESTPostSimulateQRCodePixPaymentData = APIQRCodePIX;
212
+ /**
213
+ * https://api.abacatepay.com/v2/pixQrCode/check
214
+ *
215
+ * @reference https://docs.abacatepay.com/pages/pix-qrcode/check
216
+ */
217
+ export interface RESTGetCheckQRCodePixStatusQueryParams {
218
+ /**
219
+ * QRCode Pix ID.
220
+ */
221
+ id: string;
222
+ }
223
+ /**
224
+ * https://api.abacatepay.com/v2/transparents/check
225
+ *
226
+ * @reference https://docs.abacatepay.com/pages/transparents/check
227
+ */
228
+ export interface RESTGetCheckQRCodePixStatusData {
229
+ /**
230
+ * QRCode Pix expiration date.
231
+ */
232
+ expiresAt: string;
233
+ /**
234
+ * Information about the progress of QRCode Pix.
235
+ */
236
+ status: PaymentStatus;
237
+ }
238
+ /**
239
+ * https://api.abacatepay.com/v2/checkouts/list
240
+ *
241
+ * @reference https://docs.abacatepay.com/pages/checkouts/list
242
+ */
243
+ export type RESTGetListCheckoutsData = APICheckout[];
244
+ /**
245
+ * https://api.abacatepay.com/v2/checkouts/get
246
+ *
247
+ * @reference https://docs.abacatepay.com/pages/checkouts/get
248
+ */
249
+ export type RESTGetCheckoutData = APICheckout;
250
+ /**
251
+ * https://api.abacatepay.com/v2/checkouts/get
252
+ *
253
+ * @reference https://docs.abacatepay.com/pages/checkouts/get
254
+ */
255
+ export interface RESTGetCheckoutQueryParams {
256
+ /**
257
+ * Unique billing identifier.
258
+ */
259
+ id: string;
260
+ }
261
+ /**
262
+ * https://api.abacatepay.com/v2/customers/list
263
+ *
264
+ * @reference https://docs.abacatepay.com/pages/client/list
265
+ */
266
+ export type RESTGetListCustomersData = APICustomer[];
267
+ /**
268
+ * https://api.abacatepay.com/v2/customers/list
269
+ *
270
+ * @reference https://docs.abacatepay.com/pages/client/list
271
+ */
272
+ export interface RESTGetListCustomersQueryParams {
273
+ /**
274
+ * Number of the page.
275
+ */
276
+ page?: number;
277
+ /**
278
+ * Number of items per page.
279
+ */
280
+ limit?: number;
281
+ }
282
+ /**
283
+ * https://api.abacatepay.com/v2/customers/get
284
+ *
285
+ * @reference https://docs.abacatepay.com/pages/client/get
286
+ */
287
+ export interface RESTGetCustomerQueryParams {
288
+ /**
289
+ * The ID of the customer.
290
+ */
291
+ id: string;
292
+ }
293
+ /**
294
+ * https://api.abacatepay.com/v2/customers/get
295
+ *
296
+ * @reference https://docs.abacatepay.com/pages/client/get
297
+ */
298
+ export type RESTGetCustomerData = Omit<APICustomer, 'country' | 'zipCode'>;
299
+ /**
300
+ * https://api.abacatepay.com/v2/customers/delete
301
+ *
302
+ * @reference https://docs.abacatepay.com/pages/client/delete
303
+ */
304
+ export interface RESTDeleteCustomerBody {
305
+ /**
306
+ * Unique public identifier of the customer to be deleted.
307
+ */
308
+ id: string;
309
+ }
310
+ /**
311
+ * https://api.abacatepay.com/v2/customers/delete
312
+ *
313
+ * @reference https://docs.abacatepay.com/pages/client/delete
314
+ */
315
+ export type RESTDeleteCustomerData = Omit<APICustomer, 'country' | 'zipCode'>;
316
+ /**
317
+ * https://api.abacatepay.com/v2/coupons/create
318
+ *
319
+ * @reference https://docs.abacatepay.com/pages/coupons/create
320
+ */
321
+ export interface RESTPostCreateCouponBody {
322
+ /**
323
+ * Unique coupon identifier.
324
+ *
325
+ * @example "DEYVIN_20"
326
+ */
327
+ code: string;
328
+ /**
329
+ * Discount amount to be applied.
330
+ */
331
+ discount: number;
332
+ /**
333
+ * Type of discount applied, percentage or fixed.
334
+ *
335
+ * @see {@link CouponDiscountKind}
336
+ */
337
+ discountKind: CouponDiscountKind;
338
+ /**
339
+ * Coupon description.
340
+ */
341
+ notes?: string;
342
+ /**
343
+ * Number of times the coupon can be redeemed. -1 means this coupon can be redeemed without limits.
344
+ *
345
+ * @default -1
346
+ */
347
+ maxRedeems?: number;
348
+ /**
349
+ * Key value object for coupon metadata.
350
+ */
351
+ metadata?: Record<string, unknown>;
352
+ }
353
+ /**
354
+ * https://api.abacatepay.com/v2/coupon/create
355
+ *
356
+ * @reference https://docs.abacatepay.com/pages/coupon/create
357
+ */
358
+ export type RESTPostCreateCouponData = APICoupon;
359
+ /**
360
+ * https://api.abacatepay.com/v2/payouts/create
361
+ *
362
+ * @reference https://docs.abacatepay.com/pages/payouts/create
363
+ */
364
+ export interface RESTPostCreateNewPayoutBody {
365
+ /**
366
+ * Unique identifier of the payout in your system.
367
+ */
368
+ externalId: string;
369
+ /**
370
+ * Payout value in cents (Min 350).
371
+ */
372
+ amount: number;
373
+ /**
374
+ * Optional payout description.
375
+ */
376
+ description?: string;
377
+ }
378
+ /**
379
+ * https://api.abacatepay.com/v2/payouts/create
380
+ *
381
+ * @reference https://docs.abacatepay.com/pages/payouts/create
382
+ */
383
+ export type RESTPostCreateNewWPayoutData = APIPayout;
384
+ /**
385
+ * https://api.abacatepay.com/v2/payouts/get
386
+ *
387
+ * @reference https://docs.abacatepay.com/pages/payouts/get
388
+ */
389
+ export interface RESTGetSearchPayoutQueryParams {
390
+ /**
391
+ * Unique payout identifier in your system.
392
+ */
393
+ externalId: string;
394
+ }
395
+ /**
396
+ * https://api.abacatepay.com/v2/payouts/get
397
+ *
398
+ * @reference https://docs.abacatepay.com/pages/payouts/get
399
+ */
400
+ export type RESTGetSearchPayoutData = APIPayout;
401
+ /**
402
+ * https://api.abacatepay.com/v2/payouts/list
403
+ *
404
+ * @reference https://docs.abacatepay.com/pages/payouts/list
405
+ */
406
+ export interface RESTGetListPayoutsQueryParams {
407
+ /**
408
+ * Number of the page.
409
+ *
410
+ * @default 1
411
+ */
412
+ page?: number;
413
+ /**
414
+ * Number of items per page.
415
+ *
416
+ * @default 20
417
+ */
418
+ limit?: number;
419
+ }
420
+ /**
421
+ * https://api.abacatepay.com/v2/public-mrr/revenue
422
+ *
423
+ * @reference https://docs.abacatepay.com/pages/trustMRR/list
424
+ */
425
+ export interface RESTGetRevenueByPeriodQueryParams {
426
+ /**
427
+ * Period start date (YYYY-MM-DD format).
428
+ */
429
+ startDate: string;
430
+ /**
431
+ * Period end date (YYYY-MM-DD format).
432
+ */
433
+ endDate: string;
434
+ }
435
+ /**
436
+ * https://api.abacatepay.com/v2/public-mrr/revenue
437
+ *
438
+ * @reference https://docs.abacatepay.com/pages/trustMRR/list
439
+ */
440
+ export interface RESTGetRevenueByPeriodData {
441
+ /**
442
+ * Total revenue for the period in cents.
443
+ */
444
+ totalRevenue: number;
445
+ /**
446
+ * Total transactions in the period.
447
+ */
448
+ totalTransactions: number;
449
+ /**
450
+ * Object with transactions grouped by day (key is the date in YYYY-MM-DD format).
451
+ */
452
+ transactionsPerDay: Record<string, {
453
+ /**
454
+ * Total value of the day's transactions in cents.
455
+ */
456
+ amount: number;
457
+ /**
458
+ * Number of transactions for the day.
459
+ */
460
+ count: number;
461
+ }>;
462
+ }
463
+ /**
464
+ * https://api.abacatepay.com/v2/public-mrr/merchant-info
465
+ *
466
+ * @reference https://docs.abacatepay.com/pages/trustMRR/get
467
+ */
468
+ export interface RESTGetMerchantData {
469
+ /**
470
+ * Store name.
471
+ */
472
+ name: string;
473
+ /**
474
+ * Store website.
475
+ */
476
+ website: string;
477
+ /**
478
+ * Store creation date.
479
+ */
480
+ createdAt: string;
481
+ }
482
+ /**
483
+ * https://api.abacatepay.com/v2/public-mrr/mrr
484
+ *
485
+ * @reference https://docs.abacatepay.com/pages/trustMRR/mrr
486
+ */
487
+ export interface RESTGetMRRData {
488
+ /**
489
+ * Monthly recurring revenue in cents. Value 0 indicates that there is no recurring revenue at the moment.
490
+ */
491
+ mrr: number;
492
+ /**
493
+ * Total active subscriptions. Value 0 indicates that there are no currently active subscriptions.
494
+ */
495
+ totalActiveSubscriptions: number;
496
+ }
497
+ /**
498
+ * https://api.abacatepay.com/v2/store/get
499
+ *
500
+ * @reference https://docs.abacatepay.com/pages/store/get
501
+ */
502
+ export type RESTGetStoreDetailsData = APIStore;
503
+ /**
504
+ * https://api.abacatepay.com/v2/payouts/list
505
+ *
506
+ * @reference https://docs.abacatepay.com/pages/payouts/list
507
+ */
508
+ export type RESTGetListPayoutsData = APIPayout[];
509
+ /**
510
+ * https://api.abacatepay.com/v2/coupons/list
511
+ *
512
+ * @reference https://docs.abacatepay.com/pages/coupons/list
513
+ */
514
+ export type RESTGetListCouponsData = APICoupon[];
515
+ /**
516
+ * https://api.abacatepay.com/v2/coupons/list
517
+ *
518
+ * @reference https://docs.abacatepay.com/pages/coupons/list
519
+ */
520
+ export interface RESTGetListCouponsQueryParams {
521
+ /**
522
+ * Page number.
523
+ *
524
+ * @default 1
525
+ */
526
+ page?: number;
527
+ /**
528
+ * Number of items per page.
529
+ */
530
+ limit?: number;
531
+ }
532
+ /**
533
+ * https://api.abacatepay.com/v2/coupons/get
534
+ *
535
+ * @reference https://docs.abacatepay.com/pages/coupons/get
536
+ */
537
+ export interface RESTGetCouponQueryParams {
538
+ /**
539
+ * The ID of the coupon.
540
+ */
541
+ id: string;
542
+ }
543
+ /**
544
+ * https://api.abacatepay.com/v2/coupons/get
545
+ *
546
+ * @reference https://docs.abacatepay.com/pages/coupons/get
547
+ */
548
+ export type RESTGetCouponData = APICoupon;
549
+ /**
550
+ * https://api.abacatepay.com/v2/coupons/delete
551
+ *
552
+ * @reference https://docs.abacatepay.com/pages/coupons/delete
553
+ */
554
+ export interface RESTDeleteCouponBody {
555
+ /**
556
+ * The ID of the coupon.
557
+ */
558
+ id: string;
559
+ }
560
+ /**
561
+ * https://api.abacatepay.com/v2/coupons/delete
562
+ *
563
+ * @reference https://docs.abacatepay.com/pages/coupons/delete
564
+ */
565
+ export type RESTDeleteCouponData = APICoupon;
566
+ /**
567
+ * https://api.abacatepay.com/v2/coupons/toggle
568
+ *
569
+ * @reference https://docs.abacatepay.com/pages/coupons/toggle
570
+ */
571
+ export interface RESTPatchToggleCouponStatusBody {
572
+ /**
573
+ * The ID of the coupon.
574
+ */
575
+ id: string;
576
+ }
577
+ /**
578
+ * https://api.abacatepay.com/v2/coupons/toggle
579
+ *
580
+ * @reference https://docs.abacatepay.com/pages/coupons/toggle
581
+ */
582
+ export type RESTPatchToggleCouponStatusData = APICoupon;
583
+ /**
584
+ * https://api.abacatepay.com/v2/products/create
585
+ *
586
+ * @reference https://docs.abacatepay.com/pages/products/create
587
+ */
588
+ export interface RESTPostCreateProductBody extends Pick<APIProduct, 'externalId' | 'name' | 'price' | 'currency'> {
589
+ /**
590
+ * Description for the product.
591
+ */
592
+ description?: string;
593
+ }
594
+ /**
595
+ * https://api.abacatepay.com/v2/products/create
596
+ *
597
+ * @reference https://docs.abacatepay.com/pages/products/create
598
+ */
599
+ export type RESTPostCreateProductData = APIProduct;
600
+ /**
601
+ * https://api.abacatepay.com/v2/products/list
602
+ *
603
+ * @reference https://docs.abacatepay.com/pages/products/list
604
+ */
605
+ export interface RESTGetListProductsQueryParams {
606
+ /**
607
+ * Page number.
608
+ */
609
+ page?: number;
610
+ /**
611
+ * Limit of products to return.
612
+ */
613
+ limit?: number;
614
+ }
615
+ /**
616
+ * https://api.abacatepay.com/v2/products/list
617
+ *
618
+ * @reference https://docs.abacatepay.com/pages/products/list
619
+ */
620
+ export type RESTGetListProductsData = APIProduct[];
621
+ /**
622
+ * https://api.abacatepay.com/v2/products/get
623
+ *
624
+ * @reference https://docs.abacatepay.com/pages/products/get
625
+ */
626
+ export interface RESTGetProductQueryParams {
627
+ /**
628
+ * The product ID.
629
+ */
630
+ id?: string;
631
+ /**
632
+ * External ID of the product.
633
+ */
634
+ externalId?: string;
635
+ }
636
+ /**
637
+ * https://api.abacatepay.com/v2/products/get
638
+ *
639
+ * @reference https://docs.abacatepay.com/pages/products/get
640
+ */
641
+ export type RESTGetProductData = APIProduct;
642
+ /**
643
+ * https://api.abacatepay.com/v2/subscriptions/create
644
+ *
645
+ * @reference https://docs.abacatepay.com/pages/subscriptions/create
646
+ */
647
+ export interface RESTPostCreateSubscriptionBody extends Pick<APISubscription, 'amount' | 'name' | 'externalId' | 'method' | 'frequency' | 'customerId' | 'retryPolicy'> {
648
+ /**
649
+ * Subscription description.
650
+ */
651
+ description?: string;
652
+ }
653
+ /**
654
+ * https://api.abacatepay.com/v2/subscriptions/create
655
+ *
656
+ * @reference https://docs.abacatepay.com/pages/subscriptions/create
657
+ */
658
+ export type RESTPostCreateSubscriptionData = APISubscription;
659
+ /**
660
+ * https://api.abacatepay.com/v2/subscriptions/list
661
+ *
662
+ * @reference https://docs.abacatepay.com/pages/subscriptions/list
663
+ */
664
+ export interface RESTGetListSubscriptionsQueryParams {
665
+ /**
666
+ * Cursor for the pagination.
667
+ */
668
+ cursor?: string;
669
+ /**
670
+ * Number of items per page.
671
+ *
672
+ * @default 20
673
+ */
674
+ limit?: number;
675
+ }
676
+ /**
677
+ * https://api.abacatepay.com/v2/subscriptions/list
678
+ *
679
+ * @reference https://docs.abacatepay.com/pages/subscriptions/list
680
+ */
681
+ export type RESTGetListSubscriptionsData = APISubscription[];
@@ -0,0 +1 @@
1
+ export {};