@@ -24,6 +24,11 @@ import {
2424 SchedulePayment ,
2525 PaymentRequestAutomaticPix ,
2626 CreatePaymentRequestAutomaticPix ,
27+ AutomaticPixPayment ,
28+ ScheduleAutomaticPixPaymentRequest ,
29+ RetryAutomaticPixPaymentRequest ,
30+ AutomaticPixPaymentListResponse ,
31+ PaymentPixAutomaticFilters ,
2732} from './types'
2833
2934/**
@@ -316,4 +321,93 @@ export class PluggyPaymentsClient extends BaseApi {
316321 async cancelScheduledPayments ( paymentRequest : string ) : Promise < void > {
317322 await this . createPostRequest ( `payments/requests/${ paymentRequest } /schedules/cancel` )
318323 }
324+
325+ /**
326+ * Schedule a new payment for an existing Pix Automático authorization
327+ * @param authorizationId ID of the Pix Automático authorization
328+ * @param payload ScheduleAutomaticPixPaymentRequest
329+ * @returns {AutomaticPixPayment } AutomaticPixPayment object
330+ */
331+ async scheduleAutomaticPixPayment (
332+ authorizationId : string ,
333+ payload : ScheduleAutomaticPixPaymentRequest
334+ ) : Promise < AutomaticPixPayment > {
335+ return await this . createPostRequest (
336+ `payments/requests/${ authorizationId } /automatic-pix/schedule` ,
337+ null ,
338+ payload
339+ )
340+ }
341+
342+ /**
343+ * Retry a failed scheduled Pix Automático payment
344+ * @param paymentRequestId ID of the payment request
345+ * @param automaticPixPaymentId ID of the Pix Automático authorization
346+ * @param payload RetryAutomaticPixPaymentRequest
347+ * @returns {AutomaticPixPayment } AutomaticPixPayment object
348+ */
349+ async retryAutomaticPixPayment (
350+ paymentRequestId : string ,
351+ automaticPixPaymentId : string ,
352+ payload : RetryAutomaticPixPaymentRequest
353+ ) : Promise < AutomaticPixPayment > {
354+ return await this . createPostRequest (
355+ `payments/requests/${ paymentRequestId } /automatic-pix/schedules/${ automaticPixPaymentId } /retry` ,
356+ null ,
357+ payload
358+ )
359+ }
360+
361+ /**
362+ * List scheduled Pix Automático payments for an authorization
363+ * @param automaticPixPaymentId ID of the Pix Automático authorization
364+ * @param options PaymentPixAutomaticFilters
365+ * @returns {AutomaticPixPaymentListResponse } List of scheduled payments
366+ */
367+ async fetchAutomaticPixPayments (
368+ automaticPixPaymentId : string ,
369+ options : PaymentPixAutomaticFilters
370+ ) : Promise < AutomaticPixPaymentListResponse > {
371+ return await this . createGetRequest (
372+ `payments/requests/${ automaticPixPaymentId } /automatic-pix/schedules` ,
373+ options
374+ )
375+ }
376+
377+ /**
378+ * Fetch a single scheduled Pix Automático payment
379+ * @param paymentRequestId ID of the payment request
380+ * @param automaticPixPaymentId ID of the Pix Automático authorization
381+ * @returns {AutomaticPixPayment } AutomaticPixPayment object
382+ */
383+ async fetchAutomaticPixPayment (
384+ paymentRequestId : string ,
385+ automaticPixPaymentId : string
386+ ) : Promise < AutomaticPixPayment > {
387+ return await this . createGetRequest (
388+ `payments/requests/${ paymentRequestId } /automatic-pix/schedules/${ automaticPixPaymentId } `
389+ )
390+ }
391+
392+ /**
393+ * Cancel a scheduled Pix Automático payment
394+ * @param paymentRequestId ID of the payment request
395+ * @param automaticPixPaymentId ID of the Pix Automático authorization
396+ */
397+ async cancelAutomaticPixPayment (
398+ paymentRequestId : string ,
399+ automaticPixPaymentId : string
400+ ) : Promise < void > {
401+ await this . createPostRequest (
402+ `payments/requests/${ paymentRequestId } /automatic-pix/schedules/${ automaticPixPaymentId } /cancel`
403+ )
404+ }
405+
406+ /**
407+ * Cancel all scheduled Pix Automático payments for a payment request authorization
408+ * @param paymentRequestId ID of the payment request
409+ */
410+ async cancelAutomaticPixAuthorization ( paymentRequestId : string ) : Promise < void > {
411+ await this . createPostRequest ( `payments/requests/${ paymentRequestId } /automatic-pix/cancel` )
412+ }
319413}
0 commit comments