@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.
- package/README.md +21 -13
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -1
- package/dist/v1/routes.d.ts +81 -0
- package/dist/v1/routes.js +86 -0
- package/dist/v1/utils.d.ts +19 -0
- package/dist/v1/utils.js +25 -0
- package/dist/v2/entities/checkout.d.ts +106 -0
- package/dist/v2/entities/checkout.js +29 -0
- package/dist/v2/entities/coupon.d.ts +63 -0
- package/dist/v2/entities/coupon.js +14 -0
- package/dist/v2/entities/customer.d.ts +41 -0
- package/dist/v2/entities/customer.js +1 -0
- package/dist/v2/entities/payout.d.ts +51 -0
- package/dist/v2/entities/payout.js +11 -0
- package/dist/v2/entities/pix.d.ts +48 -0
- package/dist/v2/entities/pix.js +1 -0
- package/dist/v2/entities/products.d.ts +49 -0
- package/dist/v2/entities/products.js +5 -0
- package/dist/v2/entities/store.d.ts +36 -0
- package/dist/v2/entities/store.js +1 -0
- package/dist/v2/entities/subscription.d.ts +110 -0
- package/dist/v2/entities/subscription.js +8 -0
- package/dist/v2/index.d.ts +11 -0
- package/dist/v2/index.js +11 -0
- package/dist/v2/rest.d.ts +675 -0
- package/dist/v2/rest.js +1 -0
- package/dist/v2/routes.d.ts +129 -0
- package/dist/v2/routes.js +158 -0
- package/dist/v2/utils.d.ts +26 -0
- package/dist/v2/utils.js +42 -0
- package/dist/v2/webhook.d.ts +135 -0
- package/dist/v2/webhook.js +9 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +3 -4
- package/package.json +29 -5
- package/dist/routes.d.ts +0 -68
- package/dist/routes.js +0 -99
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { RESTGetListPayoutsQueryParams, RESTGetListSubscriptionsQueryParams, RESTGetProductQueryParams } from './rest';
|
|
2
|
+
export declare const Routes: {
|
|
3
|
+
readonly customers: {
|
|
4
|
+
/**
|
|
5
|
+
* POST - https://api.abacatepay.com/v2/customers/create
|
|
6
|
+
*/
|
|
7
|
+
readonly create: "/customers/create";
|
|
8
|
+
/**
|
|
9
|
+
* GET - https://api.abacatepay.com/v2/customers/list
|
|
10
|
+
*/
|
|
11
|
+
readonly list: "/customers/list";
|
|
12
|
+
/**
|
|
13
|
+
* GET - https://api.abacatepay.com/v2/customers/get
|
|
14
|
+
*/
|
|
15
|
+
readonly get: (id: string) => `/customers/get?id=${string}`;
|
|
16
|
+
/**
|
|
17
|
+
* DELETE - https://api.abacatepay.com/v2/customers/delete
|
|
18
|
+
*/
|
|
19
|
+
readonly delete: "/customers/delete";
|
|
20
|
+
};
|
|
21
|
+
readonly checkouts: {
|
|
22
|
+
/**
|
|
23
|
+
* POST - https://api.abacatepay.com/v2/checkouts/create
|
|
24
|
+
*/
|
|
25
|
+
readonly create: "/checkouts/create";
|
|
26
|
+
/**
|
|
27
|
+
* GET - https://api.abacatepay.com/v2/checkouts/list
|
|
28
|
+
*/
|
|
29
|
+
readonly list: "/checkouts/list";
|
|
30
|
+
/**
|
|
31
|
+
* GET - https://api.abacatepay.com/v2/checkouts/get
|
|
32
|
+
*/
|
|
33
|
+
readonly get: (id: string) => `/checkouts/get?id=${string}`;
|
|
34
|
+
};
|
|
35
|
+
readonly transparents: {
|
|
36
|
+
/**
|
|
37
|
+
* POST - https://api.abacatepay.com/v2/transparents/create
|
|
38
|
+
*/
|
|
39
|
+
readonly createQRCode: "/transparents/create";
|
|
40
|
+
/**
|
|
41
|
+
* POST - https://api.abacatepay.com/v2/transparents/simulate-payment
|
|
42
|
+
*/
|
|
43
|
+
readonly simulatePayment: (id: string) => `/transparents/simulate-payment?id=${string}`;
|
|
44
|
+
/**
|
|
45
|
+
* GET - https://api.abacatepay.com/v2/transparents/check
|
|
46
|
+
*/
|
|
47
|
+
readonly checkStatus: (id: string) => `/transparents/check?id=${string}`;
|
|
48
|
+
};
|
|
49
|
+
readonly coupons: {
|
|
50
|
+
/**
|
|
51
|
+
* POST - https://api.abacatepay.com/v2/coupons/create
|
|
52
|
+
*/
|
|
53
|
+
readonly create: "/coupons/create";
|
|
54
|
+
/**
|
|
55
|
+
* GET - https://api.abacatepay.com/v2/coupons/list
|
|
56
|
+
*/
|
|
57
|
+
readonly list: "/coupons/list";
|
|
58
|
+
/**
|
|
59
|
+
* GET - https://api.abacatepay.com/v2/coupons/get
|
|
60
|
+
*/
|
|
61
|
+
readonly get: (id: string) => `/coupons/get?id=${string}`;
|
|
62
|
+
/**
|
|
63
|
+
* DELETE - https://api.abacatepay.com/v2/coupons/delete
|
|
64
|
+
*/
|
|
65
|
+
readonly delete: "/coupons/delete";
|
|
66
|
+
/**
|
|
67
|
+
* PATCH - https://api.abacatepay.com/v2/coupons/toggle
|
|
68
|
+
*/
|
|
69
|
+
readonly toggleStatus: "/coupons/toggle";
|
|
70
|
+
};
|
|
71
|
+
readonly payouts: {
|
|
72
|
+
/**
|
|
73
|
+
* POST - https://api.abacatepay.com/v2/payouts/create
|
|
74
|
+
*/
|
|
75
|
+
readonly create: "/payouts/create";
|
|
76
|
+
/**
|
|
77
|
+
* GET - https://api.abacatepay.com/v2/payouts/get
|
|
78
|
+
*/
|
|
79
|
+
readonly get: (externalId: string) => `/payouts/get?externalId=${string}`;
|
|
80
|
+
/**
|
|
81
|
+
* GET - https://api.abacatepay.com/v2/payouts/list
|
|
82
|
+
*/
|
|
83
|
+
readonly list: ({ page, limit }?: RESTGetListPayoutsQueryParams) => string;
|
|
84
|
+
};
|
|
85
|
+
readonly store: {
|
|
86
|
+
/**
|
|
87
|
+
* GET - https://api.abacatepay.com/v2/store/get
|
|
88
|
+
*/
|
|
89
|
+
readonly get: "/store/get";
|
|
90
|
+
};
|
|
91
|
+
readonly mrr: {
|
|
92
|
+
/**
|
|
93
|
+
* GET - https://api.abacatepay.com/v2/public-mrr/mrr
|
|
94
|
+
*/
|
|
95
|
+
readonly get: "/public-mrr/mrr";
|
|
96
|
+
/**
|
|
97
|
+
* GET - https://api.abacatepay.com/v2/public-mrr/merchant-info
|
|
98
|
+
*/
|
|
99
|
+
readonly merchant: "/public-mrr/merchant-info";
|
|
100
|
+
/**
|
|
101
|
+
* GET - https://api.abacatepay.com/v2/public-mrr/renevue
|
|
102
|
+
*/
|
|
103
|
+
readonly revenue: (start: string, end: string) => `/public-mrr/revenue?startDate=${string}&endDate=${string}`;
|
|
104
|
+
};
|
|
105
|
+
readonly subscriptions: {
|
|
106
|
+
/**
|
|
107
|
+
* POST - https://api.abacatepay.com/v2/subscriptions/create
|
|
108
|
+
*/
|
|
109
|
+
readonly create: "/subscriptions/create";
|
|
110
|
+
/**
|
|
111
|
+
* GET - https://api.abacatepay.com/v2/subscriptions/list
|
|
112
|
+
*/
|
|
113
|
+
readonly list: ({ cursor, limit }?: RESTGetListSubscriptionsQueryParams) => `/subscriptions/list?${string}`;
|
|
114
|
+
};
|
|
115
|
+
readonly products: {
|
|
116
|
+
/**
|
|
117
|
+
* POST - https://api.abacatepay.com/v2/products/create
|
|
118
|
+
*/
|
|
119
|
+
readonly create: "/products/create";
|
|
120
|
+
/**
|
|
121
|
+
* GET - https://api.abacatepay.com/v2/products/list
|
|
122
|
+
*/
|
|
123
|
+
readonly list: ({ page, limit }?: Record<"page" | "limit", number>) => `/products/list?page=${number}&limit=${number}`;
|
|
124
|
+
/**
|
|
125
|
+
* GET - https://api.abacatepay.com/v2/products/get
|
|
126
|
+
*/
|
|
127
|
+
readonly get: ({ id, externalId }?: RESTGetProductQueryParams) => `/products/get?${string}`;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
export const Routes = {
|
|
2
|
+
customers: {
|
|
3
|
+
/**
|
|
4
|
+
* POST - https://api.abacatepay.com/v2/customers/create
|
|
5
|
+
*/
|
|
6
|
+
create: '/customers/create',
|
|
7
|
+
/**
|
|
8
|
+
* GET - https://api.abacatepay.com/v2/customers/list
|
|
9
|
+
*/
|
|
10
|
+
list: '/customers/list',
|
|
11
|
+
/**
|
|
12
|
+
* GET - https://api.abacatepay.com/v2/customers/get
|
|
13
|
+
*/
|
|
14
|
+
get(id) {
|
|
15
|
+
return `/customers/get?id=${id}`;
|
|
16
|
+
},
|
|
17
|
+
/**
|
|
18
|
+
* DELETE - https://api.abacatepay.com/v2/customers/delete
|
|
19
|
+
*/
|
|
20
|
+
delete: '/customers/delete',
|
|
21
|
+
},
|
|
22
|
+
checkouts: {
|
|
23
|
+
/**
|
|
24
|
+
* POST - https://api.abacatepay.com/v2/checkouts/create
|
|
25
|
+
*/
|
|
26
|
+
create: '/checkouts/create',
|
|
27
|
+
/**
|
|
28
|
+
* GET - https://api.abacatepay.com/v2/checkouts/list
|
|
29
|
+
*/
|
|
30
|
+
list: '/checkouts/list',
|
|
31
|
+
/**
|
|
32
|
+
* GET - https://api.abacatepay.com/v2/checkouts/get
|
|
33
|
+
*/
|
|
34
|
+
get(id) {
|
|
35
|
+
return `/checkouts/get?id=${id}`;
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
transparents: {
|
|
39
|
+
/**
|
|
40
|
+
* POST - https://api.abacatepay.com/v2/transparents/create
|
|
41
|
+
*/
|
|
42
|
+
createQRCode: '/transparents/create',
|
|
43
|
+
/**
|
|
44
|
+
* POST - https://api.abacatepay.com/v2/transparents/simulate-payment
|
|
45
|
+
*/
|
|
46
|
+
simulatePayment(id) {
|
|
47
|
+
return `/transparents/simulate-payment?id=${id}`;
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* GET - https://api.abacatepay.com/v2/transparents/check
|
|
51
|
+
*/
|
|
52
|
+
checkStatus(id) {
|
|
53
|
+
return `/transparents/check?id=${id}`;
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
coupons: {
|
|
57
|
+
/**
|
|
58
|
+
* POST - https://api.abacatepay.com/v2/coupons/create
|
|
59
|
+
*/
|
|
60
|
+
create: '/coupons/create',
|
|
61
|
+
/**
|
|
62
|
+
* GET - https://api.abacatepay.com/v2/coupons/list
|
|
63
|
+
*/
|
|
64
|
+
list: '/coupons/list',
|
|
65
|
+
/**
|
|
66
|
+
* GET - https://api.abacatepay.com/v2/coupons/get
|
|
67
|
+
*/
|
|
68
|
+
get(id) {
|
|
69
|
+
return `/coupons/get?id=${id}`;
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
* DELETE - https://api.abacatepay.com/v2/coupons/delete
|
|
73
|
+
*/
|
|
74
|
+
delete: '/coupons/delete',
|
|
75
|
+
/**
|
|
76
|
+
* PATCH - https://api.abacatepay.com/v2/coupons/toggle
|
|
77
|
+
*/
|
|
78
|
+
toggleStatus: '/coupons/toggle',
|
|
79
|
+
},
|
|
80
|
+
payouts: {
|
|
81
|
+
/**
|
|
82
|
+
* POST - https://api.abacatepay.com/v2/payouts/create
|
|
83
|
+
*/
|
|
84
|
+
create: '/payouts/create',
|
|
85
|
+
/**
|
|
86
|
+
* GET - https://api.abacatepay.com/v2/payouts/get
|
|
87
|
+
*/
|
|
88
|
+
get(externalId) {
|
|
89
|
+
return `/payouts/get?externalId=${externalId}`;
|
|
90
|
+
},
|
|
91
|
+
/**
|
|
92
|
+
* GET - https://api.abacatepay.com/v2/payouts/list
|
|
93
|
+
*/
|
|
94
|
+
list({ page = 1, limit = 20 } = {}) {
|
|
95
|
+
return `/payouts/list?page=${page}&limit=${limit}`;
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
store: {
|
|
99
|
+
/**
|
|
100
|
+
* GET - https://api.abacatepay.com/v2/store/get
|
|
101
|
+
*/
|
|
102
|
+
get: '/store/get',
|
|
103
|
+
},
|
|
104
|
+
mrr: {
|
|
105
|
+
/**
|
|
106
|
+
* GET - https://api.abacatepay.com/v2/public-mrr/mrr
|
|
107
|
+
*/
|
|
108
|
+
get: '/public-mrr/mrr',
|
|
109
|
+
/**
|
|
110
|
+
* GET - https://api.abacatepay.com/v2/public-mrr/merchant-info
|
|
111
|
+
*/
|
|
112
|
+
merchant: '/public-mrr/merchant-info',
|
|
113
|
+
/**
|
|
114
|
+
* GET - https://api.abacatepay.com/v2/public-mrr/renevue
|
|
115
|
+
*/
|
|
116
|
+
revenue(start, end) {
|
|
117
|
+
return `/public-mrr/revenue?startDate=${start}&endDate=${end}`;
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
subscriptions: {
|
|
121
|
+
/**
|
|
122
|
+
* POST - https://api.abacatepay.com/v2/subscriptions/create
|
|
123
|
+
*/
|
|
124
|
+
create: '/subscriptions/create',
|
|
125
|
+
/**
|
|
126
|
+
* GET - https://api.abacatepay.com/v2/subscriptions/list
|
|
127
|
+
*/
|
|
128
|
+
list({ cursor, limit = 20 } = {}) {
|
|
129
|
+
const query = new URLSearchParams({ limit: `${limit}` });
|
|
130
|
+
if (cursor)
|
|
131
|
+
query.append('cursor', cursor);
|
|
132
|
+
return `/subscriptions/list?${query}`;
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
products: {
|
|
136
|
+
/**
|
|
137
|
+
* POST - https://api.abacatepay.com/v2/products/create
|
|
138
|
+
*/
|
|
139
|
+
create: '/products/create',
|
|
140
|
+
/**
|
|
141
|
+
* GET - https://api.abacatepay.com/v2/products/list
|
|
142
|
+
*/
|
|
143
|
+
list({ page = 1, limit = 20 } = {}) {
|
|
144
|
+
return `/products/list?page=${page}&limit=${limit}`;
|
|
145
|
+
},
|
|
146
|
+
/**
|
|
147
|
+
* GET - https://api.abacatepay.com/v2/products/get
|
|
148
|
+
*/
|
|
149
|
+
get({ id, externalId } = {}) {
|
|
150
|
+
const query = new URLSearchParams();
|
|
151
|
+
if (id)
|
|
152
|
+
query.append('id', id);
|
|
153
|
+
if (externalId)
|
|
154
|
+
query.append('externalId', externalId);
|
|
155
|
+
return `/products/get?${query}`;
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type WebhookEvent } from './webhook';
|
|
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
|
|
6
|
+
*/
|
|
7
|
+
export declare function isPayoutDoneWebhookEvent(event: WebhookEvent): event is import("./webhook").WebhookPayoutDoneEvent;
|
|
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
|
|
12
|
+
*/
|
|
13
|
+
export declare function isPayoutFailedWebhookEvent(event: WebhookEvent): event is import("./webhook").WebhookPayoutFailedEvent;
|
|
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
|
|
18
|
+
*/
|
|
19
|
+
export declare function isBillingPaidWebhookEvent(event: WebhookEvent): event is import("./webhook").WebhookBillingPaidEvent;
|
|
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
|
|
25
|
+
*/
|
|
26
|
+
export declare const verifyWebhookSignature: (raw: string, signature: string) => boolean;
|
package/dist/v2/utils.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { WebhookEventType } from './webhook';
|
|
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
|
|
7
|
+
*/
|
|
8
|
+
export function isPayoutDoneWebhookEvent(event) {
|
|
9
|
+
return event.event === WebhookEventType.PayoutDone;
|
|
10
|
+
}
|
|
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
|
|
15
|
+
*/
|
|
16
|
+
export function isPayoutFailedWebhookEvent(event) {
|
|
17
|
+
return event.event === WebhookEventType.PayoutFailed;
|
|
18
|
+
}
|
|
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
|
|
23
|
+
*/
|
|
24
|
+
export function isBillingPaidWebhookEvent(event) {
|
|
25
|
+
return event.event === WebhookEventType.BillingPaid;
|
|
26
|
+
}
|
|
27
|
+
const ABACATEPAY_PUBLIC_KEY = 't9dXRhHHo3yDEj5pVDYz0frf7q6bMKyMRmxxCPIPp3RCplBfXRxqlC6ZpiWmOqj4L63qEaeUOtrCI8P0VMUgo6iIga2ri9ogaHFs0WIIywSMg0q7RmBfybe1E5XJcfC4IW3alNqym0tXoAKkzvfEjZxV6bE0oG2zJrNNYmUCKZyV0KZ3JS8Votf9EAWWYdiDkMkpbMdPggfh1EqHlVkMiTady6jOR3hyzGEHrIz2Ret0xHKMbiqkr9HS1JhNHDX9';
|
|
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
|
|
33
|
+
*/
|
|
34
|
+
export const verifyWebhookSignature = (raw, signature) => {
|
|
35
|
+
const bodyBuffer = Buffer.from(raw, 'utf8');
|
|
36
|
+
const expectedSig = createHmac('sha256', ABACATEPAY_PUBLIC_KEY)
|
|
37
|
+
.update(bodyBuffer)
|
|
38
|
+
.digest('base64');
|
|
39
|
+
const A = Buffer.from(expectedSig);
|
|
40
|
+
const B = Buffer.from(signature);
|
|
41
|
+
return A.length === B.length && timingSafeEqual(A, B);
|
|
42
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { APIPayout, PaymentMethod, PaymentStatus, PayoutStatus } from '.';
|
|
2
|
+
export interface BaseWebhookEvent<Type extends WebhookEventType, Data extends object> {
|
|
3
|
+
/**
|
|
4
|
+
* The data received in the event.
|
|
5
|
+
*/
|
|
6
|
+
data: Data;
|
|
7
|
+
/**
|
|
8
|
+
* Unique identifier for the webhook.
|
|
9
|
+
*/
|
|
10
|
+
id: string;
|
|
11
|
+
/**
|
|
12
|
+
* This field identifies the type of event received.
|
|
13
|
+
*/
|
|
14
|
+
event: Type;
|
|
15
|
+
/**
|
|
16
|
+
* Indicates whether the event occurred in the development environment.
|
|
17
|
+
*/
|
|
18
|
+
devMode: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* https://docs.abacatepay.com/pages/webhooks#payout-failed
|
|
22
|
+
*/
|
|
23
|
+
export type WebhookPayoutFailedEvent = BaseWebhookEvent<WebhookEventType.PayoutFailed, {
|
|
24
|
+
/**
|
|
25
|
+
* Transaction data.
|
|
26
|
+
*/
|
|
27
|
+
transaction: Omit<APIPayout, 'status'> & {
|
|
28
|
+
/**
|
|
29
|
+
* Status of the payout. Always `PayoutStatus.Cancelled`.
|
|
30
|
+
*
|
|
31
|
+
* @see {@link PayoutStatus.Cancelled}
|
|
32
|
+
*/
|
|
33
|
+
status: PayoutStatus.Cancelled;
|
|
34
|
+
};
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* https://docs.abacatepay.com/pages/webhooks#payout-done
|
|
38
|
+
*/
|
|
39
|
+
export type WebhookPayoutDoneEvent = BaseWebhookEvent<WebhookEventType.PayoutDone, {
|
|
40
|
+
/**
|
|
41
|
+
* Transaction data.
|
|
42
|
+
*/
|
|
43
|
+
transaction: Omit<APIPayout, 'status'> & {
|
|
44
|
+
/**
|
|
45
|
+
* Status of the payout. Always `PayoutStatus.Complete`.
|
|
46
|
+
*
|
|
47
|
+
* @see {@link PayoutStatus.Complete}
|
|
48
|
+
*/
|
|
49
|
+
status: PayoutStatus.Complete;
|
|
50
|
+
};
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* https://docs.abacatepay.com/pages/webhooks#billing-paid
|
|
54
|
+
*/
|
|
55
|
+
export type WebhookBillingPaidEvent = BaseWebhookEvent<WebhookEventType.BillingPaid, {
|
|
56
|
+
/**
|
|
57
|
+
* Payment data.
|
|
58
|
+
*/
|
|
59
|
+
payment: {
|
|
60
|
+
/**
|
|
61
|
+
* Charge amount in cents (e.g. 4000 = R$40.00).
|
|
62
|
+
*/
|
|
63
|
+
amount: number;
|
|
64
|
+
/**
|
|
65
|
+
* The fee charged by AbacatePay.
|
|
66
|
+
*/
|
|
67
|
+
fee: 80;
|
|
68
|
+
/**
|
|
69
|
+
* Payment method.
|
|
70
|
+
*
|
|
71
|
+
* @see {@link PaymentMethod}
|
|
72
|
+
*/
|
|
73
|
+
method: PaymentMethod;
|
|
74
|
+
};
|
|
75
|
+
} & ({
|
|
76
|
+
pixQrCode: {
|
|
77
|
+
/**
|
|
78
|
+
* Charge amount in cents (e.g. 4000 = R$40.00).
|
|
79
|
+
*/
|
|
80
|
+
amount: number;
|
|
81
|
+
/**
|
|
82
|
+
* Unique billing identifier.
|
|
83
|
+
*/
|
|
84
|
+
id: string;
|
|
85
|
+
/**
|
|
86
|
+
* Kind of the payment
|
|
87
|
+
*/
|
|
88
|
+
kind: 'PIX';
|
|
89
|
+
/**
|
|
90
|
+
* Billing status, can only be `PAID` here
|
|
91
|
+
*
|
|
92
|
+
* @see {@link PaymentStatus.Paid}
|
|
93
|
+
*/
|
|
94
|
+
status: PaymentStatus.Paid;
|
|
95
|
+
};
|
|
96
|
+
} | {
|
|
97
|
+
billing: {
|
|
98
|
+
/**
|
|
99
|
+
* Charge amount in cents (e.g. 4000 = R$40.00).
|
|
100
|
+
*/
|
|
101
|
+
amount: number;
|
|
102
|
+
/**
|
|
103
|
+
* Unique billing identifier.
|
|
104
|
+
*/
|
|
105
|
+
id: string;
|
|
106
|
+
/**
|
|
107
|
+
* Bill ID in your system.
|
|
108
|
+
*/
|
|
109
|
+
externalId: string;
|
|
110
|
+
/**
|
|
111
|
+
* Status of the payment. Always `PaymentStatus.Paid`.
|
|
112
|
+
*
|
|
113
|
+
* @see {@link PaymentStatus.Paid}
|
|
114
|
+
*/
|
|
115
|
+
status: PaymentStatus.Paid;
|
|
116
|
+
/**
|
|
117
|
+
* URL where the user can complete the payment.
|
|
118
|
+
*/
|
|
119
|
+
url: string;
|
|
120
|
+
};
|
|
121
|
+
})>;
|
|
122
|
+
/**
|
|
123
|
+
* https://docs.abacatepay.com/pages/webhooks
|
|
124
|
+
*
|
|
125
|
+
* Any field that contains the tag "@unstable" means that the field is an assumption, it is uncertain (Since AbacatePay does not provide any information about).
|
|
126
|
+
*/
|
|
127
|
+
export type WebhookEvent = WebhookPayoutDoneEvent | WebhookPayoutFailedEvent | WebhookBillingPaidEvent;
|
|
128
|
+
/**
|
|
129
|
+
* https://docs.abacatepay.com/pages/webhooks
|
|
130
|
+
*/
|
|
131
|
+
export declare enum WebhookEventType {
|
|
132
|
+
PayoutFailed = "payout.failed",
|
|
133
|
+
PayoutDone = "payout.done",
|
|
134
|
+
BillingPaid = "billing.paid"
|
|
135
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://docs.abacatepay.com/pages/webhooks
|
|
3
|
+
*/
|
|
4
|
+
export var WebhookEventType;
|
|
5
|
+
(function (WebhookEventType) {
|
|
6
|
+
WebhookEventType["PayoutFailed"] = "payout.failed";
|
|
7
|
+
WebhookEventType["PayoutDone"] = "payout.done";
|
|
8
|
+
WebhookEventType["BillingPaid"] = "billing.paid";
|
|
9
|
+
})(WebhookEventType || (WebhookEventType = {}));
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version: "0.0
|
|
2
|
-
export declare const API_VERSION: "
|
|
1
|
+
export declare const version: "2.0.0";
|
|
2
|
+
export declare const API_VERSION: "2";
|
package/dist/version.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
export const version = '0.0
|
|
3
|
-
|
|
4
|
-
export const API_VERSION = '1';
|
|
1
|
+
// AUTO-GENERATED — DO NOT EDIT
|
|
2
|
+
export const version = '2.0.0';
|
|
3
|
+
export const API_VERSION = '2';
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0
|
|
2
|
+
"version": "2.0.0",
|
|
3
3
|
"name": "@abacatepay/types",
|
|
4
4
|
"description": "Abacate Pay API typings that are always up to date.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
+
"license": "Apache-2.0",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
11
|
"import": "./dist/index.js",
|
|
@@ -13,12 +14,28 @@
|
|
|
13
14
|
"./v1": {
|
|
14
15
|
"import": "./dist/v1/index.js",
|
|
15
16
|
"types": "./dist/v1/index.d.ts"
|
|
16
|
-
}
|
|
17
|
+
},
|
|
18
|
+
"./v1/*": {
|
|
19
|
+
"import": "./dist/v1/*.js",
|
|
20
|
+
"types": "./dist/v1/*.d.ts"
|
|
21
|
+
},
|
|
22
|
+
"./v2": {
|
|
23
|
+
"import": "./dist/v2/index.js",
|
|
24
|
+
"types": "./dist/v2/index.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./v2/*": {
|
|
27
|
+
"import": "./dist/v2/*.js",
|
|
28
|
+
"types": "./dist/v2/*.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./v*": null
|
|
17
31
|
},
|
|
18
32
|
"typesVersions": {
|
|
19
33
|
"*": {
|
|
20
34
|
"v1": [
|
|
21
35
|
"dist/v1/index.d.ts"
|
|
36
|
+
],
|
|
37
|
+
"v2": [
|
|
38
|
+
"dist/v2/index.d.ts"
|
|
22
39
|
]
|
|
23
40
|
}
|
|
24
41
|
},
|
|
@@ -26,10 +43,10 @@
|
|
|
26
43
|
"dist"
|
|
27
44
|
],
|
|
28
45
|
"scripts": {
|
|
29
|
-
"gen:version": "bun run scripts/version.ts",
|
|
30
46
|
"build": "bun run gen:version && tsc",
|
|
31
47
|
"prepublishOnly": "bun run build",
|
|
32
|
-
"
|
|
48
|
+
"gen:version": "bun run scripts/version.ts",
|
|
49
|
+
"fmt": "bunx biome check --write package.json types && clear"
|
|
33
50
|
},
|
|
34
51
|
"devDependencies": {
|
|
35
52
|
"@biomejs/biome": "^2.3.8",
|
|
@@ -40,5 +57,12 @@
|
|
|
40
57
|
"abacatepay",
|
|
41
58
|
"types",
|
|
42
59
|
"typescript"
|
|
43
|
-
]
|
|
60
|
+
],
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public"
|
|
63
|
+
},
|
|
64
|
+
"repository": {
|
|
65
|
+
"type": "git",
|
|
66
|
+
"url": "https://github.com/almeidazs/abacate-pay-types"
|
|
67
|
+
}
|
|
44
68
|
}
|
package/dist/routes.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { RESTGetCheckQRCodePixStatusQueryParams, RESTGetSearchWithdrawQueryParams, RESTPostSimulatePaymentQueryParams } from './v1/rest';
|
|
2
|
-
export declare const API_BASE_URL = "https://api.abacatepay.com/";
|
|
3
|
-
export declare const Routes: {
|
|
4
|
-
/**
|
|
5
|
-
* POST - https://api.abacatepay.com/v1/customer/create
|
|
6
|
-
*/
|
|
7
|
-
createCustomer(): "/customer/create";
|
|
8
|
-
/**
|
|
9
|
-
* GET - https://api.abacatepay.com/v1/customer/list
|
|
10
|
-
*/
|
|
11
|
-
listCustomers(): "/customer/list";
|
|
12
|
-
/**
|
|
13
|
-
* POST - https://api.abacatepay.com/v1/billing/create
|
|
14
|
-
*/
|
|
15
|
-
createCharge(): "/billing/create";
|
|
16
|
-
/**
|
|
17
|
-
* GET - https://api.abacatepay.com/v1/billing/list
|
|
18
|
-
*/
|
|
19
|
-
listCharges(): "/billing/list";
|
|
20
|
-
/**
|
|
21
|
-
* POST - https://api.abacatepay.com/v1/pixQrCode/create
|
|
22
|
-
*/
|
|
23
|
-
createPIXQRCode(): "/pixQrCode/create";
|
|
24
|
-
/**
|
|
25
|
-
* POST - https://api.abacatepay.com/v1/pixQrCode/simulate-payment
|
|
26
|
-
*/
|
|
27
|
-
simulatePayment({ id }: RESTPostSimulatePaymentQueryParams): `/pixQrCode/simulate-payment?id=${string}`;
|
|
28
|
-
/**
|
|
29
|
-
* GET - https://api.abacatepay.com/v1/pixQrCode/check
|
|
30
|
-
*/
|
|
31
|
-
checkQRCodePIXStatus({ id }: RESTGetCheckQRCodePixStatusQueryParams): `/pixQrCode/check?id=${string}`;
|
|
32
|
-
/**
|
|
33
|
-
* POST - https://api.abacatepay.com/v1/coupon/create
|
|
34
|
-
*/
|
|
35
|
-
createCoupon(): "/coupon/create";
|
|
36
|
-
/**
|
|
37
|
-
* GET - https://api.abacatepay.com/v1/coupon/list
|
|
38
|
-
*/
|
|
39
|
-
listCoupons(): "/coupon/list";
|
|
40
|
-
/**
|
|
41
|
-
* POST - https://api.abacatepay.com/v1/withdraw/create
|
|
42
|
-
*/
|
|
43
|
-
createWithdraw(): "/withdraw/create";
|
|
44
|
-
/**
|
|
45
|
-
* GET - https://api.abacatepay.com/v1/withdraw/get
|
|
46
|
-
*/
|
|
47
|
-
getWithdraw({ externalId }: RESTGetSearchWithdrawQueryParams): `/withdraw/get?externalId=${string}`;
|
|
48
|
-
/**
|
|
49
|
-
* GET - https://api.abacatepay.com/v1/withdraw/list
|
|
50
|
-
*/
|
|
51
|
-
listWithdraw(): "/withdraw/list";
|
|
52
|
-
/**
|
|
53
|
-
* GET - https://api.abacatepay.com/v1/store/get
|
|
54
|
-
*/
|
|
55
|
-
store(): "/store/get";
|
|
56
|
-
/**
|
|
57
|
-
* GET - https://api.abacatepay.com/v1/public-mrr/mrr
|
|
58
|
-
*/
|
|
59
|
-
getMRR(): "/public-mrr/mrr";
|
|
60
|
-
/**
|
|
61
|
-
* GET - https://api.abacatepay.com/v1/public-mrr/merchant-info
|
|
62
|
-
*/
|
|
63
|
-
merchant(): "/public-mrr/merchant-info";
|
|
64
|
-
/**
|
|
65
|
-
* GET - https://api.abacatepay.com/v1/public-mrr/renevue
|
|
66
|
-
*/
|
|
67
|
-
renevue(): "/public-mrr/revenue";
|
|
68
|
-
};
|