Skip to content

Commit

Permalink
fix(payment-intent): add missing type and improve create type. (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasMontone committed Apr 16, 2024
1 parent bf76cfc commit c52ed5e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/paymentsClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { BaseApi } from './baseApi'
import {
PageResponse,
CreatePaymentIntent,
CreatePaymentRequest,
PaymentIntent,
PaymentIntentsFilters,
Expand All @@ -22,6 +21,7 @@ import {
SmartAccount,
SmartAccountBalance,
PaymentReceipt,
CreatePaymentIntent,
} from './types'

/**
Expand Down Expand Up @@ -68,8 +68,8 @@ export class PluggyPaymentsClient extends BaseApi {
* Creates a payment intent
* @returns {PaymentIntent} PaymentIntent object
*/
async createPaymentIntent(paymentIntent: CreatePaymentIntent): Promise<PaymentIntent> {
return this.createPostRequest(`payments/intents`, null, paymentIntent)
async createPaymentIntent(params: CreatePaymentIntent): Promise<PaymentIntent> {
return this.createPostRequest(`payments/intents`, null, params)
}

/**
Expand Down
32 changes: 29 additions & 3 deletions src/types/payments/paymentIntent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,45 @@ 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<BulkPayment, 'smartAccount' | 'paymentRequests'> | null
status: PaymentIntentStatus
createdAt: Date
updatedAt: Date
}

export type CreatePaymentIntent = {
type BaseCreatePaymentIntentParams = {
connectorId: number
parameters: Record<string, string>
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

0 comments on commit c52ed5e

Please sign in to comment.