diff --git a/.changeset/warm-pandas-dance.md b/.changeset/warm-pandas-dance.md new file mode 100644 index 0000000..2a97625 --- /dev/null +++ b/.changeset/warm-pandas-dance.md @@ -0,0 +1,12 @@ +--- +"@blindpay/node": minor +--- + +Add support for Colombia (COP) and Argentina (ARS) payins + +- Added PSE payment method support for Colombia payins +- Added Transfers instruction support for Argentina payins +- Improved type definitions for Payin, PayinPaymentMethod, and related types +- Added new tracking fields for PSE and Transfers instructions +- Removed deprecated `export`, `get`, and `list` methods from payin quotes resource + diff --git a/package.json b/package.json index 390beba..aa9448c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blindpay/node", - "version": "3.0.0", + "version": "3.1.0", "description": "Official Node.js SDK for Blindpay API - Global payments infrastructure", "keywords": [ "blindpay", diff --git a/src/resources/payins/index.ts b/src/resources/payins/index.ts index 249f701..c4d2cde 100644 --- a/src/resources/payins/index.ts +++ b/src/resources/payins/index.ts @@ -1,8 +1,13 @@ import type { + AccountClass, + AchCopDocument, BlindpayApiResponse, + Currency, Network, PaginationMetadata, PaginationParams, + PayerRules, + PayinPaymentMethod, PayinTrackingComplete, PayinTrackingPartnerFee, PayinTrackingPayment, @@ -12,67 +17,70 @@ import type { } from "../../../types"; import type { InternalApiClient } from "../../internal/api-client"; +export type BlindpayBankDetails = { + routing_number: string; + account_number: string; + account_type: string; + swift_bic_code?: string | null; + ach?: { + routing_number: string; + account_number: string; + } | null; + wire?: { + routing_number: string; + account_number: string; + } | null; + rtp?: { + routing_number: string; + account_number: string; + } | null; + beneficiary: { + name: string; + address_line_1: string; + address_line_2: string; + }; +}; + export type Payin = { - receiver_id: string; id: string; - pix_code?: string; - memo_code?: string; - clabe?: string; + receiver_id: string; + pix_code?: string | null; + memo_code?: string | null; + clabe?: string | null; status: TransactionStatus; payin_quote_id: string; instance_id: string; - tracking_transaction?: PayinTrackingTransaction; - tracking_payment?: PayinTrackingPayment; - tracking_complete?: PayinTrackingComplete; + tracking_transaction: PayinTrackingTransaction; + tracking_payment: PayinTrackingPayment; + tracking_complete: PayinTrackingComplete; tracking_partner_fee?: PayinTrackingPartnerFee; created_at: string; updated_at: string; - image_url?: string; - first_name?: string; - last_name?: string; - legal_name?: string; - type: string; - payment_method: string; + image_url?: string | null | undefined; + first_name?: string | null | undefined; + last_name?: string | null | undefined; + legal_name?: string | null | undefined; + type: AccountClass; + payment_method: PayinPaymentMethod; sender_amount: number; receiver_amount: number; token: StablecoinToken; - partner_fee_amount: number; - total_fee_amount: number; + partner_fee_amount?: number | null; + total_fee_amount?: number | null; commercial_quotation: number; blindpay_quotation: number; - currency: string; - billing_fee: number; + currency: Extract; + billing_fee?: number | null; + is_otc?: boolean | null; + payer_rules?: PayerRules | null; name: string; - address: string; + address?: string | null; network: Network; - blindpay_bank_details: { - routing_number: string; - account_number: string; - account_type: string; - swift_bic_code: string; - ach: { - routing_number: string; - account_number: string; - }; - wire: { - routing_number: string; - account_number: string; - }; - rtp: { - routing_number: string; - account_number: string; - }; - beneficiary: { - name: string; - address_line_1: string; - address_line_2: string; - }; - receiving_bank: { - name: string; - address_line_1: string; - address_line_2: string; - }; - }; + blindpay_bank_details?: BlindpayBankDetails | null; + pse_payment_link?: string | null; + pse_full_name?: string | null; + pse_tax_id?: string | null; + pse_document_type?: Extract | null; }; export type ListPayinsInput = PaginationParams & { @@ -80,19 +88,15 @@ export type ListPayinsInput = PaginationParams & { receiver_id?: string; }; -export type ListPayinsResponse = { - data: Payin[]; - pagination: PaginationMetadata; -}; +export type ListPayinsResponse = + | { + data: Payin[]; + pagination: PaginationMetadata; + } + | Payin[]; export type CreatePayinInput = { quote_id: string; - sender_address: string; - receiver_address: string; - amount: number; - token: StablecoinToken; - network: Network; - description?: string | null; }; export type GetPayinInput = string; @@ -101,74 +105,7 @@ export type GetPayinResponse = Payin; export type GetPayinTrackInput = string; -export type GetPayinTrackResponse = { - receiver_id: string; - id: string; - pix_code: string; - memo_code: string; - clabe: string; - status: string; - payin_quote_id: string; - instance_id: string; - tracking_transaction: PayinTrackingTransaction; - tracking_payment: PayinTrackingPayment; - tracking_complete: PayinTrackingComplete; - tracking_partner_fee: PayinTrackingPartnerFee; - created_at: string; - updated_at: string; - image_url: string; - first_name: string; - last_name: string; - legal_name: string; - type: string; - payment_method: string; - sender_amount: number; - receiver_amount: number; - token: StablecoinToken; - partner_fee_amount: number; - total_fee_amount: number; - commercial_quotation: number; - blindpay_quotation: number; - currency: string; - billing_fee: number; - name: string; - address: string; - network: Network; - blindpay_bank_details: { - routing_number: string; - account_number: string; - account_type: string; - swift_bic_code: string; - ach: { - routing_number: string; - account_number: string; - }; - wire: { - routing_number: string; - account_number: string; - }; - rtp: { - routing_number: string; - account_number: string; - }; - beneficiary: { - name: string; - address_line_1: string; - address_line_2: string; - }; - receiving_bank: { - name: string; - address_line_1: string; - address_line_2: string; - }; - }; -}; - -export type ExportPayinsInput = Pick & { - status: TransactionStatus; -}; - -export type ExportPayinsResponse = Payin[]; +export type GetPayinTrackResponse = Payin; export type CreateEvmPayinInput = string; @@ -183,10 +120,14 @@ export type CreateEvmPayinResponse = Pick< | "tracking_payment" | "tracking_transaction" | "tracking_partner_fee" - | "blindpay_bank_details" - | "receiver_id" - | "receiver_amount" ->; +> & { + blindpay_bank_details: BlindpayBankDetails; + receiver_id?: string | null; + receiver_amount?: number | null; + payment_method?: PayinPaymentMethod | null; + billing_fee?: number | null; + sender_amount?: number | null; +}; export function createPayinsResource(instanceId: string, client: InternalApiClient) { return { @@ -200,12 +141,6 @@ export function createPayinsResource(instanceId: string, client: InternalApiClie getTrack(payinId: GetPayinTrackInput): Promise> { return client.get(`/e/payins/${payinId}`); }, - export({ - ...params - }: ExportPayinsInput): Promise> { - const queryParams = params ? `?${new URLSearchParams(params)}` : ""; - return client.get(`/instances/${instanceId}/export/payins${queryParams}`); - }, createEvm( payin_quote_id: CreateEvmPayinInput ): Promise> { diff --git a/src/resources/payins/payins-quotes.test.ts b/src/resources/payins/payins-quotes.test.ts index 892b910..3bd4324 100644 --- a/src/resources/payins/payins-quotes.test.ts +++ b/src/resources/payins/payins-quotes.test.ts @@ -1,11 +1,6 @@ import { afterEach, describe, expect, it } from "vitest"; import { BlindPay } from "../../client"; -import type { - CreatePayinQuoteResponse, - GetPayinFxRateResponse, - GetPayinQuoteResponse, - ListPayinQuotesResponse, -} from "./quotes"; +import type { CreatePayinQuoteResponse, GetPayinFxRateResponse } from "./quotes"; describe("Payin quotes", () => { afterEach(() => fetchMock.resetMocks()); @@ -72,98 +67,4 @@ describe("Payin quotes", () => { expect(data).toEqual(mockedFxRate); }); }); - - describe("Get payin quote", () => { - it("should get a payin quote", async () => { - const mockedPayinQuote: GetPayinQuoteResponse = { - id: "qu_000000000000", - payment_method: "pix", - token: "USDC", - request_amount: 1000, - cover_fees: true, - currency_type: "sender", - expires_at: 1712958191, - currency: "BRL", - commercial_quotation: 495, - blindpay_quotation: 505, - receiver_amount: 1010, - sender_amount: 5240, - partner_fee_amount: 150, - flat_fee: 50, - total_fee_amount: 1.53, - payer_rules: { - pix_allowed_tax_ids: ["149.476.037-68"], - }, - blockchain_wallet_id: "bw_000000000000", - instance_id: "in_000000000000", - partner_fee_id: "pf_000000000000", - billing_fee: 100, - created_at: "2021-01-01T00:00:00Z", - updated_at: "2021-01-01T00:00:00Z", - }; - - fetchMock.mockResponseOnce(JSON.stringify(mockedPayinQuote), { - headers: { "Content-Type": "application/json" }, - }); - - const { data, error } = await blindpay.payins.quotes.get("qu_000000000000"); - - expect(error).toBeNull(); - expect(data).toEqual(mockedPayinQuote); - }); - }); - - describe("List payin quotes", () => { - it("should get a payin quote", async () => { - const mockedPayinQuote: ListPayinQuotesResponse = { - data: [ - { - id: "qu_000000000000", - payment_method: "pix", - token: "USDC", - request_amount: 1000, - cover_fees: true, - currency_type: "sender", - expires_at: 1712958191, - currency: "BRL", - commercial_quotation: 495, - blindpay_quotation: 505, - receiver_amount: 1010, - sender_amount: 5240, - partner_fee_amount: 150, - flat_fee: 50, - total_fee_amount: 1.53, - payer_rules: { - pix_allowed_tax_ids: ["149.476.037-68"], - }, - blockchain_wallet_id: "bw_000000000000", - instance_id: "in_000000000000", - partner_fee_id: "pf_000000000000", - billing_fee: 100, - created_at: "2021-01-01T00:00:00Z", - updated_at: "2021-01-01T00:00:00Z", - }, - ], - pagination: { - has_more: true, - next_page: "qu_123", - prev_page: "qu_123", - }, - }; - - fetchMock.mockResponseOnce(JSON.stringify(mockedPayinQuote), { - headers: { "Content-Type": "application/json" }, - }); - - const { data, error } = await blindpay.payins.quotes.list({ - blockchain_wallet_id: "bw_000000000000", - payment_method: "pix", - token: "USDC", - receiver_id: "re_000000000000", - }); - - expect(error).toBeNull(); - expect(data).toEqual(mockedPayinQuote); - }); - }); }); diff --git a/src/resources/payins/payins.test.ts b/src/resources/payins/payins.test.ts index 0b73c3e..846ab58 100644 --- a/src/resources/payins/payins.test.ts +++ b/src/resources/payins/payins.test.ts @@ -2,7 +2,6 @@ import { afterEach, describe, expect, it } from "vitest"; import { BlindPay } from "../../client"; import type { CreateEvmPayinResponse, - ExportPayinsResponse, GetPayinResponse, GetPayinTrackResponse, ListPayinsResponse, @@ -112,11 +111,6 @@ describe("Payins", () => { address_line_1: "8 The Green, #19364", address_line_2: "Dover, DE 19901", }, - receiving_bank: { - name: "Column NA - Brex", - address_line_1: "1 Letterman Drive, Building A, Suite A4-700", - address_line_2: "San Francisco, CA 94129", - }, }, }, ], @@ -235,11 +229,6 @@ describe("Payins", () => { address_line_1: "8 The Green, #19364", address_line_2: "Dover, DE 19901", }, - receiving_bank: { - name: "Column NA - Brex", - address_line_1: "1 Letterman Drive, Building A, Suite A4-700", - address_line_2: "San Francisco, CA 94129", - }, }, }; @@ -351,11 +340,6 @@ describe("Payins", () => { address_line_1: "8 The Green, #19364", address_line_2: "Dover, DE 19901", }, - receiving_bank: { - name: "Column NA - Brex", - address_line_1: "1 Letterman Drive, Building A, Suite A4-700", - address_line_2: "San Francisco, CA 94129", - }, }, }; @@ -370,126 +354,6 @@ describe("Payins", () => { }); }); - describe("Export payins", () => { - it("should export payins", async () => { - const mockedExportPayins: ExportPayinsResponse = [ - { - receiver_id: "re_000000000000", - id: "re_000000000000", - pix_code: - "00020101021226790014br.gov.bcb.pix2557brcode.starkinfra.com/v2/bcf07f6c4110454e9fd6f120bab13e835204000053039865802BR5915Blind Pay, Inc.6010Vila Velha62070503***6304BCAB", - memo_code: "8K45GHBNT6BQ6462", - clabe: "014027000000000008", - status: "processing", - payin_quote_id: "pq_000000000000", - instance_id: "in_000000000000", - tracking_transaction: { - step: "processing", - status: "failed", - external_id: "12345678", - completed_at: "2011-10-05T14:48:00.000Z", - sender_name: "John Doe Smith", - sender_tax_id: "123.456.789-10", - sender_bank_code: "00416968", - sender_account_number: "1234567890", - trace_number: "1234567890", - transaction_reference: "1234567890", - description: "Payment from John Doe Smith", - pse_instruction: { - payment_link: "https://pse.example.com/payment/abc123", - fid: "fid_abc123", - full_name: "Juan Pérez García", - tax_id: "1234567890", - document_type: "CC", - phone: "+573001234567", - email: "juan@example.com", - bank_code: "1007", - }, - transfers_instruction: { - account: "0000003100012389237485", - type: "CVU", - tax_id: "20123456783", - }, - }, - tracking_payment: { - step: "on_hold", - provider_name: "blockchain", - completed_at: "2011-10-05T14:48:00.000Z", - }, - tracking_complete: { - step: "on_hold", - transaction_hash: "0x123...890", - completed_at: "2011-10-05T14:48:00.000Z", - }, - tracking_partner_fee: { - step: "on_hold", - transaction_hash: "0x123...890", - completed_at: "2011-10-05T14:48:00.000Z", - }, - created_at: "2021-01-01T00:00:00Z", - updated_at: "2021-01-01T00:00:00Z", - image_url: "https://example.com/image.png", - first_name: "John", - last_name: "Doe", - legal_name: "Company Name Inc.", - type: "individual", - payment_method: "pix", - sender_amount: 5240, - receiver_amount: 1010, - token: "USDC", - partner_fee_amount: 150, - total_fee_amount: 1.53, - commercial_quotation: 495, - blindpay_quotation: 505, - currency: "BRL", - billing_fee: 100, - name: "Wallet Display Name", - address: "0xDD6a3aD0949396e57C7738ba8FC1A46A5a1C372C", - network: "polygon", - blindpay_bank_details: { - routing_number: "121145349", - account_number: "621327727210181", - account_type: "Business checking", - swift_bic_code: "CHASUS33", - ach: { - routing_number: "123456789", - account_number: "123456789", - }, - wire: { - routing_number: "123456789", - account_number: "123456789", - }, - rtp: { - routing_number: "123456789", - account_number: "123456789", - }, - beneficiary: { - name: "BlindPay, Inc.", - address_line_1: "8 The Green, #19364", - address_line_2: "Dover, DE 19901", - }, - receiving_bank: { - name: "Column NA - Brex", - address_line_1: "1 Letterman Drive, Building A, Suite A4-700", - address_line_2: "San Francisco, CA 94129", - }, - }, - }, - ]; - - fetchMock.mockResponseOnce(JSON.stringify(mockedExportPayins), { - headers: { "Content-Type": "application/json" }, - }); - - const { data, error } = await blindpay.payins.export({ - status: "processing", - }); - - expect(error).toBeNull(); - expect(data).toEqual(mockedExportPayins); - }); - }); - describe("Create EVM payin", () => { it("should create an EVM payin", async () => { const mockedEvmPayin: CreateEvmPayinResponse = { @@ -564,11 +428,6 @@ describe("Payins", () => { address_line_1: "8 The Green, #19364", address_line_2: "Dover, DE 19901", }, - receiving_bank: { - name: "Column NA - Brex", - address_line_1: "1 Letterman Drive, Building A, Suite A4-700", - address_line_2: "San Francisco, CA 94129", - }, }, receiver_id: "re_000000000000", receiver_amount: 1010, diff --git a/src/resources/payins/quotes.ts b/src/resources/payins/quotes.ts index 8549026..b463e04 100644 --- a/src/resources/payins/quotes.ts +++ b/src/resources/payins/quotes.ts @@ -2,25 +2,22 @@ import type { BlindpayApiResponse, Currency, CurrencyType, - PaginationMetadata, - PaginationParams, + PayerRules, + PayinPaymentMethod, StablecoinToken, } from "../../../types"; import type { InternalApiClient } from "../../internal/api-client"; -export type PayinPaymentMethod = "ach" | "wire" | "pix" | "spei"; - export type CreatePayinQuoteInput = { blockchain_wallet_id: string; currency_type: CurrencyType; payment_method: PayinPaymentMethod; request_amount: number; token: StablecoinToken; + is_otc?: boolean | null; cover_fees: boolean; partner_fee_id: string | null; - payer_rules: { - pix_allowed_tax_ids: string[]; - }; + payer_rules?: PayerRules | null; }; export type CreatePayinQuoteResponse = { @@ -30,8 +27,9 @@ export type CreatePayinQuoteResponse = { blindpay_quotation: number; receiver_amount: number; sender_amount: number; - partner_fee_amount: number | null; - flat_fee: number | null; + partner_fee_amount?: number | null; + flat_fee: number; + is_otc?: boolean | null; }; export type GetPayinFxRateInput = { @@ -49,72 +47,6 @@ export type GetPayinFxRateResponse = { instance_percentage_fee: number; }; -export type GetPayinQuoteInput = string; - -export type GetPayinQuoteResponse = { - id: string; - payment_method: PayinPaymentMethod; - token: StablecoinToken; - request_amount: number; - cover_fees: boolean; - currency_type: CurrencyType; - expires_at: number | null; - currency: Extract; - commercial_quotation: number | null; - blindpay_quotation: number | null; - receiver_amount: number; - sender_amount: number; - partner_fee_amount: number | null; - flat_fee: number | null; - total_fee_amount: number | null; - payer_rules: { - pix_allowed_tax_ids: string[]; - } | null; - blockchain_wallet_id: string; - instance_id: string; - partner_fee_id: string | null; - billing_fee: number | null; - created_at: string; - updated_at: string; -}; - -export type ListPayinQuotesInput = PaginationParams & { - receiver_id?: string; - blockchain_wallet_id?: string; - payment_method?: PayinPaymentMethod; - token?: StablecoinToken; -}; - -export type ListPayinQuotesResponse = { - data: Array<{ - id: string; - payment_method: PayinPaymentMethod; - token: StablecoinToken; - request_amount: number; - cover_fees: boolean; - currency_type: CurrencyType; - expires_at: number | null; - currency: Extract; - commercial_quotation: number | null; - blindpay_quotation: number | null; - receiver_amount: number; - sender_amount: number; - partner_fee_amount: number | null; - flat_fee: number | null; - total_fee_amount: number | null; - payer_rules: { - pix_allowed_tax_ids: string[]; - } | null; - blockchain_wallet_id: string; - instance_id: string; - partner_fee_id: string | null; - billing_fee: number | null; - created_at: string; - updated_at: string; - }>; - pagination: PaginationMetadata; -}; - export function createPayinQuotesResource(instanceId: string, client: InternalApiClient) { return { create({ @@ -127,13 +59,5 @@ export function createPayinQuotesResource(instanceId: string, client: InternalAp }: GetPayinFxRateInput): Promise> { return client.post(`/instances/${instanceId}/payin-quotes/fx`, data); }, - get(id: GetPayinQuoteInput): Promise> { - return client.get(`/instances/${instanceId}/payin-quotes/${id}`); - }, - list(params?: ListPayinQuotesInput): Promise> { - const queryParams = params ? `?${new URLSearchParams(params)}` : ""; - - return client.get(`/instances/${instanceId}/payin-quotes${queryParams}`); - }, }; } diff --git a/src/resources/payouts/index.ts b/src/resources/payouts/index.ts index 2432ca8..e187bf3 100644 --- a/src/resources/payouts/index.ts +++ b/src/resources/payouts/index.ts @@ -115,10 +115,6 @@ export type GetPayoutTrackInput = string; export type GetPayoutTrackResponse = Payout; -export type ExportPayoutsInput = Pick; - -export type ExportPayoutsResponse = Payout[]; - export type AuthorizeStellarTokenInput = { quote_id: string; sender_wallet_address: string; @@ -163,15 +159,6 @@ export type CreateEvmPayoutResponse = { receiver_id: string; }; -export type AuthorizeSolanaInput = { - quote_id: string; - sender_wallet_address: string; -}; - -export type AuthorizeSolanaResponse = { - serialized_transaction: string; -}; - export type CreateSolanaPayoutInput = { quote_id: string; sender_wallet_address: string; @@ -196,10 +183,6 @@ export function createPayoutsResource(instanceId: string, client: InternalApiCli const queryParams = params ? `?${new URLSearchParams(params)}` : ""; return client.get(`/instances/${instanceId}/payouts${queryParams}`); }, - export(params?: ExportPayoutsInput): Promise> { - const queryParams = params ? `?${new URLSearchParams(params)}` : ""; - return client.get(`/instances/${instanceId}/export/payouts${queryParams}`); - }, get(payoutId: GetPayoutInput): Promise> { return client.get(`/instances/${instanceId}/payouts/${payoutId}`); }, @@ -225,11 +208,6 @@ export function createPayoutsResource(instanceId: string, client: InternalApiCli }: CreateEvmPayoutInput): Promise> { return client.post(`/instances/${instanceId}/payouts/evm`, data); }, - authorizeSolana({ - ...data - }: AuthorizeSolanaInput): Promise> { - return client.post(`/instances/${instanceId}/payouts/solana/authorize`, data); - }, createSolana({ ...data }: CreateSolanaPayoutInput): Promise> { diff --git a/src/resources/payouts/payouts.test.ts b/src/resources/payouts/payouts.test.ts index 7a2799a..64f2645 100644 --- a/src/resources/payouts/payouts.test.ts +++ b/src/resources/payouts/payouts.test.ts @@ -1,12 +1,10 @@ import { afterEach, describe, expect, it } from "vitest"; import { BlindPay } from "../../client"; import type { - AuthorizeSolanaResponse, AuthorizeStellarTokenResponse, CreateEvmPayoutResponse, CreateSolanaPayoutResponse, CreateStellarPayoutResponse, - ExportPayoutsResponse, GetPayoutResponse, GetPayoutTrackResponse, ListPayoutsResponse, @@ -250,120 +248,6 @@ describe("Payouts", () => { }); }); - describe("Export payouts", () => { - it("should export payouts", async () => { - const mockedExportPayouts: ExportPayoutsResponse = [ - { - receiver_id: "re_000000000000", - id: "pa_000000000000", - status: "processing", - sender_wallet_address: "0x123...890", - signed_transaction: "AAA...Zey8y0A", - quote_id: "qu_000000000000", - instance_id: "in_000000000000", - tracking_transaction: { - step: "processing", - status: "failed", - transaction_hash: "0x123...890", - completed_at: "2011-10-05T14:48:00.000Z", - }, - tracking_payment: { - step: "on_hold", - provider_name: "blockchain", - provider_transaction_id: "0x123...890", - provider_status: "canceled", - recipient_name: "John Doe", - recipient_tax_id: "123.456.789-10", - recipient_bank_code: "00416968", - recipient_branch_code: "0001", - recipient_account_number: "1234567890", - recipient_account_type: "checking", - estimated_time_of_arrival: "5_min", - completed_at: "2011-10-05T14:48:00.000Z", - }, - tracking_liquidity: { - step: "processing", - provider_transaction_id: "0x123...890", - provider_status: "deposited", - estimated_time_of_arrival: "1_business_day", - completed_at: "2011-10-05T14:48:00.000Z", - }, - tracking_complete: { - step: "on_hold", - status: "tokens_refunded", - transaction_hash: "0x123...890", - completed_at: "2011-10-05T14:48:00.000Z", - }, - tracking_partner_fee: { - step: "on_hold", - transaction_hash: "0x123...890", - completed_at: "2011-10-05T14:48:00.000Z", - }, - created_at: "2021-01-01T00:00:00Z", - updated_at: "2021-01-01T00:00:00Z", - image_url: "https://example.com/image.png", - first_name: "John", - last_name: "Doe", - legal_name: "Company Name Inc.", - network: "sepolia", - token: "USDC", - description: "Memo code or description, only works with USD and BRL", - sender_amount: 1010, - receiver_amount: 5240, - partner_fee_amount: 150, - commercial_quotation: 495, - blindpay_quotation: 485, - total_fee_amount: 1.5, - receiver_local_amount: 1000, - currency: "BRL", - transaction_document_file: "https://example.com/image.png", - transaction_document_type: "invoice", - transaction_document_id: "1234567890", - name: "Bank Account Name", - type: "wire", - pix_key: "14947677768", - account_number: "1001001234", - routing_number: "012345678", - country: "US", - account_class: "individual", - address_line_1: "Address line 1", - address_line_2: "Address line 2", - city: "City", - state_province_region: "State/Province/Region", - postal_code: "Postal code", - account_type: "checking", - ach_cop_beneficiary_first_name: "Fernando", - ach_cop_bank_account: "12345678", - ach_cop_bank_code: "051", - ach_cop_beneficiary_last_name: "Guzman Alarcón", - ach_cop_document_id: "1661105408", - ach_cop_document_type: "CC", - ach_cop_email: "fernando.guzman@gmail.com", - beneficiary_name: "Individual full name or business name", - spei_clabe: "5482347403740546", - spei_protocol: "clabe", - spei_institution_code: "40002", - swift_beneficiary_country: "MX", - swift_code_bic: "123456789", - swift_account_holder_name: "John Doe", - swift_account_number_iban: "123456789", - transfers_account: "BM123123123123", - transfers_type: "CVU", - has_virtual_account: true, - }, - ]; - - fetchMock.mockResponseOnce(JSON.stringify(mockedExportPayouts), { - headers: { "Content-Type": "application/json" }, - }); - - const { data, error } = await blindpay.payouts.export(); - - expect(error).toBeNull(); - expect(data).toEqual(mockedExportPayouts); - }); - }); - describe("Get payout track", () => { it("should get payout tracking information", async () => { const mockedPayoutTrack: GetPayoutTrackResponse = { @@ -618,26 +502,6 @@ describe("Payouts", () => { }); }); - describe("Authorize solana", () => { - it("should authorize solana transaction", async () => { - const mockedAuthorizeSolana: AuthorizeSolanaResponse = { - serialized_transaction: "AAA...Zey8y0A", - }; - - fetchMock.mockResponseOnce(JSON.stringify(mockedAuthorizeSolana), { - headers: { "Content-Type": "application/json" }, - }); - - const { data, error } = await blindpay.payouts.authorizeSolana({ - quote_id: "qu_000000000000", - sender_wallet_address: "0x123...890", - }); - - expect(error).toBeNull(); - expect(data).toEqual(mockedAuthorizeSolana); - }); - }); - describe("Create solana payout", () => { it("should create a solana payout", async () => { const mockedSolanaPayout: CreateSolanaPayoutResponse = { diff --git a/src/resources/quotes/index.ts b/src/resources/quotes/index.ts index 4b58917..3ebf257 100644 --- a/src/resources/quotes/index.ts +++ b/src/resources/quotes/index.ts @@ -11,15 +11,15 @@ import type { InternalApiClient } from "../../internal/api-client"; export type CreateQuoteInput = { bank_account_id: string; currency_type: CurrencyType; - network?: Network | null; + cover_fees: boolean; request_amount: number; + network: Network; token?: StablecoinToken | null; - cover_fees: boolean | null; description?: string | null; - partner_fee_id: string | null; + partner_fee_id?: string | null; transaction_document_file: string | null; - transaction_document_id: string | null; - transaction_document_type: TransactionDocumentType; + transaction_document_id?: string | null; + transaction_document_type?: TransactionDocumentType | null; }; export type CreateQuoteResponse = { id: string; @@ -28,27 +28,27 @@ export type CreateQuoteResponse = { blindpay_quotation: number; receiver_amount: number; sender_amount: number; - partner_fee_amount: number; - flat_fee: number; - contract: { + partner_fee_amount?: number | null; + flat_fee?: number | null; + contract?: { abi: Record[]; address: string; - functionName: string; + functionName: "approve"; blindpayContractAddress: string; amount: string; network: { name: string; chainId: number; }; - }; - receiver_local_amount: number; - description: string; + } | null; + receiver_local_amount?: number | null; + description?: string | null; }; export type GetFxRateInput = { currency_type: CurrencyType; - from: Currency; - to: Currency; + from: StablecoinToken; + to: Extract; request_amount: number; }; @@ -56,7 +56,7 @@ export type GetFxRateResponse = { commercial_quotation: number; blindpay_quotation: number; result_amount: number; - instance_flat_fee: number; + instance_flat_fee?: number | null; instance_percentage_fee: number; }; diff --git a/src/resources/quotes/quotes.test.ts b/src/resources/quotes/quotes.test.ts index e4ddd0a..8d69ad6 100644 --- a/src/resources/quotes/quotes.test.ts +++ b/src/resources/quotes/quotes.test.ts @@ -72,7 +72,7 @@ describe("Quotes", () => { const { data, error } = await blindpay.quotes.getFxRate({ currency_type: "sender", - from: "USD", + from: "USDC", to: "BRL", request_amount: 1000, }); diff --git a/types/index.d.ts b/types/index.d.ts index c49d276..ef968cd 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -16,7 +16,7 @@ export type BlindpaySuccessResponse = { export type CurrencyType = "sender" | "receiver"; -export type Network = "base" | "sepolia" | "arbitrum_sepolia" | "base_sepolia" | "arbitrum" | "polygon" | "polygon_amoy" | "ethereum" | "stellar" | "stellar_testnet" | "tron" +export type Network = "base" | "sepolia" | "arbitrum_sepolia" | "base_sepolia" | "arbitrum" | "polygon" | "polygon_amoy" | "ethereum" | "stellar" | "stellar_testnet" | "tron" | "solana" | "solana_devnet"; export type StablecoinToken = "USDC" | "USDT" | "USDB" @@ -302,17 +302,17 @@ export type AchCopDocument = "CC" | "CE" | "NIT" | "PASS" | "PEP"; export type PayinTrackingTransaction = { step: TrackingStatus - status: 'failed' | 'completed' | null; + status?: 'failed' | 'completed' | null; external_id: string | null; - completed_at: string | null; - sender_name: string | null; - sender_tax_id: string | null; - sender_bank_code: string | null; - sender_account_number: string | null; - trace_number: string | null; - transaction_reference: string | null; - description: string | null; - pse_instruction: { + completed_at?: string | null; + sender_name?: string | null; + sender_tax_id?: string | null; + sender_bank_code?: string | null; + sender_account_number?: string | null; + trace_number?: string | null; + transaction_reference?: string | null; + description?: string | null; + pse_instruction?: { payment_link: string; fid: string; full_name: string; @@ -320,33 +320,47 @@ export type PayinTrackingTransaction = { document_type: Extract; phone: string; email: string; - bank_code: string | null; + bank_code?: string | null; } | null - transfers_instruction: { + transfers_instruction?: { account: string; type: ArgentinaTransfers; - tax_id: string | null; + tax_id?: string | null; } | null }; - export type PayinTrackingPayment = { +export type PayinTrackingPayment = { step: TrackingStatus provider_name?: string | null completed_at?: string | null }; - export type PayinTrackingComplete = { +export type PayinTrackingComplete = { step: TrackingStatus - transaction_hash: string | null; - completed_at: string | null; + transaction_hash?: string | null; + completed_at?: string | null; }; - export type PayinTrackingPartnerFee = { +export type PayinTrackingPartnerFee = { step: TrackingStatus transaction_hash?: string | null completed_at?: string | null } +export type PayinPaymentMethod = "ach" | "wire" | "pix" | "spei" | "transfers" | "pse" + +export type PayerRules = { + pix_allowed_tax_ids?: string[] | null; + transfers_allowed_tax_id?: string | null; + pse_allowed_tax_ids?: string[] | null; + pse_full_name?: string | null; + pse_document_type?: Extract | null; + pse_document_number?: string | null; + pse_email?: string | null; + pse_phone?: string | null; + pse_bank_code?: string | null; +} + export type TrackingStatus = 'processing' | 'on_hold' | 'completed'; export type EstimatedTimeOfArrival = '5_min' | '30_min' | '2_hours' | '1_business_day' | '2_business_days' | '5_business_days'; @@ -358,7 +372,7 @@ export type PayoutTrackingTransaction = { completed_at: string | null }; - export type PayoutTrackingPayment = { +export type PayoutTrackingPayment = { step: TrackingStatus provider_name: string | null ; provider_transaction_id: string | null ; @@ -373,7 +387,7 @@ export type PayoutTrackingTransaction = { completed_at: string | null ; }; - export type PayoutTrackingLiquidity = { +export type PayoutTrackingLiquidity = { step: TrackingStatus provider_transaction_id: string | null ; provider_status: 'deposited' | 'converted' | 'withdrawn' | null; @@ -388,7 +402,7 @@ export type PayoutTrackingComplete = { completed_at: string | null; }; - export type PayoutTrackingPartnerFee = { +export type PayoutTrackingPartnerFee = { step: TrackingStatus transaction_hash: string | null; completed_at: string | null;