diff --git a/src/paymentsClient.ts b/src/paymentsClient.ts index 7f1f5e3..3207dc9 100644 --- a/src/paymentsClient.ts +++ b/src/paymentsClient.ts @@ -1,7 +1,6 @@ import { BaseApi } from './baseApi' import { PageResponse, - CreatePaymentIntent, CreatePaymentRequest, PaymentIntent, PaymentIntentsFilters, @@ -22,6 +21,7 @@ import { SmartAccount, SmartAccountBalance, PaymentReceipt, + CreatePaymentIntent, } from './types' /** @@ -68,8 +68,8 @@ export class PluggyPaymentsClient extends BaseApi { * Creates a payment intent * @returns {PaymentIntent} PaymentIntent object */ - async createPaymentIntent(paymentIntent: CreatePaymentIntent): Promise { - return this.createPostRequest(`payments/intents`, null, paymentIntent) + async createPaymentIntent(params: CreatePaymentIntent): Promise { + return this.createPostRequest(`payments/intents`, null, params) } /** diff --git a/src/types/payments/paymentIntent.ts b/src/types/payments/paymentIntent.ts index 9d656be..4bfb0ec 100644 --- a/src/types/payments/paymentIntent.ts +++ b/src/types/payments/paymentIntent.ts @@ -27,10 +27,16 @@ export type PaymentIntentErrorStatus = typeof PAYMENT_INTENT_ERROR_STATUSES[numb export type PaymentIntentStatus = typeof PAYMENT_INTENT_STATUSES[number] +export type PaymentIntentPixQrData = { + qr: string + value: string +} + export type PaymentIntent = { id: string - connector: Connector + connector: Connector | null consentUrl: string | null + pixData: PaymentIntentPixQrData | null paymentRequest: PaymentRequest | null bulkPayment: Omit | null status: PaymentIntentStatus @@ -38,8 +44,28 @@ export type PaymentIntent = { updatedAt: Date } -export type CreatePaymentIntent = { +type BaseCreatePaymentIntentParams = { connectorId: number - parameters: Record + parameters: { + cpf: string + cnpj?: string + } +} + +export type CreatePaymentIntentPaymentRequestsParams = BaseCreatePaymentIntentParams & { paymentRequestId: string } + +export type CreatePaymentIntentBulkParmas = BaseCreatePaymentIntentParams & { + bulkPaymentId: string +} + +export type CreatePaymentIntentBulkPixQrParams = { + bulkPaymentId: string + paymentMethod: 'PIX' +} + +export type CreatePaymentIntent = + | CreatePaymentIntentPaymentRequestsParams + | CreatePaymentIntentBulkParmas + | CreatePaymentIntentBulkPixQrParams