@abacatepay/types 2.0.0 → 2.0.2
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 +30 -25
- package/dist/v1/rest.d.ts +0 -1
- package/dist/v2/entities/coupon.d.ts +1 -1
- package/dist/v2/entities/store.d.ts +1 -1
- package/dist/v2/entities/subscription.d.ts +1 -1
- package/dist/v2/index.d.ts +1 -0
- package/dist/v2/index.js +1 -0
- package/dist/v2/rest.d.ts +51 -21
- package/dist/v2/routes.d.ts +4 -4
- package/dist/v2/routes.js +6 -2
- package/dist/v2/utils.d.ts +13 -13
- package/dist/v2/utils.js +13 -13
- package/dist/v2/webhook.d.ts +2 -2
- package/dist/version.d.ts +7 -1
- package/dist/version.js +7 -1
- package/package.json +14 -2
package/README.md
CHANGED
|
@@ -2,41 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
## AbacatePay API Types
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
O [@abacatepay/types](https://www.npmjs.com/package/@abacatepay/types) fornece **tipagens oficiais** e **helpers modernos** para trabalhar com a API da AbacatePay de forma **segura**, **previsível** e **alinhada** à documentação oficial.
|
|
6
|
+
|
|
7
|
+
O pacote é **TypeScript-first** e serve como base para integrações diretas via **fetch**, **SDKs** internos, **CLIs** e validações em **aplicações** backend.
|
|
6
8
|
|
|
7
9
|
<img src="https://res.cloudinary.com/dkok1obj5/image/upload/v1767631413/avo_clhmaf.png" width="100%" alt="AbacatePay Open Source"/>
|
|
8
10
|
|
|
9
11
|
## Instalação
|
|
10
12
|
|
|
11
|
-
Use
|
|
13
|
+
Use o *package manager* da sua preferência:
|
|
12
14
|
|
|
13
15
|
</div>
|
|
14
16
|
|
|
15
17
|
```bash
|
|
16
18
|
bun add @abacatepay/types
|
|
19
|
+
# ou
|
|
17
20
|
pnpm add @abacatepay/types
|
|
21
|
+
# ou
|
|
18
22
|
npm install @abacatepay/types
|
|
19
23
|
```
|
|
20
24
|
|
|
21
25
|
<div align="center">
|
|
22
26
|
|
|
23
|
-
##
|
|
27
|
+
## Versionamento dos Tipos
|
|
24
28
|
|
|
25
|
-
Antes de tudo, você deve
|
|
29
|
+
Antes de tudo, você deve especificar a versão da API que deseja usar, adicionando **/v*** na importação:
|
|
26
30
|
|
|
27
31
|
</div>
|
|
28
32
|
|
|
29
33
|
```ts
|
|
30
|
-
import { APICustomer } from '@abacatepay/types/
|
|
34
|
+
import { APICustomer } from '@abacatepay/types/v2';
|
|
31
35
|
```
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
<p align="center">Para tipos globais como <code>API_BASE_URL</code>, <code>API_VERSION</code>, <code>version</code> e <code>Routes</code>, apenas import normalmente sem a versão.</p>
|
|
37
|
+
<p align="center">Tipos e constantes globais não são versionados e devem ser importados diretamente sem a versão:</p>
|
|
35
38
|
|
|
36
39
|
```ts
|
|
37
|
-
import { version } from '@abacatepay/types'
|
|
40
|
+
import { version, API_BASE_URL, API_VERSION } from '@abacatepay/types';
|
|
38
41
|
```
|
|
39
42
|
|
|
43
|
+
## Como a AbacatePay API Types documenta
|
|
44
|
+
|
|
40
45
|
- Prefixo `API*`
|
|
41
46
|
Representa estruturas gerais da API (Objetos retornados, modelos internos etc.).
|
|
42
47
|
|
|
@@ -69,36 +74,33 @@ São campos que não têm definição formal na documentação, mas cujo tipo fo
|
|
|
69
74
|
|
|
70
75
|
```ts
|
|
71
76
|
import {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
} from '@abacatepay/types/v1';
|
|
77
|
+
Routes,
|
|
78
|
+
type APICoupon,
|
|
79
|
+
type RESTPostCreateCouponBody,
|
|
80
|
+
} from '@abacatepay/types/v2';
|
|
81
|
+
import { REST } from '@abacatepay/rest';
|
|
78
82
|
|
|
79
|
-
|
|
80
|
-
const path = `${API_BASE_URL}/${API_VERSION}/${Routes.coupon.create}`;
|
|
81
|
-
|
|
82
|
-
const response = await fetch(path, {
|
|
83
|
-
method: 'POST',
|
|
84
|
-
body: JSON.stringify(body),
|
|
85
|
-
});
|
|
83
|
+
const client = new REST({ secret });
|
|
86
84
|
|
|
87
|
-
|
|
85
|
+
async function createCoupon(body: RESTPostCreateCouponBody) {
|
|
86
|
+
const data = await client.post<APICoupon>(Routes.coupons.create, { body });
|
|
88
87
|
|
|
89
|
-
|
|
88
|
+
return data;
|
|
90
89
|
}
|
|
91
90
|
```
|
|
92
91
|
|
|
93
92
|
<p align="center"><strong>Crie um servidor e escute eventos de Webhooks do Aabacate</strong></p>
|
|
94
93
|
|
|
95
94
|
```ts
|
|
96
|
-
import {
|
|
95
|
+
import { WebhookEvent } from '@abacatepay/zod/v2';
|
|
96
|
+
import { WebhookEventType } from '@abacatepay/types/v2';
|
|
97
97
|
|
|
98
98
|
Bun.serve({
|
|
99
99
|
routes: {
|
|
100
100
|
async '/webhooks/abacate'(request) {
|
|
101
|
-
const
|
|
101
|
+
const raw = await request.json();
|
|
102
|
+
|
|
103
|
+
const { data, event } = WebhookEvent.parse(raw);
|
|
102
104
|
|
|
103
105
|
switch (event) {
|
|
104
106
|
case WebhookEventType.BillingPaid:
|
|
@@ -118,3 +120,6 @@ Bun.serve({
|
|
|
118
120
|
},
|
|
119
121
|
});
|
|
120
122
|
```
|
|
123
|
+
|
|
124
|
+
<p align="center">Feito com 🥑 pela equipe AbacatePay</br>
|
|
125
|
+
Open source, de verdade.</p>
|
package/dist/v1/rest.d.ts
CHANGED
|
@@ -86,7 +86,6 @@ export interface RESTPostCreateNewChargeBody {
|
|
|
86
86
|
*/
|
|
87
87
|
customerId?: string;
|
|
88
88
|
/**
|
|
89
|
-
* /**
|
|
90
89
|
* Your customer's data to create it.
|
|
91
90
|
* The customer object is not mandatory, but when entering any `customer` information, all `name`, `cellphone`, `email` and `taxId` fields are mandatory.
|
|
92
91
|
*/
|
|
@@ -27,7 +27,7 @@ export interface APICoupon {
|
|
|
27
27
|
/**
|
|
28
28
|
* Counter of how many times the coupon has been used by customers.
|
|
29
29
|
*/
|
|
30
|
-
redeemsCount:
|
|
30
|
+
redeemsCount: number;
|
|
31
31
|
/**
|
|
32
32
|
* Indicates whether the coupon was created in a development (true) or production (false) environment.
|
|
33
33
|
*/
|
|
@@ -15,7 +15,7 @@ export interface APIStore {
|
|
|
15
15
|
/**
|
|
16
16
|
* Object containing information about your account balances.
|
|
17
17
|
*
|
|
18
|
-
* @remarks All balance values are returned in cents. To convert to Reais, divide by 100. For example: 15000 cents = R$150.00
|
|
18
|
+
* @remarks All balance values are returned in cents. To convert to Reais, divide by 100. For example: 15000 cents = R$150.00.
|
|
19
19
|
*/
|
|
20
20
|
balance: {
|
|
21
21
|
/**
|
package/dist/v2/index.d.ts
CHANGED
package/dist/v2/index.js
CHANGED
package/dist/v2/rest.d.ts
CHANGED
|
@@ -2,73 +2,93 @@ import type { APICheckout, APICoupon, APICustomer, APIPayout, APIQRCodePIX, APIS
|
|
|
2
2
|
import type { APIProduct } from './entities/products';
|
|
3
3
|
import type { APISubscription } from './entities/subscription';
|
|
4
4
|
/**
|
|
5
|
-
* Any response returned by the AbacatePay API
|
|
5
|
+
* Any response returned by the AbacatePay API.
|
|
6
6
|
*/
|
|
7
7
|
export type APIResponse<Data> = {
|
|
8
8
|
/**
|
|
9
|
-
* The data of the response
|
|
9
|
+
* The data of the response.
|
|
10
10
|
*/
|
|
11
11
|
data: Data;
|
|
12
12
|
error: null;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the request was successful or not.
|
|
15
|
+
*/
|
|
16
|
+
success: true;
|
|
13
17
|
} | {
|
|
14
18
|
data: null;
|
|
15
19
|
/**
|
|
16
|
-
* Error message returned from the API
|
|
20
|
+
* Error message returned from the API.
|
|
17
21
|
*/
|
|
18
22
|
error: string;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the request was successful or not.
|
|
25
|
+
*/
|
|
26
|
+
success: false;
|
|
19
27
|
};
|
|
20
28
|
/**
|
|
21
|
-
* Any response returned by the AbacatePay API that has a `pagination` field (Not cursor based)
|
|
29
|
+
* Any response returned by the AbacatePay API that has a `pagination` field (Not cursor based).
|
|
22
30
|
*/
|
|
23
31
|
export type APIResponseWithPagination<Data> = {
|
|
24
32
|
/**
|
|
25
|
-
* The data of the response
|
|
33
|
+
* The data of the response.
|
|
26
34
|
*/
|
|
27
35
|
data: Data;
|
|
28
36
|
error: null;
|
|
29
37
|
/**
|
|
30
|
-
*
|
|
38
|
+
* Whether the request was successful or not.
|
|
39
|
+
*/
|
|
40
|
+
success: true;
|
|
41
|
+
/**
|
|
42
|
+
* Pagination info.
|
|
31
43
|
*/
|
|
32
44
|
pagination: {
|
|
33
45
|
/**
|
|
34
|
-
* Current page
|
|
46
|
+
* Current page.
|
|
35
47
|
*/
|
|
36
48
|
page: number;
|
|
37
49
|
/**
|
|
38
|
-
* Number of items per page
|
|
50
|
+
* Number of items per page.
|
|
39
51
|
*/
|
|
40
52
|
limit: number;
|
|
41
53
|
/**
|
|
42
|
-
* Number of items
|
|
54
|
+
* Number of items.
|
|
43
55
|
*/
|
|
44
56
|
items: number;
|
|
45
57
|
/**
|
|
46
|
-
* Number of pages
|
|
58
|
+
* Number of pages.
|
|
47
59
|
*/
|
|
48
60
|
totalPages: number;
|
|
49
61
|
};
|
|
50
62
|
} | {
|
|
51
63
|
data: null;
|
|
52
64
|
/**
|
|
53
|
-
* Error message returned from the API
|
|
65
|
+
* Error message returned from the API.
|
|
54
66
|
*/
|
|
55
67
|
error: string;
|
|
68
|
+
/**
|
|
69
|
+
* Whether the request was successful or not.
|
|
70
|
+
*/
|
|
71
|
+
success: false;
|
|
56
72
|
};
|
|
57
73
|
/**
|
|
58
|
-
* Any response returned by the AbacatePay API that has a `pagination` field and is cursor-based
|
|
74
|
+
* Any response returned by the AbacatePay API that has a `pagination` field and is cursor-based.
|
|
59
75
|
*/
|
|
60
76
|
export type APIResponseWithCursorBasedPagination<Data> = {
|
|
61
77
|
/**
|
|
62
|
-
* The data of the response
|
|
78
|
+
* The data of the response.
|
|
63
79
|
*/
|
|
64
80
|
data: Data;
|
|
65
81
|
error: null;
|
|
66
82
|
/**
|
|
67
|
-
*
|
|
83
|
+
* Whether the request was successful or not.
|
|
84
|
+
*/
|
|
85
|
+
success: true;
|
|
86
|
+
/**
|
|
87
|
+
* Pagination info.
|
|
68
88
|
*/
|
|
69
89
|
pagination: {
|
|
70
90
|
/**
|
|
71
|
-
* Number of items per page
|
|
91
|
+
* Number of items per page.
|
|
72
92
|
*/
|
|
73
93
|
limit: number;
|
|
74
94
|
/**
|
|
@@ -80,16 +100,20 @@ export type APIResponseWithCursorBasedPagination<Data> = {
|
|
|
80
100
|
*/
|
|
81
101
|
hasPrevious: boolean;
|
|
82
102
|
/**
|
|
83
|
-
* Cursor for the next page
|
|
103
|
+
* Cursor for the next page.
|
|
84
104
|
*/
|
|
85
105
|
nextCursor: string | null;
|
|
86
106
|
};
|
|
87
107
|
} | {
|
|
88
108
|
data: null;
|
|
89
109
|
/**
|
|
90
|
-
* Error message returned from the API
|
|
110
|
+
* Error message returned from the API.
|
|
91
111
|
*/
|
|
92
112
|
error: string;
|
|
113
|
+
/**
|
|
114
|
+
* Whether the request was successful or not.
|
|
115
|
+
*/
|
|
116
|
+
success: false;
|
|
93
117
|
};
|
|
94
118
|
/**
|
|
95
119
|
* https://api.abacatepay.com/v2/customers/create
|
|
@@ -336,7 +360,7 @@ export interface RESTPostCreateCouponBody {
|
|
|
336
360
|
*/
|
|
337
361
|
discountKind: CouponDiscountKind;
|
|
338
362
|
/**
|
|
339
|
-
* Coupon description
|
|
363
|
+
* Coupon description.
|
|
340
364
|
*/
|
|
341
365
|
notes?: string;
|
|
342
366
|
/**
|
|
@@ -392,6 +416,12 @@ export interface RESTGetSearchPayoutQueryParams {
|
|
|
392
416
|
*/
|
|
393
417
|
externalId: string;
|
|
394
418
|
}
|
|
419
|
+
/**
|
|
420
|
+
* https://api.abacatepay.com/v2/payouts/get
|
|
421
|
+
*
|
|
422
|
+
* @reference https://docs.abacatepay.com/pages/payouts/get
|
|
423
|
+
*/
|
|
424
|
+
export type RESTGetSearchPayoutData = APIPayout;
|
|
395
425
|
/**
|
|
396
426
|
* https://api.abacatepay.com/v2/payouts/list
|
|
397
427
|
*
|
|
@@ -399,13 +429,13 @@ export interface RESTGetSearchPayoutQueryParams {
|
|
|
399
429
|
*/
|
|
400
430
|
export interface RESTGetListPayoutsQueryParams {
|
|
401
431
|
/**
|
|
402
|
-
* Number of the page
|
|
432
|
+
* Number of the page.
|
|
403
433
|
*
|
|
404
434
|
* @default 1
|
|
405
435
|
*/
|
|
406
436
|
page?: number;
|
|
407
437
|
/**
|
|
408
|
-
* Number of items per page
|
|
438
|
+
* Number of items per page.
|
|
409
439
|
*
|
|
410
440
|
* @default 20
|
|
411
441
|
*/
|
|
@@ -581,7 +611,7 @@ export type RESTPatchToggleCouponStatusData = APICoupon;
|
|
|
581
611
|
*/
|
|
582
612
|
export interface RESTPostCreateProductBody extends Pick<APIProduct, 'externalId' | 'name' | 'price' | 'currency'> {
|
|
583
613
|
/**
|
|
584
|
-
* Description for the product
|
|
614
|
+
* Description for the product.
|
|
585
615
|
*/
|
|
586
616
|
description?: string;
|
|
587
617
|
}
|
package/dist/v2/routes.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RESTGetListPayoutsQueryParams, RESTGetListSubscriptionsQueryParams, RESTGetProductQueryParams } from './rest';
|
|
1
|
+
import type { RESTGetListCouponsQueryParams, RESTGetListCustomersQueryParams, RESTGetListPayoutsQueryParams, RESTGetListProductsQueryParams, RESTGetListSubscriptionsQueryParams, RESTGetProductQueryParams } from './rest';
|
|
2
2
|
export declare const Routes: {
|
|
3
3
|
readonly customers: {
|
|
4
4
|
/**
|
|
@@ -8,7 +8,7 @@ export declare const Routes: {
|
|
|
8
8
|
/**
|
|
9
9
|
* GET - https://api.abacatepay.com/v2/customers/list
|
|
10
10
|
*/
|
|
11
|
-
readonly list:
|
|
11
|
+
readonly list: ({ page, limit }?: RESTGetListCustomersQueryParams) => `/customers/list?page=${number}&limit=${number}`;
|
|
12
12
|
/**
|
|
13
13
|
* GET - https://api.abacatepay.com/v2/customers/get
|
|
14
14
|
*/
|
|
@@ -54,7 +54,7 @@ export declare const Routes: {
|
|
|
54
54
|
/**
|
|
55
55
|
* GET - https://api.abacatepay.com/v2/coupons/list
|
|
56
56
|
*/
|
|
57
|
-
readonly list:
|
|
57
|
+
readonly list: ({ page, limit }?: RESTGetListCouponsQueryParams) => `/coupons/list?page=${number}&limit=${number}`;
|
|
58
58
|
/**
|
|
59
59
|
* GET - https://api.abacatepay.com/v2/coupons/get
|
|
60
60
|
*/
|
|
@@ -120,7 +120,7 @@ export declare const Routes: {
|
|
|
120
120
|
/**
|
|
121
121
|
* GET - https://api.abacatepay.com/v2/products/list
|
|
122
122
|
*/
|
|
123
|
-
readonly list: ({ page, limit }?:
|
|
123
|
+
readonly list: ({ page, limit }?: RESTGetListProductsQueryParams) => `/products/list?page=${number}&limit=${number}`;
|
|
124
124
|
/**
|
|
125
125
|
* GET - https://api.abacatepay.com/v2/products/get
|
|
126
126
|
*/
|
package/dist/v2/routes.js
CHANGED
|
@@ -7,7 +7,9 @@ export const Routes = {
|
|
|
7
7
|
/**
|
|
8
8
|
* GET - https://api.abacatepay.com/v2/customers/list
|
|
9
9
|
*/
|
|
10
|
-
list
|
|
10
|
+
list({ page = 1, limit = 20 } = {}) {
|
|
11
|
+
return `/customers/list?page=${page}&limit=${limit}`;
|
|
12
|
+
},
|
|
11
13
|
/**
|
|
12
14
|
* GET - https://api.abacatepay.com/v2/customers/get
|
|
13
15
|
*/
|
|
@@ -61,7 +63,9 @@ export const Routes = {
|
|
|
61
63
|
/**
|
|
62
64
|
* GET - https://api.abacatepay.com/v2/coupons/list
|
|
63
65
|
*/
|
|
64
|
-
list
|
|
66
|
+
list({ page = 1, limit = 20 } = {}) {
|
|
67
|
+
return `/coupons/list?page=${page}&limit=${limit}`;
|
|
68
|
+
},
|
|
65
69
|
/**
|
|
66
70
|
* GET - https://api.abacatepay.com/v2/coupons/get
|
|
67
71
|
*/
|
package/dist/v2/utils.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { type WebhookEvent } from './webhook';
|
|
2
2
|
/**
|
|
3
|
-
* A type guard check for `payout.done` webhook events
|
|
4
|
-
* @param event - The webhook event to check against
|
|
5
|
-
* @returns A boolean that indicates if the webhook is a payout done webhook
|
|
3
|
+
* A type guard check for `payout.done` webhook events.
|
|
4
|
+
* @param event - The webhook event to check against.
|
|
5
|
+
* @returns A boolean that indicates if the webhook is a payout done webhook.
|
|
6
6
|
*/
|
|
7
7
|
export declare function isPayoutDoneWebhookEvent(event: WebhookEvent): event is import("./webhook").WebhookPayoutDoneEvent;
|
|
8
8
|
/**
|
|
9
|
-
* A type guard check for `payout.failed` webhook events
|
|
10
|
-
* @param event - The webhook event to check against
|
|
11
|
-
* @returns A boolean that indicates if the webhook is a payout failed webhook
|
|
9
|
+
* A type guard check for `payout.failed` webhook events.
|
|
10
|
+
* @param event - The webhook event to check against.
|
|
11
|
+
* @returns A boolean that indicates if the webhook is a payout failed webhook.
|
|
12
12
|
*/
|
|
13
13
|
export declare function isPayoutFailedWebhookEvent(event: WebhookEvent): event is import("./webhook").WebhookPayoutFailedEvent;
|
|
14
14
|
/**
|
|
15
|
-
* A type guard check for `billing.paid` webhook events
|
|
16
|
-
* @param event - The webhook event to check against
|
|
17
|
-
* @returns A boolean that indicates if the webhook is a billing paid webhook
|
|
15
|
+
* A type guard check for `billing.paid` webhook events.
|
|
16
|
+
* @param event - The webhook event to check against.
|
|
17
|
+
* @returns A boolean that indicates if the webhook is a billing paid webhook.
|
|
18
18
|
*/
|
|
19
19
|
export declare function isBillingPaidWebhookEvent(event: WebhookEvent): event is import("./webhook").WebhookBillingPaidEvent;
|
|
20
20
|
/**
|
|
21
|
-
* Verify whether the signature is valid or not
|
|
22
|
-
* @param raw Raw body response (string)
|
|
23
|
-
* @param signature The content of the`X-Webhook-Signature` header
|
|
24
|
-
* @returns A boolean that indicates if the signature is valid
|
|
21
|
+
* Verify whether the signature is valid or not.
|
|
22
|
+
* @param raw Raw body response (string).
|
|
23
|
+
* @param signature The content of the`X-Webhook-Signature` header.
|
|
24
|
+
* @returns A boolean that indicates if the signature is valid.
|
|
25
25
|
*/
|
|
26
26
|
export declare const verifyWebhookSignature: (raw: string, signature: string) => boolean;
|
package/dist/v2/utils.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
2
2
|
import { WebhookEventType } from './webhook';
|
|
3
3
|
/**
|
|
4
|
-
* A type guard check for `payout.done` webhook events
|
|
5
|
-
* @param event - The webhook event to check against
|
|
6
|
-
* @returns A boolean that indicates if the webhook is a payout done webhook
|
|
4
|
+
* A type guard check for `payout.done` webhook events.
|
|
5
|
+
* @param event - The webhook event to check against.
|
|
6
|
+
* @returns A boolean that indicates if the webhook is a payout done webhook.
|
|
7
7
|
*/
|
|
8
8
|
export function isPayoutDoneWebhookEvent(event) {
|
|
9
9
|
return event.event === WebhookEventType.PayoutDone;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* A type guard check for `payout.failed` webhook events
|
|
13
|
-
* @param event - The webhook event to check against
|
|
14
|
-
* @returns A boolean that indicates if the webhook is a payout failed webhook
|
|
12
|
+
* A type guard check for `payout.failed` webhook events.
|
|
13
|
+
* @param event - The webhook event to check against.
|
|
14
|
+
* @returns A boolean that indicates if the webhook is a payout failed webhook.
|
|
15
15
|
*/
|
|
16
16
|
export function isPayoutFailedWebhookEvent(event) {
|
|
17
17
|
return event.event === WebhookEventType.PayoutFailed;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* A type guard check for `billing.paid` webhook events
|
|
21
|
-
* @param event - The webhook event to check against
|
|
22
|
-
* @returns A boolean that indicates if the webhook is a billing paid webhook
|
|
20
|
+
* A type guard check for `billing.paid` webhook events.
|
|
21
|
+
* @param event - The webhook event to check against.
|
|
22
|
+
* @returns A boolean that indicates if the webhook is a billing paid webhook.
|
|
23
23
|
*/
|
|
24
24
|
export function isBillingPaidWebhookEvent(event) {
|
|
25
25
|
return event.event === WebhookEventType.BillingPaid;
|
|
26
26
|
}
|
|
27
27
|
const ABACATEPAY_PUBLIC_KEY = 't9dXRhHHo3yDEj5pVDYz0frf7q6bMKyMRmxxCPIPp3RCplBfXRxqlC6ZpiWmOqj4L63qEaeUOtrCI8P0VMUgo6iIga2ri9ogaHFs0WIIywSMg0q7RmBfybe1E5XJcfC4IW3alNqym0tXoAKkzvfEjZxV6bE0oG2zJrNNYmUCKZyV0KZ3JS8Votf9EAWWYdiDkMkpbMdPggfh1EqHlVkMiTady6jOR3hyzGEHrIz2Ret0xHKMbiqkr9HS1JhNHDX9';
|
|
28
28
|
/**
|
|
29
|
-
* Verify whether the signature is valid or not
|
|
30
|
-
* @param raw Raw body response (string)
|
|
31
|
-
* @param signature The content of the`X-Webhook-Signature` header
|
|
32
|
-
* @returns A boolean that indicates if the signature is valid
|
|
29
|
+
* Verify whether the signature is valid or not.
|
|
30
|
+
* @param raw Raw body response (string).
|
|
31
|
+
* @param signature The content of the`X-Webhook-Signature` header.
|
|
32
|
+
* @returns A boolean that indicates if the signature is valid.
|
|
33
33
|
*/
|
|
34
34
|
export const verifyWebhookSignature = (raw, signature) => {
|
|
35
35
|
const bodyBuffer = Buffer.from(raw, 'utf8');
|
package/dist/v2/webhook.d.ts
CHANGED
|
@@ -83,11 +83,11 @@ export type WebhookBillingPaidEvent = BaseWebhookEvent<WebhookEventType.BillingP
|
|
|
83
83
|
*/
|
|
84
84
|
id: string;
|
|
85
85
|
/**
|
|
86
|
-
* Kind of the payment
|
|
86
|
+
* Kind of the payment.
|
|
87
87
|
*/
|
|
88
88
|
kind: 'PIX';
|
|
89
89
|
/**
|
|
90
|
-
* Billing status, can only be `PAID` here
|
|
90
|
+
* Billing status, can only be `PAID` here.
|
|
91
91
|
*
|
|
92
92
|
* @see {@link PaymentStatus.Paid}
|
|
93
93
|
*/
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Current version of [@abacatepay/types](https://www.npmjs.com/package/@abacatepay/types).
|
|
3
|
+
*/
|
|
4
|
+
export declare const version: "2.0.2";
|
|
5
|
+
/**
|
|
6
|
+
* Current version of the AbacatePay API.
|
|
7
|
+
*/
|
|
2
8
|
export declare const API_VERSION: "2";
|
package/dist/version.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
// AUTO-GENERATED — DO NOT EDIT
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Current version of [@abacatepay/types](https://www.npmjs.com/package/@abacatepay/types).
|
|
4
|
+
*/
|
|
5
|
+
export const version = '2.0.2';
|
|
6
|
+
/**
|
|
7
|
+
* Current version of the AbacatePay API.
|
|
8
|
+
*/
|
|
3
9
|
export const API_VERSION = '2';
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.0.
|
|
2
|
+
"version": "2.0.2",
|
|
3
3
|
"name": "@abacatepay/types",
|
|
4
4
|
"description": "Abacate Pay API typings that are always up to date.",
|
|
5
5
|
"type": "module",
|
|
@@ -46,12 +46,24 @@
|
|
|
46
46
|
"build": "bun run gen:version && tsc",
|
|
47
47
|
"prepublishOnly": "bun run build",
|
|
48
48
|
"gen:version": "bun run scripts/version.ts",
|
|
49
|
+
"test": "bun test",
|
|
49
50
|
"fmt": "bunx biome check --write package.json types && clear"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"@biomejs/biome": "^2.3.8",
|
|
53
54
|
"typescript": "^5.9.3"
|
|
54
55
|
},
|
|
56
|
+
"author": {
|
|
57
|
+
"name": "AbacatePay",
|
|
58
|
+
"email": "opensource@abacatepay.com",
|
|
59
|
+
"url": "https://abacatepay.com"
|
|
60
|
+
},
|
|
61
|
+
"maintainers": [
|
|
62
|
+
{
|
|
63
|
+
"name": "Almeida",
|
|
64
|
+
"url": "https://github.com/almeidazs"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
55
67
|
"keywords": [
|
|
56
68
|
"api",
|
|
57
69
|
"abacatepay",
|
|
@@ -63,6 +75,6 @@
|
|
|
63
75
|
},
|
|
64
76
|
"repository": {
|
|
65
77
|
"type": "git",
|
|
66
|
-
"url": "https://github.com/
|
|
78
|
+
"url": "git+https://github.com/AbacatePay/ecosystem.git"
|
|
67
79
|
}
|
|
68
80
|
}
|