@pague-dev/sdk-node 1.2.0 → 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/dist/index.cjs +3 -1
- package/dist/index.d.cts +73 -4
- package/dist/index.d.mts +73 -4
- package/dist/index.mjs +3 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -223,9 +223,11 @@ function isValidWebhookEvent(event) {
|
|
|
223
223
|
if (typeof obj.data !== "object" || obj.data === null) return false;
|
|
224
224
|
return [
|
|
225
225
|
"payment_completed",
|
|
226
|
+
"payment_expired",
|
|
226
227
|
"refund_completed",
|
|
227
228
|
"withdrawal_completed",
|
|
228
|
-
"withdrawal_failed"
|
|
229
|
+
"withdrawal_failed",
|
|
230
|
+
"withdrawal_reversed"
|
|
229
231
|
].includes(obj.event);
|
|
230
232
|
}
|
|
231
233
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -20,6 +20,7 @@ interface CompanyDetail {
|
|
|
20
20
|
interface BalanceDetail {
|
|
21
21
|
available: BalanceAmount;
|
|
22
22
|
promotional: BalanceAmount;
|
|
23
|
+
held: BalanceAmount;
|
|
23
24
|
total: BalanceAmount;
|
|
24
25
|
currency: string;
|
|
25
26
|
updatedAt: string;
|
|
@@ -384,7 +385,7 @@ declare class Pdev {
|
|
|
384
385
|
/**
|
|
385
386
|
* Available webhook event types
|
|
386
387
|
*/
|
|
387
|
-
type WebhookEventType = 'payment_completed' | 'refund_completed' | 'withdrawal_completed' | 'withdrawal_failed';
|
|
388
|
+
type WebhookEventType = 'payment_completed' | 'payment_expired' | 'refund_completed' | 'withdrawal_completed' | 'withdrawal_failed' | 'withdrawal_reversed';
|
|
388
389
|
/**
|
|
389
390
|
* Base webhook payload structure
|
|
390
391
|
*/
|
|
@@ -425,6 +426,33 @@ interface PaymentCompletedData {
|
|
|
425
426
|
/** Custom metadata passed when creating the payment */
|
|
426
427
|
metadata?: Record<string, unknown>;
|
|
427
428
|
}
|
|
429
|
+
/**
|
|
430
|
+
* Data payload for payment_expired event
|
|
431
|
+
*/
|
|
432
|
+
interface PaymentExpiredData {
|
|
433
|
+
/** Transaction identifier */
|
|
434
|
+
transactionId: string;
|
|
435
|
+
/** Environment where the transaction occurred */
|
|
436
|
+
environment: 'production' | 'sandbox';
|
|
437
|
+
/** Payment amount */
|
|
438
|
+
amount: number;
|
|
439
|
+
/** Platform fees (always 0 for expired payments) */
|
|
440
|
+
feeAmount: number;
|
|
441
|
+
/** Net amount (always 0 for expired payments) */
|
|
442
|
+
netAmount: number;
|
|
443
|
+
/** Currency code (e.g., "BRL") */
|
|
444
|
+
currency: string;
|
|
445
|
+
/** Payment method used (e.g., "pix") */
|
|
446
|
+
paymentMethod: string;
|
|
447
|
+
/** Payment status */
|
|
448
|
+
status: 'expired';
|
|
449
|
+
/** ISO 8601 timestamp of when payment expired */
|
|
450
|
+
expiredAt: string;
|
|
451
|
+
/** Your external reference ID (optional) */
|
|
452
|
+
externalReference?: string;
|
|
453
|
+
/** Custom metadata passed when creating the payment */
|
|
454
|
+
metadata?: Record<string, unknown>;
|
|
455
|
+
}
|
|
428
456
|
/**
|
|
429
457
|
* Data payload for refund_completed event
|
|
430
458
|
*/
|
|
@@ -443,10 +471,14 @@ interface RefundCompletedData {
|
|
|
443
471
|
netAmount: number;
|
|
444
472
|
/** Currency code (e.g., "BRL") */
|
|
445
473
|
currency: string;
|
|
474
|
+
/** Payment method of the original transaction */
|
|
475
|
+
paymentMethod: string;
|
|
446
476
|
/** Refund status */
|
|
447
477
|
status: 'completed';
|
|
448
478
|
/** ISO 8601 timestamp of when refund was completed */
|
|
449
|
-
|
|
479
|
+
refundedAt: string;
|
|
480
|
+
/** Your external reference ID from the original payment (optional) */
|
|
481
|
+
externalReference?: string;
|
|
450
482
|
/** Custom metadata from the original payment */
|
|
451
483
|
metadata?: Record<string, unknown>;
|
|
452
484
|
}
|
|
@@ -498,10 +530,43 @@ interface WithdrawalFailedData {
|
|
|
498
530
|
/** Custom metadata from the withdrawal request */
|
|
499
531
|
metadata?: Record<string, unknown>;
|
|
500
532
|
}
|
|
533
|
+
/**
|
|
534
|
+
* Data payload for withdrawal_reversed event
|
|
535
|
+
*/
|
|
536
|
+
interface WithdrawalReversedData {
|
|
537
|
+
/** Reversal transaction identifier */
|
|
538
|
+
reversalTransactionId: string;
|
|
539
|
+
/** Original withdrawal transaction ID that was reversed */
|
|
540
|
+
originalTransactionId: string;
|
|
541
|
+
/** Environment where the transaction occurred */
|
|
542
|
+
environment: 'production' | 'sandbox';
|
|
543
|
+
/** Reversal amount */
|
|
544
|
+
amount: number;
|
|
545
|
+
/** Fees charged for the reversal */
|
|
546
|
+
feeAmount: number;
|
|
547
|
+
/** Net amount after fees */
|
|
548
|
+
netAmount: number;
|
|
549
|
+
/** Currency code (e.g., "BRL") */
|
|
550
|
+
currency: string;
|
|
551
|
+
/** Payment method (e.g., "pix") */
|
|
552
|
+
paymentMethod: string;
|
|
553
|
+
/** Reversal status */
|
|
554
|
+
status: 'completed';
|
|
555
|
+
/** ISO 8601 timestamp of when withdrawal was reversed */
|
|
556
|
+
reversedAt: string;
|
|
557
|
+
/** Your external reference ID from the original withdrawal (optional) */
|
|
558
|
+
externalReference?: string;
|
|
559
|
+
/** Custom metadata from the original withdrawal */
|
|
560
|
+
metadata?: Record<string, unknown>;
|
|
561
|
+
}
|
|
501
562
|
/**
|
|
502
563
|
* Payment completed webhook event
|
|
503
564
|
*/
|
|
504
565
|
type PaymentCompletedEvent = WebhookPayload<'payment_completed', PaymentCompletedData>;
|
|
566
|
+
/**
|
|
567
|
+
* Payment expired webhook event
|
|
568
|
+
*/
|
|
569
|
+
type PaymentExpiredEvent = WebhookPayload<'payment_expired', PaymentExpiredData>;
|
|
505
570
|
/**
|
|
506
571
|
* Refund completed webhook event
|
|
507
572
|
*/
|
|
@@ -514,10 +579,14 @@ type WithdrawalCompletedEvent = WebhookPayload<'withdrawal_completed', Withdrawa
|
|
|
514
579
|
* Withdrawal failed webhook event
|
|
515
580
|
*/
|
|
516
581
|
type WithdrawalFailedEvent = WebhookPayload<'withdrawal_failed', WithdrawalFailedData>;
|
|
582
|
+
/**
|
|
583
|
+
* Withdrawal reversed webhook event
|
|
584
|
+
*/
|
|
585
|
+
type WithdrawalReversedEvent = WebhookPayload<'withdrawal_reversed', WithdrawalReversedData>;
|
|
517
586
|
/**
|
|
518
587
|
* Union type of all possible webhook events
|
|
519
588
|
*/
|
|
520
|
-
type WebhookEvent = PaymentCompletedEvent | RefundCompletedEvent | WithdrawalCompletedEvent | WithdrawalFailedEvent;
|
|
589
|
+
type WebhookEvent = PaymentCompletedEvent | PaymentExpiredEvent | RefundCompletedEvent | WithdrawalCompletedEvent | WithdrawalFailedEvent | WithdrawalReversedEvent;
|
|
521
590
|
/**
|
|
522
591
|
* Webhook headers sent with each request
|
|
523
592
|
*/
|
|
@@ -607,4 +676,4 @@ interface WebhookHeaders {
|
|
|
607
676
|
declare function verifyWebhookSignature(payload: string, signature: string, secret: string): boolean;
|
|
608
677
|
declare function parseWebhook(payload: string): WebhookEvent | null;
|
|
609
678
|
//#endregion
|
|
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 };
|
|
679
|
+
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, WithdrawalReversedData, WithdrawalReversedEvent, WithdrawalStatus, parseWebhook, verifyWebhookSignature };
|
package/dist/index.d.mts
CHANGED
|
@@ -20,6 +20,7 @@ interface CompanyDetail {
|
|
|
20
20
|
interface BalanceDetail {
|
|
21
21
|
available: BalanceAmount;
|
|
22
22
|
promotional: BalanceAmount;
|
|
23
|
+
held: BalanceAmount;
|
|
23
24
|
total: BalanceAmount;
|
|
24
25
|
currency: string;
|
|
25
26
|
updatedAt: string;
|
|
@@ -384,7 +385,7 @@ declare class Pdev {
|
|
|
384
385
|
/**
|
|
385
386
|
* Available webhook event types
|
|
386
387
|
*/
|
|
387
|
-
type WebhookEventType = 'payment_completed' | 'refund_completed' | 'withdrawal_completed' | 'withdrawal_failed';
|
|
388
|
+
type WebhookEventType = 'payment_completed' | 'payment_expired' | 'refund_completed' | 'withdrawal_completed' | 'withdrawal_failed' | 'withdrawal_reversed';
|
|
388
389
|
/**
|
|
389
390
|
* Base webhook payload structure
|
|
390
391
|
*/
|
|
@@ -425,6 +426,33 @@ interface PaymentCompletedData {
|
|
|
425
426
|
/** Custom metadata passed when creating the payment */
|
|
426
427
|
metadata?: Record<string, unknown>;
|
|
427
428
|
}
|
|
429
|
+
/**
|
|
430
|
+
* Data payload for payment_expired event
|
|
431
|
+
*/
|
|
432
|
+
interface PaymentExpiredData {
|
|
433
|
+
/** Transaction identifier */
|
|
434
|
+
transactionId: string;
|
|
435
|
+
/** Environment where the transaction occurred */
|
|
436
|
+
environment: 'production' | 'sandbox';
|
|
437
|
+
/** Payment amount */
|
|
438
|
+
amount: number;
|
|
439
|
+
/** Platform fees (always 0 for expired payments) */
|
|
440
|
+
feeAmount: number;
|
|
441
|
+
/** Net amount (always 0 for expired payments) */
|
|
442
|
+
netAmount: number;
|
|
443
|
+
/** Currency code (e.g., "BRL") */
|
|
444
|
+
currency: string;
|
|
445
|
+
/** Payment method used (e.g., "pix") */
|
|
446
|
+
paymentMethod: string;
|
|
447
|
+
/** Payment status */
|
|
448
|
+
status: 'expired';
|
|
449
|
+
/** ISO 8601 timestamp of when payment expired */
|
|
450
|
+
expiredAt: string;
|
|
451
|
+
/** Your external reference ID (optional) */
|
|
452
|
+
externalReference?: string;
|
|
453
|
+
/** Custom metadata passed when creating the payment */
|
|
454
|
+
metadata?: Record<string, unknown>;
|
|
455
|
+
}
|
|
428
456
|
/**
|
|
429
457
|
* Data payload for refund_completed event
|
|
430
458
|
*/
|
|
@@ -443,10 +471,14 @@ interface RefundCompletedData {
|
|
|
443
471
|
netAmount: number;
|
|
444
472
|
/** Currency code (e.g., "BRL") */
|
|
445
473
|
currency: string;
|
|
474
|
+
/** Payment method of the original transaction */
|
|
475
|
+
paymentMethod: string;
|
|
446
476
|
/** Refund status */
|
|
447
477
|
status: 'completed';
|
|
448
478
|
/** ISO 8601 timestamp of when refund was completed */
|
|
449
|
-
|
|
479
|
+
refundedAt: string;
|
|
480
|
+
/** Your external reference ID from the original payment (optional) */
|
|
481
|
+
externalReference?: string;
|
|
450
482
|
/** Custom metadata from the original payment */
|
|
451
483
|
metadata?: Record<string, unknown>;
|
|
452
484
|
}
|
|
@@ -498,10 +530,43 @@ interface WithdrawalFailedData {
|
|
|
498
530
|
/** Custom metadata from the withdrawal request */
|
|
499
531
|
metadata?: Record<string, unknown>;
|
|
500
532
|
}
|
|
533
|
+
/**
|
|
534
|
+
* Data payload for withdrawal_reversed event
|
|
535
|
+
*/
|
|
536
|
+
interface WithdrawalReversedData {
|
|
537
|
+
/** Reversal transaction identifier */
|
|
538
|
+
reversalTransactionId: string;
|
|
539
|
+
/** Original withdrawal transaction ID that was reversed */
|
|
540
|
+
originalTransactionId: string;
|
|
541
|
+
/** Environment where the transaction occurred */
|
|
542
|
+
environment: 'production' | 'sandbox';
|
|
543
|
+
/** Reversal amount */
|
|
544
|
+
amount: number;
|
|
545
|
+
/** Fees charged for the reversal */
|
|
546
|
+
feeAmount: number;
|
|
547
|
+
/** Net amount after fees */
|
|
548
|
+
netAmount: number;
|
|
549
|
+
/** Currency code (e.g., "BRL") */
|
|
550
|
+
currency: string;
|
|
551
|
+
/** Payment method (e.g., "pix") */
|
|
552
|
+
paymentMethod: string;
|
|
553
|
+
/** Reversal status */
|
|
554
|
+
status: 'completed';
|
|
555
|
+
/** ISO 8601 timestamp of when withdrawal was reversed */
|
|
556
|
+
reversedAt: string;
|
|
557
|
+
/** Your external reference ID from the original withdrawal (optional) */
|
|
558
|
+
externalReference?: string;
|
|
559
|
+
/** Custom metadata from the original withdrawal */
|
|
560
|
+
metadata?: Record<string, unknown>;
|
|
561
|
+
}
|
|
501
562
|
/**
|
|
502
563
|
* Payment completed webhook event
|
|
503
564
|
*/
|
|
504
565
|
type PaymentCompletedEvent = WebhookPayload<'payment_completed', PaymentCompletedData>;
|
|
566
|
+
/**
|
|
567
|
+
* Payment expired webhook event
|
|
568
|
+
*/
|
|
569
|
+
type PaymentExpiredEvent = WebhookPayload<'payment_expired', PaymentExpiredData>;
|
|
505
570
|
/**
|
|
506
571
|
* Refund completed webhook event
|
|
507
572
|
*/
|
|
@@ -514,10 +579,14 @@ type WithdrawalCompletedEvent = WebhookPayload<'withdrawal_completed', Withdrawa
|
|
|
514
579
|
* Withdrawal failed webhook event
|
|
515
580
|
*/
|
|
516
581
|
type WithdrawalFailedEvent = WebhookPayload<'withdrawal_failed', WithdrawalFailedData>;
|
|
582
|
+
/**
|
|
583
|
+
* Withdrawal reversed webhook event
|
|
584
|
+
*/
|
|
585
|
+
type WithdrawalReversedEvent = WebhookPayload<'withdrawal_reversed', WithdrawalReversedData>;
|
|
517
586
|
/**
|
|
518
587
|
* Union type of all possible webhook events
|
|
519
588
|
*/
|
|
520
|
-
type WebhookEvent = PaymentCompletedEvent | RefundCompletedEvent | WithdrawalCompletedEvent | WithdrawalFailedEvent;
|
|
589
|
+
type WebhookEvent = PaymentCompletedEvent | PaymentExpiredEvent | RefundCompletedEvent | WithdrawalCompletedEvent | WithdrawalFailedEvent | WithdrawalReversedEvent;
|
|
521
590
|
/**
|
|
522
591
|
* Webhook headers sent with each request
|
|
523
592
|
*/
|
|
@@ -607,4 +676,4 @@ interface WebhookHeaders {
|
|
|
607
676
|
declare function verifyWebhookSignature(payload: string, signature: string, secret: string): boolean;
|
|
608
677
|
declare function parseWebhook(payload: string): WebhookEvent | null;
|
|
609
678
|
//#endregion
|
|
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 };
|
|
679
|
+
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, WithdrawalReversedData, WithdrawalReversedEvent, WithdrawalStatus, parseWebhook, verifyWebhookSignature };
|
package/dist/index.mjs
CHANGED
|
@@ -223,9 +223,11 @@ function isValidWebhookEvent(event) {
|
|
|
223
223
|
if (typeof obj.data !== "object" || obj.data === null) return false;
|
|
224
224
|
return [
|
|
225
225
|
"payment_completed",
|
|
226
|
+
"payment_expired",
|
|
226
227
|
"refund_completed",
|
|
227
228
|
"withdrawal_completed",
|
|
228
|
-
"withdrawal_failed"
|
|
229
|
+
"withdrawal_failed",
|
|
230
|
+
"withdrawal_reversed"
|
|
229
231
|
].includes(obj.event);
|
|
230
232
|
}
|
|
231
233
|
/**
|