@abacatepay/types 0.0.3 → 2.0.0

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,675 @@
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/list
397
+ *
398
+ * @reference https://docs.abacatepay.com/pages/payouts/list
399
+ */
400
+ export interface RESTGetListPayoutsQueryParams {
401
+ /**
402
+ * Number of the page
403
+ *
404
+ * @default 1
405
+ */
406
+ page?: number;
407
+ /**
408
+ * Number of items per page
409
+ *
410
+ * @default 20
411
+ */
412
+ limit?: number;
413
+ }
414
+ /**
415
+ * https://api.abacatepay.com/v2/public-mrr/revenue
416
+ *
417
+ * @reference https://docs.abacatepay.com/pages/trustMRR/list
418
+ */
419
+ export interface RESTGetRevenueByPeriodQueryParams {
420
+ /**
421
+ * Period start date (YYYY-MM-DD format).
422
+ */
423
+ startDate: string;
424
+ /**
425
+ * Period end date (YYYY-MM-DD format).
426
+ */
427
+ endDate: string;
428
+ }
429
+ /**
430
+ * https://api.abacatepay.com/v2/public-mrr/revenue
431
+ *
432
+ * @reference https://docs.abacatepay.com/pages/trustMRR/list
433
+ */
434
+ export interface RESTGetRevenueByPeriodData {
435
+ /**
436
+ * Total revenue for the period in cents.
437
+ */
438
+ totalRevenue: number;
439
+ /**
440
+ * Total transactions in the period.
441
+ */
442
+ totalTransactions: number;
443
+ /**
444
+ * Object with transactions grouped by day (key is the date in YYYY-MM-DD format).
445
+ */
446
+ transactionsPerDay: Record<string, {
447
+ /**
448
+ * Total value of the day's transactions in cents.
449
+ */
450
+ amount: number;
451
+ /**
452
+ * Number of transactions for the day.
453
+ */
454
+ count: number;
455
+ }>;
456
+ }
457
+ /**
458
+ * https://api.abacatepay.com/v2/public-mrr/merchant-info
459
+ *
460
+ * @reference https://docs.abacatepay.com/pages/trustMRR/get
461
+ */
462
+ export interface RESTGetMerchantData {
463
+ /**
464
+ * Store name.
465
+ */
466
+ name: string;
467
+ /**
468
+ * Store website.
469
+ */
470
+ website: string;
471
+ /**
472
+ * Store creation date.
473
+ */
474
+ createdAt: string;
475
+ }
476
+ /**
477
+ * https://api.abacatepay.com/v2/public-mrr/mrr
478
+ *
479
+ * @reference https://docs.abacatepay.com/pages/trustMRR/mrr
480
+ */
481
+ export interface RESTGetMRRData {
482
+ /**
483
+ * Monthly recurring revenue in cents. Value 0 indicates that there is no recurring revenue at the moment.
484
+ */
485
+ mrr: number;
486
+ /**
487
+ * Total active subscriptions. Value 0 indicates that there are no currently active subscriptions.
488
+ */
489
+ totalActiveSubscriptions: number;
490
+ }
491
+ /**
492
+ * https://api.abacatepay.com/v2/store/get
493
+ *
494
+ * @reference https://docs.abacatepay.com/pages/store/get
495
+ */
496
+ export type RESTGetStoreDetailsData = APIStore;
497
+ /**
498
+ * https://api.abacatepay.com/v2/payouts/list
499
+ *
500
+ * @reference https://docs.abacatepay.com/pages/payouts/list
501
+ */
502
+ export type RESTGetListPayoutsData = APIPayout[];
503
+ /**
504
+ * https://api.abacatepay.com/v2/coupons/list
505
+ *
506
+ * @reference https://docs.abacatepay.com/pages/coupons/list
507
+ */
508
+ export type RESTGetListCouponsData = APICoupon[];
509
+ /**
510
+ * https://api.abacatepay.com/v2/coupons/list
511
+ *
512
+ * @reference https://docs.abacatepay.com/pages/coupons/list
513
+ */
514
+ export interface RESTGetListCouponsQueryParams {
515
+ /**
516
+ * Page number.
517
+ *
518
+ * @default 1
519
+ */
520
+ page?: number;
521
+ /**
522
+ * Number of items per page.
523
+ */
524
+ limit?: number;
525
+ }
526
+ /**
527
+ * https://api.abacatepay.com/v2/coupons/get
528
+ *
529
+ * @reference https://docs.abacatepay.com/pages/coupons/get
530
+ */
531
+ export interface RESTGetCouponQueryParams {
532
+ /**
533
+ * The ID of the coupon.
534
+ */
535
+ id: string;
536
+ }
537
+ /**
538
+ * https://api.abacatepay.com/v2/coupons/get
539
+ *
540
+ * @reference https://docs.abacatepay.com/pages/coupons/get
541
+ */
542
+ export type RESTGetCouponData = APICoupon;
543
+ /**
544
+ * https://api.abacatepay.com/v2/coupons/delete
545
+ *
546
+ * @reference https://docs.abacatepay.com/pages/coupons/delete
547
+ */
548
+ export interface RESTDeleteCouponBody {
549
+ /**
550
+ * The ID of the coupon.
551
+ */
552
+ id: string;
553
+ }
554
+ /**
555
+ * https://api.abacatepay.com/v2/coupons/delete
556
+ *
557
+ * @reference https://docs.abacatepay.com/pages/coupons/delete
558
+ */
559
+ export type RESTDeleteCouponData = APICoupon;
560
+ /**
561
+ * https://api.abacatepay.com/v2/coupons/toggle
562
+ *
563
+ * @reference https://docs.abacatepay.com/pages/coupons/toggle
564
+ */
565
+ export interface RESTPatchToggleCouponStatusBody {
566
+ /**
567
+ * The ID of the coupon.
568
+ */
569
+ id: string;
570
+ }
571
+ /**
572
+ * https://api.abacatepay.com/v2/coupons/toggle
573
+ *
574
+ * @reference https://docs.abacatepay.com/pages/coupons/toggle
575
+ */
576
+ export type RESTPatchToggleCouponStatusData = APICoupon;
577
+ /**
578
+ * https://api.abacatepay.com/v2/products/create
579
+ *
580
+ * @reference https://docs.abacatepay.com/pages/products/create
581
+ */
582
+ export interface RESTPostCreateProductBody extends Pick<APIProduct, 'externalId' | 'name' | 'price' | 'currency'> {
583
+ /**
584
+ * Description for the product
585
+ */
586
+ description?: string;
587
+ }
588
+ /**
589
+ * https://api.abacatepay.com/v2/products/create
590
+ *
591
+ * @reference https://docs.abacatepay.com/pages/products/create
592
+ */
593
+ export type RESTPostCreateProductData = APIProduct;
594
+ /**
595
+ * https://api.abacatepay.com/v2/products/list
596
+ *
597
+ * @reference https://docs.abacatepay.com/pages/products/list
598
+ */
599
+ export interface RESTGetListProductsQueryParams {
600
+ /**
601
+ * Page number.
602
+ */
603
+ page?: number;
604
+ /**
605
+ * Limit of products to return.
606
+ */
607
+ limit?: number;
608
+ }
609
+ /**
610
+ * https://api.abacatepay.com/v2/products/list
611
+ *
612
+ * @reference https://docs.abacatepay.com/pages/products/list
613
+ */
614
+ export type RESTGetListProductsData = APIProduct[];
615
+ /**
616
+ * https://api.abacatepay.com/v2/products/get
617
+ *
618
+ * @reference https://docs.abacatepay.com/pages/products/get
619
+ */
620
+ export interface RESTGetProductQueryParams {
621
+ /**
622
+ * The product ID.
623
+ */
624
+ id?: string;
625
+ /**
626
+ * External ID of the product.
627
+ */
628
+ externalId?: string;
629
+ }
630
+ /**
631
+ * https://api.abacatepay.com/v2/products/get
632
+ *
633
+ * @reference https://docs.abacatepay.com/pages/products/get
634
+ */
635
+ export type RESTGetProductData = APIProduct;
636
+ /**
637
+ * https://api.abacatepay.com/v2/subscriptions/create
638
+ *
639
+ * @reference https://docs.abacatepay.com/pages/subscriptions/create
640
+ */
641
+ export interface RESTPostCreateSubscriptionBody extends Pick<APISubscription, 'amount' | 'name' | 'externalId' | 'method' | 'frequency' | 'customerId' | 'retryPolicy'> {
642
+ /**
643
+ * Subscription description.
644
+ */
645
+ description?: string;
646
+ }
647
+ /**
648
+ * https://api.abacatepay.com/v2/subscriptions/create
649
+ *
650
+ * @reference https://docs.abacatepay.com/pages/subscriptions/create
651
+ */
652
+ export type RESTPostCreateSubscriptionData = APISubscription;
653
+ /**
654
+ * https://api.abacatepay.com/v2/subscriptions/list
655
+ *
656
+ * @reference https://docs.abacatepay.com/pages/subscriptions/list
657
+ */
658
+ export interface RESTGetListSubscriptionsQueryParams {
659
+ /**
660
+ * Cursor for the pagination.
661
+ */
662
+ cursor?: string;
663
+ /**
664
+ * Number of items per page.
665
+ *
666
+ * @default 20
667
+ */
668
+ limit?: number;
669
+ }
670
+ /**
671
+ * https://api.abacatepay.com/v2/subscriptions/list
672
+ *
673
+ * @reference https://docs.abacatepay.com/pages/subscriptions/list
674
+ */
675
+ export type RESTGetListSubscriptionsData = APISubscription[];
@@ -0,0 +1 @@
1
+ export {};