@pague-dev/sdk-node 1.1.0 → 1.3.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 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** - Notificações em tempo real
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);
@@ -209,6 +223,7 @@ function isValidWebhookEvent(event) {
209
223
  if (typeof obj.data !== "object" || obj.data === null) return false;
210
224
  return [
211
225
  "payment_completed",
226
+ "payment_expired",
212
227
  "refund_completed",
213
228
  "withdrawal_completed",
214
229
  "withdrawal_failed"
package/dist/index.d.cts CHANGED
@@ -1,3 +1,36 @@
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
+ held: BalanceAmount;
24
+ total: BalanceAmount;
25
+ currency: string;
26
+ updatedAt: string;
27
+ }
28
+ interface AccountInfo {
29
+ account: AccountDetail;
30
+ company: CompanyDetail | null;
31
+ balance: BalanceDetail;
32
+ }
33
+ //#endregion
1
34
  //#region src/charges/interfaces/charge.interface.d.ts
2
35
  type ChargeStatus = 'active' | 'expired' | 'disabled' | 'paid';
3
36
  type PaymentMethod = 'pix' | 'credit_card' | 'boleto';
@@ -108,6 +141,14 @@ interface ListCustomersOptions extends PaginationOptions {
108
141
  }
109
142
  type ListCustomersResponse = Response<PaginatedResponse<Customer>>;
110
143
  //#endregion
144
+ //#region src/account/account.d.ts
145
+ declare class Account {
146
+ private readonly pdev;
147
+ private readonly endpoint;
148
+ constructor(pdev: Pdev);
149
+ get(): Promise<Response<AccountInfo>>;
150
+ }
151
+ //#endregion
111
152
  //#region src/common/base-resource.d.ts
112
153
  /**
113
154
  * Base class for API resources that follow CRUD patterns.
@@ -326,6 +367,7 @@ declare class Pdev {
326
367
  readonly key: string;
327
368
  private readonly baseUrl;
328
369
  private readonly headers;
370
+ readonly account: Account;
329
371
  readonly pix: Pix;
330
372
  readonly customers: Customers;
331
373
  readonly projects: Projects;
@@ -343,7 +385,7 @@ declare class Pdev {
343
385
  /**
344
386
  * Available webhook event types
345
387
  */
346
- type WebhookEventType = 'payment_completed' | 'refund_completed' | 'withdrawal_completed' | 'withdrawal_failed';
388
+ type WebhookEventType = 'payment_completed' | 'payment_expired' | 'refund_completed' | 'withdrawal_completed' | 'withdrawal_failed';
347
389
  /**
348
390
  * Base webhook payload structure
349
391
  */
@@ -384,6 +426,27 @@ interface PaymentCompletedData {
384
426
  /** Custom metadata passed when creating the payment */
385
427
  metadata?: Record<string, unknown>;
386
428
  }
429
+ /**
430
+ * Data payload for payment_expired event
431
+ */
432
+ interface PaymentExpiredData {
433
+ /** Transaction identifier */
434
+ transactionId: string;
435
+ /** Payment amount */
436
+ amount: number;
437
+ /** Currency code (e.g., "BRL") */
438
+ currency: string;
439
+ /** Payment method used (e.g., "pix") */
440
+ paymentMethod: string;
441
+ /** Payment status */
442
+ status: 'expired';
443
+ /** ISO 8601 timestamp of when payment expired */
444
+ expiredAt: string;
445
+ /** Your external reference ID (optional) */
446
+ externalReference?: string;
447
+ /** Custom metadata passed when creating the payment */
448
+ metadata?: Record<string, unknown>;
449
+ }
387
450
  /**
388
451
  * Data payload for refund_completed event
389
452
  */
@@ -461,6 +524,10 @@ interface WithdrawalFailedData {
461
524
  * Payment completed webhook event
462
525
  */
463
526
  type PaymentCompletedEvent = WebhookPayload<'payment_completed', PaymentCompletedData>;
527
+ /**
528
+ * Payment expired webhook event
529
+ */
530
+ type PaymentExpiredEvent = WebhookPayload<'payment_expired', PaymentExpiredData>;
464
531
  /**
465
532
  * Refund completed webhook event
466
533
  */
@@ -476,7 +543,7 @@ type WithdrawalFailedEvent = WebhookPayload<'withdrawal_failed', WithdrawalFaile
476
543
  /**
477
544
  * Union type of all possible webhook events
478
545
  */
479
- type WebhookEvent = PaymentCompletedEvent | RefundCompletedEvent | WithdrawalCompletedEvent | WithdrawalFailedEvent;
546
+ type WebhookEvent = PaymentCompletedEvent | PaymentExpiredEvent | RefundCompletedEvent | WithdrawalCompletedEvent | WithdrawalFailedEvent;
480
547
  /**
481
548
  * Webhook headers sent with each request
482
549
  */
@@ -566,4 +633,4 @@ interface WebhookHeaders {
566
633
  declare function verifyWebhookSignature(payload: string, signature: string, secret: string): boolean;
567
634
  declare function parseWebhook(payload: string): WebhookEvent | null;
568
635
  //#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 };
636
+ 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, PaymentExpiredData, PaymentExpiredEvent, 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,36 @@
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
+ held: BalanceAmount;
24
+ total: BalanceAmount;
25
+ currency: string;
26
+ updatedAt: string;
27
+ }
28
+ interface AccountInfo {
29
+ account: AccountDetail;
30
+ company: CompanyDetail | null;
31
+ balance: BalanceDetail;
32
+ }
33
+ //#endregion
1
34
  //#region src/charges/interfaces/charge.interface.d.ts
2
35
  type ChargeStatus = 'active' | 'expired' | 'disabled' | 'paid';
3
36
  type PaymentMethod = 'pix' | 'credit_card' | 'boleto';
@@ -108,6 +141,14 @@ interface ListCustomersOptions extends PaginationOptions {
108
141
  }
109
142
  type ListCustomersResponse = Response<PaginatedResponse<Customer>>;
110
143
  //#endregion
144
+ //#region src/account/account.d.ts
145
+ declare class Account {
146
+ private readonly pdev;
147
+ private readonly endpoint;
148
+ constructor(pdev: Pdev);
149
+ get(): Promise<Response<AccountInfo>>;
150
+ }
151
+ //#endregion
111
152
  //#region src/common/base-resource.d.ts
112
153
  /**
113
154
  * Base class for API resources that follow CRUD patterns.
@@ -326,6 +367,7 @@ declare class Pdev {
326
367
  readonly key: string;
327
368
  private readonly baseUrl;
328
369
  private readonly headers;
370
+ readonly account: Account;
329
371
  readonly pix: Pix;
330
372
  readonly customers: Customers;
331
373
  readonly projects: Projects;
@@ -343,7 +385,7 @@ declare class Pdev {
343
385
  /**
344
386
  * Available webhook event types
345
387
  */
346
- type WebhookEventType = 'payment_completed' | 'refund_completed' | 'withdrawal_completed' | 'withdrawal_failed';
388
+ type WebhookEventType = 'payment_completed' | 'payment_expired' | 'refund_completed' | 'withdrawal_completed' | 'withdrawal_failed';
347
389
  /**
348
390
  * Base webhook payload structure
349
391
  */
@@ -384,6 +426,27 @@ interface PaymentCompletedData {
384
426
  /** Custom metadata passed when creating the payment */
385
427
  metadata?: Record<string, unknown>;
386
428
  }
429
+ /**
430
+ * Data payload for payment_expired event
431
+ */
432
+ interface PaymentExpiredData {
433
+ /** Transaction identifier */
434
+ transactionId: string;
435
+ /** Payment amount */
436
+ amount: number;
437
+ /** Currency code (e.g., "BRL") */
438
+ currency: string;
439
+ /** Payment method used (e.g., "pix") */
440
+ paymentMethod: string;
441
+ /** Payment status */
442
+ status: 'expired';
443
+ /** ISO 8601 timestamp of when payment expired */
444
+ expiredAt: string;
445
+ /** Your external reference ID (optional) */
446
+ externalReference?: string;
447
+ /** Custom metadata passed when creating the payment */
448
+ metadata?: Record<string, unknown>;
449
+ }
387
450
  /**
388
451
  * Data payload for refund_completed event
389
452
  */
@@ -461,6 +524,10 @@ interface WithdrawalFailedData {
461
524
  * Payment completed webhook event
462
525
  */
463
526
  type PaymentCompletedEvent = WebhookPayload<'payment_completed', PaymentCompletedData>;
527
+ /**
528
+ * Payment expired webhook event
529
+ */
530
+ type PaymentExpiredEvent = WebhookPayload<'payment_expired', PaymentExpiredData>;
464
531
  /**
465
532
  * Refund completed webhook event
466
533
  */
@@ -476,7 +543,7 @@ type WithdrawalFailedEvent = WebhookPayload<'withdrawal_failed', WithdrawalFaile
476
543
  /**
477
544
  * Union type of all possible webhook events
478
545
  */
479
- type WebhookEvent = PaymentCompletedEvent | RefundCompletedEvent | WithdrawalCompletedEvent | WithdrawalFailedEvent;
546
+ type WebhookEvent = PaymentCompletedEvent | PaymentExpiredEvent | RefundCompletedEvent | WithdrawalCompletedEvent | WithdrawalFailedEvent;
480
547
  /**
481
548
  * Webhook headers sent with each request
482
549
  */
@@ -566,4 +633,4 @@ interface WebhookHeaders {
566
633
  declare function verifyWebhookSignature(payload: string, signature: string, secret: string): boolean;
567
634
  declare function parseWebhook(payload: string): WebhookEvent | null;
568
635
  //#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 };
636
+ 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, PaymentExpiredData, PaymentExpiredEvent, 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);
@@ -209,6 +223,7 @@ function isValidWebhookEvent(event) {
209
223
  if (typeof obj.data !== "object" || obj.data === null) return false;
210
224
  return [
211
225
  "payment_completed",
226
+ "payment_expired",
212
227
  "refund_completed",
213
228
  "withdrawal_completed",
214
229
  "withdrawal_failed"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pague-dev/sdk-node",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "Node.js SDK for the pague.dev API",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",