@pague-dev/sdk-node 1.1.0 → 1.2.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 +8 -2
- package/dist/index.cjs +14 -0
- package/dist/index.d.cts +42 -1
- package/dist/index.d.mts +42 -1
- package/dist/index.mjs +14 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,7 +46,13 @@ await pdev.withdrawals.create({ amount, bankAccountId });
|
|
|
46
46
|
await pdev.transactions.get(id);
|
|
47
47
|
|
|
48
48
|
// Webhooks
|
|
49
|
-
import { parseWebhook } from '@pague-dev/sdk-node';
|
|
49
|
+
import { verifyWebhookSignature, parseWebhook } from '@pague-dev/sdk-node';
|
|
50
|
+
|
|
51
|
+
const signature = req.headers['x-webhook-signature'] as string;
|
|
52
|
+
if (!verifyWebhookSignature(req.body, signature, 'your_webhook_secret')) {
|
|
53
|
+
return res.status(401).send('Invalid signature');
|
|
54
|
+
}
|
|
55
|
+
|
|
50
56
|
const event = parseWebhook(req.body);
|
|
51
57
|
```
|
|
52
58
|
|
|
@@ -58,7 +64,7 @@ const event = parseWebhook(req.body);
|
|
|
58
64
|
- **Projects** - Organização por projetos
|
|
59
65
|
- **Withdrawals** - Saques via PIX (avulso ou conta salva)
|
|
60
66
|
- **Transactions** - Consulta de transações
|
|
61
|
-
- **Webhooks** -
|
|
67
|
+
- **Webhooks** - Verificação de assinatura e parsing de eventos
|
|
62
68
|
|
|
63
69
|
## Exemplo
|
|
64
70
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
let node_crypto = require("node:crypto");
|
|
2
2
|
|
|
3
|
+
//#region src/account/account.ts
|
|
4
|
+
var Account = class {
|
|
5
|
+
endpoint = "/account";
|
|
6
|
+
constructor(pdev) {
|
|
7
|
+
this.pdev = pdev;
|
|
8
|
+
}
|
|
9
|
+
async get() {
|
|
10
|
+
return this.pdev.get(this.endpoint);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
3
15
|
//#region src/common/utils/build-pagination-query.ts
|
|
4
16
|
function buildPaginationQuery(options) {
|
|
5
17
|
const searchParams = new URLSearchParams();
|
|
@@ -110,6 +122,7 @@ var Pdev = class {
|
|
|
110
122
|
key;
|
|
111
123
|
baseUrl;
|
|
112
124
|
headers;
|
|
125
|
+
account;
|
|
113
126
|
pix;
|
|
114
127
|
customers;
|
|
115
128
|
projects;
|
|
@@ -127,6 +140,7 @@ var Pdev = class {
|
|
|
127
140
|
"X-API-Key": this.key,
|
|
128
141
|
"Content-Type": "application/json"
|
|
129
142
|
});
|
|
143
|
+
this.account = new Account(this);
|
|
130
144
|
this.pix = new Pix(this);
|
|
131
145
|
this.customers = new Customers(this);
|
|
132
146
|
this.projects = new Projects(this);
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
//#region src/account/interfaces/account-info.interface.d.ts
|
|
2
|
+
type AccountStatus = 'approved' | 'pending' | 'pending_documents' | 'pending_approval' | 'rejected' | 'suspended';
|
|
3
|
+
type CompanyStatus = 'pending' | 'active' | 'suspended' | 'blocked';
|
|
4
|
+
interface BalanceAmount {
|
|
5
|
+
amount: number;
|
|
6
|
+
amountFormatted: number;
|
|
7
|
+
}
|
|
8
|
+
interface AccountDetail {
|
|
9
|
+
id: string;
|
|
10
|
+
status: AccountStatus;
|
|
11
|
+
}
|
|
12
|
+
interface CompanyDetail {
|
|
13
|
+
razaoSocial: string;
|
|
14
|
+
nomeFantasia?: string;
|
|
15
|
+
cnpj: string;
|
|
16
|
+
email: string;
|
|
17
|
+
phone: string;
|
|
18
|
+
status: CompanyStatus;
|
|
19
|
+
}
|
|
20
|
+
interface BalanceDetail {
|
|
21
|
+
available: BalanceAmount;
|
|
22
|
+
promotional: BalanceAmount;
|
|
23
|
+
total: BalanceAmount;
|
|
24
|
+
currency: string;
|
|
25
|
+
updatedAt: string;
|
|
26
|
+
}
|
|
27
|
+
interface AccountInfo {
|
|
28
|
+
account: AccountDetail;
|
|
29
|
+
company: CompanyDetail | null;
|
|
30
|
+
balance: BalanceDetail;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
1
33
|
//#region src/charges/interfaces/charge.interface.d.ts
|
|
2
34
|
type ChargeStatus = 'active' | 'expired' | 'disabled' | 'paid';
|
|
3
35
|
type PaymentMethod = 'pix' | 'credit_card' | 'boleto';
|
|
@@ -108,6 +140,14 @@ interface ListCustomersOptions extends PaginationOptions {
|
|
|
108
140
|
}
|
|
109
141
|
type ListCustomersResponse = Response<PaginatedResponse<Customer>>;
|
|
110
142
|
//#endregion
|
|
143
|
+
//#region src/account/account.d.ts
|
|
144
|
+
declare class Account {
|
|
145
|
+
private readonly pdev;
|
|
146
|
+
private readonly endpoint;
|
|
147
|
+
constructor(pdev: Pdev);
|
|
148
|
+
get(): Promise<Response<AccountInfo>>;
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
111
151
|
//#region src/common/base-resource.d.ts
|
|
112
152
|
/**
|
|
113
153
|
* Base class for API resources that follow CRUD patterns.
|
|
@@ -326,6 +366,7 @@ declare class Pdev {
|
|
|
326
366
|
readonly key: string;
|
|
327
367
|
private readonly baseUrl;
|
|
328
368
|
private readonly headers;
|
|
369
|
+
readonly account: Account;
|
|
329
370
|
readonly pix: Pix;
|
|
330
371
|
readonly customers: Customers;
|
|
331
372
|
readonly projects: Projects;
|
|
@@ -566,4 +607,4 @@ interface WebhookHeaders {
|
|
|
566
607
|
declare function verifyWebhookSignature(payload: string, signature: string, secret: string): boolean;
|
|
567
608
|
declare function parseWebhook(payload: string): WebhookEvent | null;
|
|
568
609
|
//#endregion
|
|
569
|
-
export { Charge, ChargeStatus, CreateChargeOptions, CreateChargeResponse, CreateCustomerOptions, CreateCustomerResponse, CreatePixCustomer, CreatePixOptions, CreatePixResponse, CreateProjectOptions, CreateProjectResponse, CreateStaticQrCodeOptions, CreateStaticQrCodeResponse, CreateWithdrawalOptions, CreateWithdrawalResponse, Customer, DocumentType, type ErrorResponse, GetChargeResponse, GetTransactionResponse, ListChargesOptions, ListChargesResponse, ListCustomersOptions, ListCustomersResponse, ListProjectsOptions, ListProjectsResponse, NotificationType, type PaginatedResponse, type PaginationOptions, PaymentCompletedData, PaymentCompletedEvent, PaymentMethod, Pdev, PixCharge, PixKeyType, PixStatus, Project, RefundCompletedData, RefundCompletedEvent, type Response, SortBy, SortOrder, StaticQrCode, Transaction, TransactionPaymentMethod, TransactionStatus, TransactionType, WebhookEvent, WebhookEventType, WebhookHeaders, WebhookPayload, Withdrawal, WithdrawalCompletedData, WithdrawalCompletedEvent, WithdrawalFailedData, WithdrawalFailedEvent, WithdrawalStatus, parseWebhook, verifyWebhookSignature };
|
|
610
|
+
export { AccountDetail, AccountInfo, AccountStatus, BalanceAmount, BalanceDetail, Charge, ChargeStatus, CompanyDetail, CompanyStatus, CreateChargeOptions, CreateChargeResponse, CreateCustomerOptions, CreateCustomerResponse, CreatePixCustomer, CreatePixOptions, CreatePixResponse, CreateProjectOptions, CreateProjectResponse, CreateStaticQrCodeOptions, CreateStaticQrCodeResponse, CreateWithdrawalOptions, CreateWithdrawalResponse, Customer, DocumentType, type ErrorResponse, GetChargeResponse, GetTransactionResponse, ListChargesOptions, ListChargesResponse, ListCustomersOptions, ListCustomersResponse, ListProjectsOptions, ListProjectsResponse, NotificationType, type PaginatedResponse, type PaginationOptions, PaymentCompletedData, PaymentCompletedEvent, PaymentMethod, Pdev, PixCharge, PixKeyType, PixStatus, Project, RefundCompletedData, RefundCompletedEvent, type Response, SortBy, SortOrder, StaticQrCode, Transaction, TransactionPaymentMethod, TransactionStatus, TransactionType, WebhookEvent, WebhookEventType, WebhookHeaders, WebhookPayload, Withdrawal, WithdrawalCompletedData, WithdrawalCompletedEvent, WithdrawalFailedData, WithdrawalFailedEvent, WithdrawalStatus, parseWebhook, verifyWebhookSignature };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
//#region src/account/interfaces/account-info.interface.d.ts
|
|
2
|
+
type AccountStatus = 'approved' | 'pending' | 'pending_documents' | 'pending_approval' | 'rejected' | 'suspended';
|
|
3
|
+
type CompanyStatus = 'pending' | 'active' | 'suspended' | 'blocked';
|
|
4
|
+
interface BalanceAmount {
|
|
5
|
+
amount: number;
|
|
6
|
+
amountFormatted: number;
|
|
7
|
+
}
|
|
8
|
+
interface AccountDetail {
|
|
9
|
+
id: string;
|
|
10
|
+
status: AccountStatus;
|
|
11
|
+
}
|
|
12
|
+
interface CompanyDetail {
|
|
13
|
+
razaoSocial: string;
|
|
14
|
+
nomeFantasia?: string;
|
|
15
|
+
cnpj: string;
|
|
16
|
+
email: string;
|
|
17
|
+
phone: string;
|
|
18
|
+
status: CompanyStatus;
|
|
19
|
+
}
|
|
20
|
+
interface BalanceDetail {
|
|
21
|
+
available: BalanceAmount;
|
|
22
|
+
promotional: BalanceAmount;
|
|
23
|
+
total: BalanceAmount;
|
|
24
|
+
currency: string;
|
|
25
|
+
updatedAt: string;
|
|
26
|
+
}
|
|
27
|
+
interface AccountInfo {
|
|
28
|
+
account: AccountDetail;
|
|
29
|
+
company: CompanyDetail | null;
|
|
30
|
+
balance: BalanceDetail;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
1
33
|
//#region src/charges/interfaces/charge.interface.d.ts
|
|
2
34
|
type ChargeStatus = 'active' | 'expired' | 'disabled' | 'paid';
|
|
3
35
|
type PaymentMethod = 'pix' | 'credit_card' | 'boleto';
|
|
@@ -108,6 +140,14 @@ interface ListCustomersOptions extends PaginationOptions {
|
|
|
108
140
|
}
|
|
109
141
|
type ListCustomersResponse = Response<PaginatedResponse<Customer>>;
|
|
110
142
|
//#endregion
|
|
143
|
+
//#region src/account/account.d.ts
|
|
144
|
+
declare class Account {
|
|
145
|
+
private readonly pdev;
|
|
146
|
+
private readonly endpoint;
|
|
147
|
+
constructor(pdev: Pdev);
|
|
148
|
+
get(): Promise<Response<AccountInfo>>;
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
111
151
|
//#region src/common/base-resource.d.ts
|
|
112
152
|
/**
|
|
113
153
|
* Base class for API resources that follow CRUD patterns.
|
|
@@ -326,6 +366,7 @@ declare class Pdev {
|
|
|
326
366
|
readonly key: string;
|
|
327
367
|
private readonly baseUrl;
|
|
328
368
|
private readonly headers;
|
|
369
|
+
readonly account: Account;
|
|
329
370
|
readonly pix: Pix;
|
|
330
371
|
readonly customers: Customers;
|
|
331
372
|
readonly projects: Projects;
|
|
@@ -566,4 +607,4 @@ interface WebhookHeaders {
|
|
|
566
607
|
declare function verifyWebhookSignature(payload: string, signature: string, secret: string): boolean;
|
|
567
608
|
declare function parseWebhook(payload: string): WebhookEvent | null;
|
|
568
609
|
//#endregion
|
|
569
|
-
export { Charge, ChargeStatus, CreateChargeOptions, CreateChargeResponse, CreateCustomerOptions, CreateCustomerResponse, CreatePixCustomer, CreatePixOptions, CreatePixResponse, CreateProjectOptions, CreateProjectResponse, CreateStaticQrCodeOptions, CreateStaticQrCodeResponse, CreateWithdrawalOptions, CreateWithdrawalResponse, Customer, DocumentType, type ErrorResponse, GetChargeResponse, GetTransactionResponse, ListChargesOptions, ListChargesResponse, ListCustomersOptions, ListCustomersResponse, ListProjectsOptions, ListProjectsResponse, NotificationType, type PaginatedResponse, type PaginationOptions, PaymentCompletedData, PaymentCompletedEvent, PaymentMethod, Pdev, PixCharge, PixKeyType, PixStatus, Project, RefundCompletedData, RefundCompletedEvent, type Response, SortBy, SortOrder, StaticQrCode, Transaction, TransactionPaymentMethod, TransactionStatus, TransactionType, WebhookEvent, WebhookEventType, WebhookHeaders, WebhookPayload, Withdrawal, WithdrawalCompletedData, WithdrawalCompletedEvent, WithdrawalFailedData, WithdrawalFailedEvent, WithdrawalStatus, parseWebhook, verifyWebhookSignature };
|
|
610
|
+
export { AccountDetail, AccountInfo, AccountStatus, BalanceAmount, BalanceDetail, Charge, ChargeStatus, CompanyDetail, CompanyStatus, CreateChargeOptions, CreateChargeResponse, CreateCustomerOptions, CreateCustomerResponse, CreatePixCustomer, CreatePixOptions, CreatePixResponse, CreateProjectOptions, CreateProjectResponse, CreateStaticQrCodeOptions, CreateStaticQrCodeResponse, CreateWithdrawalOptions, CreateWithdrawalResponse, Customer, DocumentType, type ErrorResponse, GetChargeResponse, GetTransactionResponse, ListChargesOptions, ListChargesResponse, ListCustomersOptions, ListCustomersResponse, ListProjectsOptions, ListProjectsResponse, NotificationType, type PaginatedResponse, type PaginationOptions, PaymentCompletedData, PaymentCompletedEvent, PaymentMethod, Pdev, PixCharge, PixKeyType, PixStatus, Project, RefundCompletedData, RefundCompletedEvent, type Response, SortBy, SortOrder, StaticQrCode, Transaction, TransactionPaymentMethod, TransactionStatus, TransactionType, WebhookEvent, WebhookEventType, WebhookHeaders, WebhookPayload, Withdrawal, WithdrawalCompletedData, WithdrawalCompletedEvent, WithdrawalFailedData, WithdrawalFailedEvent, WithdrawalStatus, parseWebhook, verifyWebhookSignature };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
2
2
|
|
|
3
|
+
//#region src/account/account.ts
|
|
4
|
+
var Account = class {
|
|
5
|
+
endpoint = "/account";
|
|
6
|
+
constructor(pdev) {
|
|
7
|
+
this.pdev = pdev;
|
|
8
|
+
}
|
|
9
|
+
async get() {
|
|
10
|
+
return this.pdev.get(this.endpoint);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
3
15
|
//#region src/common/utils/build-pagination-query.ts
|
|
4
16
|
function buildPaginationQuery(options) {
|
|
5
17
|
const searchParams = new URLSearchParams();
|
|
@@ -110,6 +122,7 @@ var Pdev = class {
|
|
|
110
122
|
key;
|
|
111
123
|
baseUrl;
|
|
112
124
|
headers;
|
|
125
|
+
account;
|
|
113
126
|
pix;
|
|
114
127
|
customers;
|
|
115
128
|
projects;
|
|
@@ -127,6 +140,7 @@ var Pdev = class {
|
|
|
127
140
|
"X-API-Key": this.key,
|
|
128
141
|
"Content-Type": "application/json"
|
|
129
142
|
});
|
|
143
|
+
this.account = new Account(this);
|
|
130
144
|
this.pix = new Pix(this);
|
|
131
145
|
this.customers = new Customers(this);
|
|
132
146
|
this.projects = new Projects(this);
|