From eb5f370e8bb6e10188d52acf67061dabf35311c7 Mon Sep 17 00:00:00 2001 From: anshitraj Date: Thu, 10 Sep 2026 04:05:23 +0530 Subject: [PATCH] fix: add EUR currency support --- .api-sync/unmodeled.json | 8 -------- .changeset/calm-euros-flow.md | 5 +++++ src/resources/payins/index.ts | 2 +- src/resources/payins/payins-quotes.test.ts | 22 ++++++++++++++++++++++ src/resources/payins/payins.test.ts | 7 +++++++ src/resources/payins/quotes.ts | 2 +- src/resources/quotes/index.ts | 2 +- src/resources/quotes/quotes.test.ts | 22 ++++++++++++++++++++++ types/index.d.ts | 4 ++-- 9 files changed, 61 insertions(+), 13 deletions(-) create mode 100644 .changeset/calm-euros-flow.md diff --git a/.api-sync/unmodeled.json b/.api-sync/unmodeled.json index 8e3b110..9212a86 100644 --- a/.api-sync/unmodeled.json +++ b/.api-sync/unmodeled.json @@ -803,14 +803,6 @@ "reason": "Already tracked in .api-sync/contract-check-allowlist.json (superseded by billing_fee_amount); mirrored here for the same reason as the partner-fee entries above.", "owner": "eric@blindpay.com" }, - { - "kind": "enum", - "schema": "PayinOut", - "enumProperty": "currency", - "reason": "Spec's fiat currency enum added EUR; this SDK's Currency union (which also carries the 3 crypto settlement tokens as a deliberate broader union) is missing it.", - "owner": "eric@blindpay.com", - "member": "EUR" - }, { "kind": "property", "schema": "PayinOut", diff --git a/.changeset/calm-euros-flow.md b/.changeset/calm-euros-flow.md new file mode 100644 index 0000000..b923f2d --- /dev/null +++ b/.changeset/calm-euros-flow.md @@ -0,0 +1,5 @@ +--- +"@blindpay/node": minor +--- + +Add EUR support to the shared currency type and payout and payin FX inputs. diff --git a/src/resources/payins/index.ts b/src/resources/payins/index.ts index 6ffe178..e064588 100644 --- a/src/resources/payins/index.ts +++ b/src/resources/payins/index.ts @@ -81,7 +81,7 @@ export type Payin = { total_fee_amount?: number | null; commercial_quotation: number; blindpay_quotation: number; - currency: Extract; + currency: Extract; billing_fee?: number | null; billing_fee_amount?: number | null; is_otc?: boolean | null; diff --git a/src/resources/payins/payins-quotes.test.ts b/src/resources/payins/payins-quotes.test.ts index cc56094..ea07442 100644 --- a/src/resources/payins/payins-quotes.test.ts +++ b/src/resources/payins/payins-quotes.test.ts @@ -66,5 +66,27 @@ describe("Payin quotes", () => { expect(error).toBeNull(); expect(data).toEqual(mockedFxRate); }); + + it("should request a EUR to USDC FX rate", async () => { + fetchMock.mockResponseOnce( + JSON.stringify({ + commercial_quotation: 1.18, + blindpay_quotation: 1.17, + result_amount: 1170, + instance_flat_fee: 50, + instance_percentage_fee: 0, + }), + { headers: { "Content-Type": "application/json" } } + ); + + const { error } = await blindpay.payins.quotes.getFxRate({ + currency_type: "sender", + from: "EUR", + to: "USDC", + request_amount: 1000, + }); + + expect(error).toBeNull(); + }); }); }); diff --git a/src/resources/payins/payins.test.ts b/src/resources/payins/payins.test.ts index 5f8690b..4436aa7 100644 --- a/src/resources/payins/payins.test.ts +++ b/src/resources/payins/payins.test.ts @@ -5,6 +5,7 @@ import type { GetPayinResponse, GetPayinTrackResponse, ListPayinsResponse, + Payin, } from "."; describe("Payins", () => { @@ -12,6 +13,12 @@ describe("Payins", () => { const blindpay = new BlindPay({ apiKey: "test-key", instanceId: "in_000000000000" }); + it("should type EUR payin responses", () => { + const currency: Payin["currency"] = "EUR"; + + expect(currency).toBe("EUR"); + }); + describe("List payins", () => { it("should list payins", async () => { const mockedPayins: ListPayinsResponse = { diff --git a/src/resources/payins/quotes.ts b/src/resources/payins/quotes.ts index 0696c09..e2a1242 100644 --- a/src/resources/payins/quotes.ts +++ b/src/resources/payins/quotes.ts @@ -35,7 +35,7 @@ export type CreatePayinQuoteResponse = { export type GetPayinFxRateInput = { currency_type: CurrencyType; - from: Extract; + from: Extract; to: Extract; request_amount: number; }; diff --git a/src/resources/quotes/index.ts b/src/resources/quotes/index.ts index 1f0ba2a..338f76a 100644 --- a/src/resources/quotes/index.ts +++ b/src/resources/quotes/index.ts @@ -45,7 +45,7 @@ export type CreateQuoteResponse = { export type GetFxRateInput = { currency_type: CurrencyType; from: StablecoinToken; - to: Extract; + to: Extract; request_amount: number; }; diff --git a/src/resources/quotes/quotes.test.ts b/src/resources/quotes/quotes.test.ts index 668c2d4..806e695 100644 --- a/src/resources/quotes/quotes.test.ts +++ b/src/resources/quotes/quotes.test.ts @@ -77,5 +77,27 @@ describe("Quotes", () => { expect(error).toBeNull(); expect(data).toEqual(mockedFxRate); }); + + it("should request a USDC to EUR FX rate", async () => { + fetchMock.mockResponseOnce( + JSON.stringify({ + commercial_quotation: 0.86, + blindpay_quotation: 0.85, + result_amount: 850, + instance_flat_fee: 50, + instance_percentage_fee: 0, + }), + { headers: { "Content-Type": "application/json" } } + ); + + const { error } = await blindpay.quotes.getFxRate({ + currency_type: "sender", + from: "USDC", + to: "EUR", + request_amount: 1000, + }); + + expect(error).toBeNull(); + }); }); }); diff --git a/types/index.d.ts b/types/index.d.ts index 5d32b53..f333909 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -24,7 +24,7 @@ export type TransactionDocumentType = "invoice" | "purchase_order" | "delivery_s export type BankAccountType = "checking" | "saving"; -export type Currency = "USDC" | "USDT" | "USDB" | "BRL" | "USD" | "MXN" | "COP" | "ARS"; +export type Currency = "USDC" | "USDT" | "USDB" | "BRL" | "USD" | "MXN" | "COP" | "ARS" | "EUR"; export type Rail = "wire" | "ach" | "pix" | "pix_safe" | "spei_bitso" | "transfers_bitso" | "ach_cop_bitso" | "international_swift" | "rtp" | "ted" | "sepa"; @@ -657,4 +657,4 @@ export type PayoutTrackingPartnerFee = { completed_at: string | null; } -export type KycStatus = "awaiting_contract" | "compliance_request" | "verifying" | "approved" | "rejected" | "deprecated" | "pending_review"; \ No newline at end of file +export type KycStatus = "awaiting_contract" | "compliance_request" | "verifying" | "approved" | "rejected" | "deprecated" | "pending_review";