@pague-dev/sdk-node 0.1.4 → 0.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 +2 -0
- package/dist/index.cjs +3 -2
- package/dist/index.d.cts +57 -28
- package/dist/index.d.mts +57 -28
- package/dist/index.mjs +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,6 +24,8 @@ await pdev.pix.create({ amount, description, customer });
|
|
|
24
24
|
|
|
25
25
|
// Charges
|
|
26
26
|
await pdev.charges.create({ projectId, name, amount, paymentMethods });
|
|
27
|
+
await pdev.charges.list({ page, limit });
|
|
28
|
+
await pdev.charges.get(id);
|
|
27
29
|
|
|
28
30
|
// Customers
|
|
29
31
|
await pdev.customers.create({ name, document });
|
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
|
-
"
|
|
201
|
-
"
|
|
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' | '
|
|
285
|
+
type WebhookEventType = 'payment_completed' | 'refund_completed' | 'withdrawal_completed' | 'withdrawal_failed';
|
|
286
286
|
/**
|
|
287
287
|
* Base webhook payload structure
|
|
288
288
|
*/
|
|
@@ -316,25 +316,8 @@ interface PaymentCompletedData {
|
|
|
316
316
|
status: 'completed';
|
|
317
317
|
/** ISO 8601 timestamp of when payment was completed */
|
|
318
318
|
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;
|
|
319
|
+
/** Your external reference ID (optional) */
|
|
320
|
+
externalReference?: string;
|
|
338
321
|
}
|
|
339
322
|
/**
|
|
340
323
|
* Data payload for refund_completed event
|
|
@@ -346,31 +329,77 @@ interface RefundCompletedData {
|
|
|
346
329
|
originalTransactionId: string;
|
|
347
330
|
/** Refunded amount */
|
|
348
331
|
amount: number;
|
|
349
|
-
/** Fees
|
|
332
|
+
/** Fees charged for the refund */
|
|
350
333
|
feeAmount: number;
|
|
334
|
+
/** Net amount after fees */
|
|
335
|
+
netAmount: number;
|
|
351
336
|
/** Currency code (e.g., "BRL") */
|
|
352
337
|
currency: string;
|
|
353
338
|
/** Refund status */
|
|
354
339
|
status: 'completed';
|
|
355
340
|
/** ISO 8601 timestamp of when refund was completed */
|
|
356
|
-
|
|
341
|
+
completedAt: string;
|
|
357
342
|
}
|
|
358
343
|
/**
|
|
359
|
-
*
|
|
344
|
+
* Data payload for withdrawal_completed event
|
|
360
345
|
*/
|
|
361
|
-
|
|
346
|
+
interface WithdrawalCompletedData {
|
|
347
|
+
/** Withdrawal identifier */
|
|
348
|
+
withdrawalId: string;
|
|
349
|
+
/** Withdrawal amount */
|
|
350
|
+
amount: number;
|
|
351
|
+
/** Fees charged for the withdrawal */
|
|
352
|
+
feeAmount: number;
|
|
353
|
+
/** Net amount transferred (amount - feeAmount) */
|
|
354
|
+
netAmount: number;
|
|
355
|
+
/** Currency code (e.g., "BRL") */
|
|
356
|
+
currency: string;
|
|
357
|
+
/** Withdrawal status */
|
|
358
|
+
status: 'completed';
|
|
359
|
+
/** ISO 8601 timestamp of when withdrawal was completed */
|
|
360
|
+
completedAt: string;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Data payload for withdrawal_failed event
|
|
364
|
+
*/
|
|
365
|
+
interface WithdrawalFailedData {
|
|
366
|
+
/** Withdrawal identifier */
|
|
367
|
+
withdrawalId: string;
|
|
368
|
+
/** Withdrawal amount */
|
|
369
|
+
amount: number;
|
|
370
|
+
/** Fees that would have been charged */
|
|
371
|
+
feeAmount: number;
|
|
372
|
+
/** Net amount that would have been transferred */
|
|
373
|
+
netAmount: number;
|
|
374
|
+
/** Currency code (e.g., "BRL") */
|
|
375
|
+
currency: string;
|
|
376
|
+
/** Withdrawal status */
|
|
377
|
+
status: 'failed';
|
|
378
|
+
/** ISO 8601 timestamp of when withdrawal failed */
|
|
379
|
+
failedAt: string;
|
|
380
|
+
/** Reason for failure (e.g., "insufficient_funds", "invalid_account") */
|
|
381
|
+
failureReason: string;
|
|
382
|
+
}
|
|
362
383
|
/**
|
|
363
|
-
* Payment
|
|
384
|
+
* Payment completed webhook event
|
|
364
385
|
*/
|
|
365
|
-
type
|
|
386
|
+
type PaymentCompletedEvent = WebhookPayload<'payment_completed', PaymentCompletedData>;
|
|
366
387
|
/**
|
|
367
388
|
* Refund completed webhook event
|
|
368
389
|
*/
|
|
369
390
|
type RefundCompletedEvent = WebhookPayload<'refund_completed', RefundCompletedData>;
|
|
391
|
+
/**
|
|
392
|
+
* Withdrawal completed webhook event
|
|
393
|
+
*/
|
|
394
|
+
type WithdrawalCompletedEvent = WebhookPayload<'withdrawal_completed', WithdrawalCompletedData>;
|
|
395
|
+
/**
|
|
396
|
+
* Withdrawal failed webhook event
|
|
397
|
+
*/
|
|
398
|
+
type WithdrawalFailedEvent = WebhookPayload<'withdrawal_failed', WithdrawalFailedData>;
|
|
370
399
|
/**
|
|
371
400
|
* Union type of all possible webhook events
|
|
372
401
|
*/
|
|
373
|
-
type WebhookEvent = PaymentCompletedEvent |
|
|
402
|
+
type WebhookEvent = PaymentCompletedEvent | RefundCompletedEvent | WithdrawalCompletedEvent | WithdrawalFailedEvent;
|
|
374
403
|
/**
|
|
375
404
|
* Webhook headers sent with each request
|
|
376
405
|
*/
|
|
@@ -434,4 +463,4 @@ interface WebhookHeaders {
|
|
|
434
463
|
*/
|
|
435
464
|
declare function parseWebhook(payload: string): WebhookEvent | null;
|
|
436
465
|
//#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,
|
|
466
|
+
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' | '
|
|
285
|
+
type WebhookEventType = 'payment_completed' | 'refund_completed' | 'withdrawal_completed' | 'withdrawal_failed';
|
|
286
286
|
/**
|
|
287
287
|
* Base webhook payload structure
|
|
288
288
|
*/
|
|
@@ -316,25 +316,8 @@ interface PaymentCompletedData {
|
|
|
316
316
|
status: 'completed';
|
|
317
317
|
/** ISO 8601 timestamp of when payment was completed */
|
|
318
318
|
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;
|
|
319
|
+
/** Your external reference ID (optional) */
|
|
320
|
+
externalReference?: string;
|
|
338
321
|
}
|
|
339
322
|
/**
|
|
340
323
|
* Data payload for refund_completed event
|
|
@@ -346,31 +329,77 @@ interface RefundCompletedData {
|
|
|
346
329
|
originalTransactionId: string;
|
|
347
330
|
/** Refunded amount */
|
|
348
331
|
amount: number;
|
|
349
|
-
/** Fees
|
|
332
|
+
/** Fees charged for the refund */
|
|
350
333
|
feeAmount: number;
|
|
334
|
+
/** Net amount after fees */
|
|
335
|
+
netAmount: number;
|
|
351
336
|
/** Currency code (e.g., "BRL") */
|
|
352
337
|
currency: string;
|
|
353
338
|
/** Refund status */
|
|
354
339
|
status: 'completed';
|
|
355
340
|
/** ISO 8601 timestamp of when refund was completed */
|
|
356
|
-
|
|
341
|
+
completedAt: string;
|
|
357
342
|
}
|
|
358
343
|
/**
|
|
359
|
-
*
|
|
344
|
+
* Data payload for withdrawal_completed event
|
|
360
345
|
*/
|
|
361
|
-
|
|
346
|
+
interface WithdrawalCompletedData {
|
|
347
|
+
/** Withdrawal identifier */
|
|
348
|
+
withdrawalId: string;
|
|
349
|
+
/** Withdrawal amount */
|
|
350
|
+
amount: number;
|
|
351
|
+
/** Fees charged for the withdrawal */
|
|
352
|
+
feeAmount: number;
|
|
353
|
+
/** Net amount transferred (amount - feeAmount) */
|
|
354
|
+
netAmount: number;
|
|
355
|
+
/** Currency code (e.g., "BRL") */
|
|
356
|
+
currency: string;
|
|
357
|
+
/** Withdrawal status */
|
|
358
|
+
status: 'completed';
|
|
359
|
+
/** ISO 8601 timestamp of when withdrawal was completed */
|
|
360
|
+
completedAt: string;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Data payload for withdrawal_failed event
|
|
364
|
+
*/
|
|
365
|
+
interface WithdrawalFailedData {
|
|
366
|
+
/** Withdrawal identifier */
|
|
367
|
+
withdrawalId: string;
|
|
368
|
+
/** Withdrawal amount */
|
|
369
|
+
amount: number;
|
|
370
|
+
/** Fees that would have been charged */
|
|
371
|
+
feeAmount: number;
|
|
372
|
+
/** Net amount that would have been transferred */
|
|
373
|
+
netAmount: number;
|
|
374
|
+
/** Currency code (e.g., "BRL") */
|
|
375
|
+
currency: string;
|
|
376
|
+
/** Withdrawal status */
|
|
377
|
+
status: 'failed';
|
|
378
|
+
/** ISO 8601 timestamp of when withdrawal failed */
|
|
379
|
+
failedAt: string;
|
|
380
|
+
/** Reason for failure (e.g., "insufficient_funds", "invalid_account") */
|
|
381
|
+
failureReason: string;
|
|
382
|
+
}
|
|
362
383
|
/**
|
|
363
|
-
* Payment
|
|
384
|
+
* Payment completed webhook event
|
|
364
385
|
*/
|
|
365
|
-
type
|
|
386
|
+
type PaymentCompletedEvent = WebhookPayload<'payment_completed', PaymentCompletedData>;
|
|
366
387
|
/**
|
|
367
388
|
* Refund completed webhook event
|
|
368
389
|
*/
|
|
369
390
|
type RefundCompletedEvent = WebhookPayload<'refund_completed', RefundCompletedData>;
|
|
391
|
+
/**
|
|
392
|
+
* Withdrawal completed webhook event
|
|
393
|
+
*/
|
|
394
|
+
type WithdrawalCompletedEvent = WebhookPayload<'withdrawal_completed', WithdrawalCompletedData>;
|
|
395
|
+
/**
|
|
396
|
+
* Withdrawal failed webhook event
|
|
397
|
+
*/
|
|
398
|
+
type WithdrawalFailedEvent = WebhookPayload<'withdrawal_failed', WithdrawalFailedData>;
|
|
370
399
|
/**
|
|
371
400
|
* Union type of all possible webhook events
|
|
372
401
|
*/
|
|
373
|
-
type WebhookEvent = PaymentCompletedEvent |
|
|
402
|
+
type WebhookEvent = PaymentCompletedEvent | RefundCompletedEvent | WithdrawalCompletedEvent | WithdrawalFailedEvent;
|
|
374
403
|
/**
|
|
375
404
|
* Webhook headers sent with each request
|
|
376
405
|
*/
|
|
@@ -434,4 +463,4 @@ interface WebhookHeaders {
|
|
|
434
463
|
*/
|
|
435
464
|
declare function parseWebhook(payload: string): WebhookEvent | null;
|
|
436
465
|
//#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,
|
|
466
|
+
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
|
-
"
|
|
200
|
-
"
|
|
199
|
+
"refund_completed",
|
|
200
|
+
"withdrawal_completed",
|
|
201
|
+
"withdrawal_failed"
|
|
201
202
|
].includes(obj.event);
|
|
202
203
|
}
|
|
203
204
|
/**
|