@pague-dev/sdk-node 0.1.5 → 0.2.1

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/dist/index.cjs CHANGED
@@ -197,8 +197,9 @@ function isValidWebhookEvent(event) {
197
197
  if (typeof obj.data !== "object" || obj.data === null) return false;
198
198
  return [
199
199
  "payment_completed",
200
- "payment_failed",
201
- "refund_completed"
200
+ "refund_completed",
201
+ "withdrawal_completed",
202
+ "withdrawal_failed"
202
203
  ].includes(obj.event);
203
204
  }
204
205
  /**
package/dist/index.d.cts CHANGED
@@ -282,7 +282,7 @@ declare class Pdev {
282
282
  /**
283
283
  * Available webhook event types
284
284
  */
285
- type WebhookEventType = 'payment_completed' | 'payment_failed' | 'refund_completed';
285
+ type WebhookEventType = 'payment_completed' | 'refund_completed' | 'withdrawal_completed' | 'withdrawal_failed';
286
286
  /**
287
287
  * Base webhook payload structure
288
288
  */
@@ -302,6 +302,8 @@ interface WebhookPayload<T extends WebhookEventType, D> {
302
302
  interface PaymentCompletedData {
303
303
  /** Transaction identifier */
304
304
  transactionId: string;
305
+ /** Environment where the transaction occurred */
306
+ environment: 'production' | 'sandbox';
305
307
  /** Payment amount */
306
308
  amount: number;
307
309
  /** Platform fees charged */
@@ -316,25 +318,8 @@ interface PaymentCompletedData {
316
318
  status: 'completed';
317
319
  /** ISO 8601 timestamp of when payment was completed */
318
320
  completedAt: string;
319
- }
320
- /**
321
- * Data payload for payment_failed event
322
- */
323
- interface PaymentFailedData {
324
- /** Transaction identifier */
325
- transactionId: string;
326
- /** Payment amount */
327
- amount: number;
328
- /** Currency code (e.g., "BRL") */
329
- currency: string;
330
- /** Payment method used (e.g., "pix") */
331
- paymentMethod: string;
332
- /** Payment status */
333
- status: 'failed';
334
- /** ISO 8601 timestamp of when payment failed */
335
- failedAt: string;
336
- /** Reason for failure (e.g., "expired", "insufficient_funds") */
337
- failureReason: string;
321
+ /** Your external reference ID (optional) */
322
+ externalReference?: string;
338
323
  }
339
324
  /**
340
325
  * Data payload for refund_completed event
@@ -344,33 +329,85 @@ interface RefundCompletedData {
344
329
  refundTransactionId: string;
345
330
  /** Original payment transaction ID that was refunded */
346
331
  originalTransactionId: string;
332
+ /** Environment where the transaction occurred */
333
+ environment: 'production' | 'sandbox';
347
334
  /** Refunded amount */
348
335
  amount: number;
349
- /** Fees (typically 0 for refunds) */
336
+ /** Fees charged for the refund */
350
337
  feeAmount: number;
338
+ /** Net amount after fees */
339
+ netAmount: number;
351
340
  /** Currency code (e.g., "BRL") */
352
341
  currency: string;
353
342
  /** Refund status */
354
343
  status: 'completed';
355
344
  /** ISO 8601 timestamp of when refund was completed */
356
- refundedAt: string;
345
+ completedAt: string;
357
346
  }
358
347
  /**
359
- * Payment completed webhook event
348
+ * Data payload for withdrawal_completed event
360
349
  */
361
- type PaymentCompletedEvent = WebhookPayload<'payment_completed', PaymentCompletedData>;
350
+ interface WithdrawalCompletedData {
351
+ /** Withdrawal identifier */
352
+ withdrawalId: string;
353
+ /** Environment where the withdrawal occurred */
354
+ environment: 'production' | 'sandbox';
355
+ /** Withdrawal amount */
356
+ amount: number;
357
+ /** Fees charged for the withdrawal */
358
+ feeAmount: number;
359
+ /** Net amount transferred (amount - feeAmount) */
360
+ netAmount: number;
361
+ /** Currency code (e.g., "BRL") */
362
+ currency: string;
363
+ /** Withdrawal status */
364
+ status: 'completed';
365
+ /** ISO 8601 timestamp of when withdrawal was completed */
366
+ completedAt: string;
367
+ }
368
+ /**
369
+ * Data payload for withdrawal_failed event
370
+ */
371
+ interface WithdrawalFailedData {
372
+ /** Withdrawal identifier */
373
+ withdrawalId: string;
374
+ /** Environment where the withdrawal occurred */
375
+ environment: 'production' | 'sandbox';
376
+ /** Withdrawal amount */
377
+ amount: number;
378
+ /** Fees that would have been charged */
379
+ feeAmount: number;
380
+ /** Net amount that would have been transferred */
381
+ netAmount: number;
382
+ /** Currency code (e.g., "BRL") */
383
+ currency: string;
384
+ /** Withdrawal status */
385
+ status: 'failed';
386
+ /** ISO 8601 timestamp of when withdrawal failed */
387
+ failedAt: string;
388
+ /** Reason for failure (e.g., "insufficient_funds", "invalid_account") */
389
+ failureReason: string;
390
+ }
362
391
  /**
363
- * Payment failed webhook event
392
+ * Payment completed webhook event
364
393
  */
365
- type PaymentFailedEvent = WebhookPayload<'payment_failed', PaymentFailedData>;
394
+ type PaymentCompletedEvent = WebhookPayload<'payment_completed', PaymentCompletedData>;
366
395
  /**
367
396
  * Refund completed webhook event
368
397
  */
369
398
  type RefundCompletedEvent = WebhookPayload<'refund_completed', RefundCompletedData>;
399
+ /**
400
+ * Withdrawal completed webhook event
401
+ */
402
+ type WithdrawalCompletedEvent = WebhookPayload<'withdrawal_completed', WithdrawalCompletedData>;
403
+ /**
404
+ * Withdrawal failed webhook event
405
+ */
406
+ type WithdrawalFailedEvent = WebhookPayload<'withdrawal_failed', WithdrawalFailedData>;
370
407
  /**
371
408
  * Union type of all possible webhook events
372
409
  */
373
- type WebhookEvent = PaymentCompletedEvent | PaymentFailedEvent | RefundCompletedEvent;
410
+ type WebhookEvent = PaymentCompletedEvent | RefundCompletedEvent | WithdrawalCompletedEvent | WithdrawalFailedEvent;
374
411
  /**
375
412
  * Webhook headers sent with each request
376
413
  */
@@ -434,4 +471,4 @@ interface WebhookHeaders {
434
471
  */
435
472
  declare function parseWebhook(payload: string): WebhookEvent | null;
436
473
  //#endregion
437
- export { Charge, ChargeStatus, CreateChargeOptions, CreateChargeResponse, CreateCustomerOptions, CreateCustomerResponse, CreatePixCustomer, CreatePixOptions, CreatePixResponse, CreateProjectOptions, CreateProjectResponse, Customer, DocumentType, type ErrorResponse, GetChargeResponse, GetTransactionResponse, ListChargesOptions, ListChargesResponse, ListCustomersOptions, ListCustomersResponse, ListProjectsOptions, ListProjectsResponse, NotificationType, type PaginatedResponse, type PaginationOptions, PaymentCompletedData, PaymentCompletedEvent, PaymentFailedData, PaymentFailedEvent, PaymentMethod, Pdev, PixCharge, PixStatus, Project, RefundCompletedData, RefundCompletedEvent, type Response, SortBy, SortOrder, Transaction, TransactionPaymentMethod, TransactionStatus, TransactionType, WebhookEvent, WebhookEventType, WebhookHeaders, WebhookPayload, parseWebhook };
474
+ export { Charge, ChargeStatus, CreateChargeOptions, CreateChargeResponse, CreateCustomerOptions, CreateCustomerResponse, CreatePixCustomer, CreatePixOptions, CreatePixResponse, CreateProjectOptions, CreateProjectResponse, Customer, DocumentType, type ErrorResponse, GetChargeResponse, GetTransactionResponse, ListChargesOptions, ListChargesResponse, ListCustomersOptions, ListCustomersResponse, ListProjectsOptions, ListProjectsResponse, NotificationType, type PaginatedResponse, type PaginationOptions, PaymentCompletedData, PaymentCompletedEvent, PaymentMethod, Pdev, PixCharge, PixStatus, Project, RefundCompletedData, RefundCompletedEvent, type Response, SortBy, SortOrder, Transaction, TransactionPaymentMethod, TransactionStatus, TransactionType, WebhookEvent, WebhookEventType, WebhookHeaders, WebhookPayload, WithdrawalCompletedData, WithdrawalCompletedEvent, WithdrawalFailedData, WithdrawalFailedEvent, parseWebhook };
package/dist/index.d.mts CHANGED
@@ -282,7 +282,7 @@ declare class Pdev {
282
282
  /**
283
283
  * Available webhook event types
284
284
  */
285
- type WebhookEventType = 'payment_completed' | 'payment_failed' | 'refund_completed';
285
+ type WebhookEventType = 'payment_completed' | 'refund_completed' | 'withdrawal_completed' | 'withdrawal_failed';
286
286
  /**
287
287
  * Base webhook payload structure
288
288
  */
@@ -302,6 +302,8 @@ interface WebhookPayload<T extends WebhookEventType, D> {
302
302
  interface PaymentCompletedData {
303
303
  /** Transaction identifier */
304
304
  transactionId: string;
305
+ /** Environment where the transaction occurred */
306
+ environment: 'production' | 'sandbox';
305
307
  /** Payment amount */
306
308
  amount: number;
307
309
  /** Platform fees charged */
@@ -316,25 +318,8 @@ interface PaymentCompletedData {
316
318
  status: 'completed';
317
319
  /** ISO 8601 timestamp of when payment was completed */
318
320
  completedAt: string;
319
- }
320
- /**
321
- * Data payload for payment_failed event
322
- */
323
- interface PaymentFailedData {
324
- /** Transaction identifier */
325
- transactionId: string;
326
- /** Payment amount */
327
- amount: number;
328
- /** Currency code (e.g., "BRL") */
329
- currency: string;
330
- /** Payment method used (e.g., "pix") */
331
- paymentMethod: string;
332
- /** Payment status */
333
- status: 'failed';
334
- /** ISO 8601 timestamp of when payment failed */
335
- failedAt: string;
336
- /** Reason for failure (e.g., "expired", "insufficient_funds") */
337
- failureReason: string;
321
+ /** Your external reference ID (optional) */
322
+ externalReference?: string;
338
323
  }
339
324
  /**
340
325
  * Data payload for refund_completed event
@@ -344,33 +329,85 @@ interface RefundCompletedData {
344
329
  refundTransactionId: string;
345
330
  /** Original payment transaction ID that was refunded */
346
331
  originalTransactionId: string;
332
+ /** Environment where the transaction occurred */
333
+ environment: 'production' | 'sandbox';
347
334
  /** Refunded amount */
348
335
  amount: number;
349
- /** Fees (typically 0 for refunds) */
336
+ /** Fees charged for the refund */
350
337
  feeAmount: number;
338
+ /** Net amount after fees */
339
+ netAmount: number;
351
340
  /** Currency code (e.g., "BRL") */
352
341
  currency: string;
353
342
  /** Refund status */
354
343
  status: 'completed';
355
344
  /** ISO 8601 timestamp of when refund was completed */
356
- refundedAt: string;
345
+ completedAt: string;
357
346
  }
358
347
  /**
359
- * Payment completed webhook event
348
+ * Data payload for withdrawal_completed event
360
349
  */
361
- type PaymentCompletedEvent = WebhookPayload<'payment_completed', PaymentCompletedData>;
350
+ interface WithdrawalCompletedData {
351
+ /** Withdrawal identifier */
352
+ withdrawalId: string;
353
+ /** Environment where the withdrawal occurred */
354
+ environment: 'production' | 'sandbox';
355
+ /** Withdrawal amount */
356
+ amount: number;
357
+ /** Fees charged for the withdrawal */
358
+ feeAmount: number;
359
+ /** Net amount transferred (amount - feeAmount) */
360
+ netAmount: number;
361
+ /** Currency code (e.g., "BRL") */
362
+ currency: string;
363
+ /** Withdrawal status */
364
+ status: 'completed';
365
+ /** ISO 8601 timestamp of when withdrawal was completed */
366
+ completedAt: string;
367
+ }
368
+ /**
369
+ * Data payload for withdrawal_failed event
370
+ */
371
+ interface WithdrawalFailedData {
372
+ /** Withdrawal identifier */
373
+ withdrawalId: string;
374
+ /** Environment where the withdrawal occurred */
375
+ environment: 'production' | 'sandbox';
376
+ /** Withdrawal amount */
377
+ amount: number;
378
+ /** Fees that would have been charged */
379
+ feeAmount: number;
380
+ /** Net amount that would have been transferred */
381
+ netAmount: number;
382
+ /** Currency code (e.g., "BRL") */
383
+ currency: string;
384
+ /** Withdrawal status */
385
+ status: 'failed';
386
+ /** ISO 8601 timestamp of when withdrawal failed */
387
+ failedAt: string;
388
+ /** Reason for failure (e.g., "insufficient_funds", "invalid_account") */
389
+ failureReason: string;
390
+ }
362
391
  /**
363
- * Payment failed webhook event
392
+ * Payment completed webhook event
364
393
  */
365
- type PaymentFailedEvent = WebhookPayload<'payment_failed', PaymentFailedData>;
394
+ type PaymentCompletedEvent = WebhookPayload<'payment_completed', PaymentCompletedData>;
366
395
  /**
367
396
  * Refund completed webhook event
368
397
  */
369
398
  type RefundCompletedEvent = WebhookPayload<'refund_completed', RefundCompletedData>;
399
+ /**
400
+ * Withdrawal completed webhook event
401
+ */
402
+ type WithdrawalCompletedEvent = WebhookPayload<'withdrawal_completed', WithdrawalCompletedData>;
403
+ /**
404
+ * Withdrawal failed webhook event
405
+ */
406
+ type WithdrawalFailedEvent = WebhookPayload<'withdrawal_failed', WithdrawalFailedData>;
370
407
  /**
371
408
  * Union type of all possible webhook events
372
409
  */
373
- type WebhookEvent = PaymentCompletedEvent | PaymentFailedEvent | RefundCompletedEvent;
410
+ type WebhookEvent = PaymentCompletedEvent | RefundCompletedEvent | WithdrawalCompletedEvent | WithdrawalFailedEvent;
374
411
  /**
375
412
  * Webhook headers sent with each request
376
413
  */
@@ -434,4 +471,4 @@ interface WebhookHeaders {
434
471
  */
435
472
  declare function parseWebhook(payload: string): WebhookEvent | null;
436
473
  //#endregion
437
- export { Charge, ChargeStatus, CreateChargeOptions, CreateChargeResponse, CreateCustomerOptions, CreateCustomerResponse, CreatePixCustomer, CreatePixOptions, CreatePixResponse, CreateProjectOptions, CreateProjectResponse, Customer, DocumentType, type ErrorResponse, GetChargeResponse, GetTransactionResponse, ListChargesOptions, ListChargesResponse, ListCustomersOptions, ListCustomersResponse, ListProjectsOptions, ListProjectsResponse, NotificationType, type PaginatedResponse, type PaginationOptions, PaymentCompletedData, PaymentCompletedEvent, PaymentFailedData, PaymentFailedEvent, PaymentMethod, Pdev, PixCharge, PixStatus, Project, RefundCompletedData, RefundCompletedEvent, type Response, SortBy, SortOrder, Transaction, TransactionPaymentMethod, TransactionStatus, TransactionType, WebhookEvent, WebhookEventType, WebhookHeaders, WebhookPayload, parseWebhook };
474
+ export { Charge, ChargeStatus, CreateChargeOptions, CreateChargeResponse, CreateCustomerOptions, CreateCustomerResponse, CreatePixCustomer, CreatePixOptions, CreatePixResponse, CreateProjectOptions, CreateProjectResponse, Customer, DocumentType, type ErrorResponse, GetChargeResponse, GetTransactionResponse, ListChargesOptions, ListChargesResponse, ListCustomersOptions, ListCustomersResponse, ListProjectsOptions, ListProjectsResponse, NotificationType, type PaginatedResponse, type PaginationOptions, PaymentCompletedData, PaymentCompletedEvent, PaymentMethod, Pdev, PixCharge, PixStatus, Project, RefundCompletedData, RefundCompletedEvent, type Response, SortBy, SortOrder, Transaction, TransactionPaymentMethod, TransactionStatus, TransactionType, WebhookEvent, WebhookEventType, WebhookHeaders, WebhookPayload, WithdrawalCompletedData, WithdrawalCompletedEvent, WithdrawalFailedData, WithdrawalFailedEvent, parseWebhook };
package/dist/index.mjs CHANGED
@@ -196,8 +196,9 @@ function isValidWebhookEvent(event) {
196
196
  if (typeof obj.data !== "object" || obj.data === null) return false;
197
197
  return [
198
198
  "payment_completed",
199
- "payment_failed",
200
- "refund_completed"
199
+ "refund_completed",
200
+ "withdrawal_completed",
201
+ "withdrawal_failed"
201
202
  ].includes(obj.event);
202
203
  }
203
204
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pague-dev/sdk-node",
3
- "version": "0.1.5",
3
+ "version": "0.2.1",
4
4
  "description": "Node.js SDK for the pague.dev API",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",