From 781275a5ccab519e1e8eddf35b26ca14888f3463 Mon Sep 17 00:00:00 2001 From: Darius Costolas <10818970+meltingice1337@users.noreply.github.com> Date: Wed, 3 Jun 2026 11:13:24 +0300 Subject: [PATCH 1/2] fix: map non-prefixed payment method IDs in Transak translation --- packages/ramps-controller/CHANGELOG.md | 4 ++++ .../src/TransakService.test.ts | 22 +++++++++++++++++++ .../ramps-controller/src/TransakService.ts | 17 +++++++++++--- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/packages/ramps-controller/CHANGELOG.md b/packages/ramps-controller/CHANGELOG.md index 8b2de93250..0f3979089c 100644 --- a/packages/ramps-controller/CHANGELOG.md +++ b/packages/ramps-controller/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Fix Transak Native deposits failing on staging/UAT with a 400 `paymentMethod is required parameter` error by mapping canonical payment method IDs supplied without the `/payments/` prefix (e.g. `apple-pay`) to their deposit-format equivalents, in addition to the prefixed forms (e.g. `/payments/apple-pay`) ([#8916](https://github.com/MetaMask/core/pull/8916)) + ## [14.1.0] ### Added diff --git a/packages/ramps-controller/src/TransakService.test.ts b/packages/ramps-controller/src/TransakService.test.ts index f265023075..922641a37c 100644 --- a/packages/ramps-controller/src/TransakService.test.ts +++ b/packages/ramps-controller/src/TransakService.test.ts @@ -1172,6 +1172,28 @@ describe('TransakService', () => { expect(await promise).toStrictEqual(MOCK_TRANSLATION); }); + it('normalizes canonical payment method IDs without the /payments/ prefix', async () => { + nock(STAGING_ORDERS_BASE) + .get(`${STAGING_PROVIDER_PATH}/native/translate`) + .query( + (query) => + query.paymentMethod === 'apple_pay' && + query.fiatCurrencyId === 'USD', + ) + .reply(200, MOCK_TRANSLATION); + + const { service } = getService(); + + const promise = service.getTranslation({ + fiatCurrencyId: 'USD', + paymentMethod: 'apple-pay', + }); + await jest.runAllTimersAsync(); + await flushPromises(); + + expect(await promise).toStrictEqual(MOCK_TRANSLATION); + }); + it('passes through payment methods already in deposit format', async () => { nock(STAGING_ORDERS_BASE) .get(`${STAGING_PROVIDER_PATH}/native/translate`) diff --git a/packages/ramps-controller/src/TransakService.ts b/packages/ramps-controller/src/TransakService.ts index 22f2b22c56..a88e5b6c70 100644 --- a/packages/ramps-controller/src/TransakService.ts +++ b/packages/ramps-controller/src/TransakService.ts @@ -354,8 +354,10 @@ export type TransakServiceMessenger = Messenger< * (e.g., "credit_debit_card"). * * The translation endpoint only understands the deposit-format IDs. - * If no mapping exists, the input is returned as-is (it may already be - * in the deposit format). + * Canonical IDs may arrive either with the "/payments/" prefix + * (e.g., "/payments/apple-pay") or without it (e.g., "apple-pay"), so both + * forms are accepted. If no mapping exists, the input is returned as-is (it + * may already be in the deposit format). */ const RAMPS_TO_DEPOSIT_PAYMENT_METHOD: Record = { '/payments/debit-credit-card': 'credit_debit_card', @@ -366,13 +368,22 @@ const RAMPS_TO_DEPOSIT_PAYMENT_METHOD: Record = { '/payments/gbp-bank-transfer': 'gbp_bank_transfer', }; +const PAYMENTS_PREFIX = '/payments/'; + function normalizePaymentMethodForTranslation( paymentMethod: string | undefined, ): string | undefined { if (!paymentMethod) { return undefined; } - return RAMPS_TO_DEPOSIT_PAYMENT_METHOD[paymentMethod] ?? paymentMethod; + const prefixed = paymentMethod.startsWith(PAYMENTS_PREFIX) + ? paymentMethod + : `${PAYMENTS_PREFIX}${paymentMethod}`; + return ( + RAMPS_TO_DEPOSIT_PAYMENT_METHOD[paymentMethod] ?? + RAMPS_TO_DEPOSIT_PAYMENT_METHOD[prefixed] ?? + paymentMethod + ); } function getTransakApiBaseUrl(environment: TransakEnvironment): string { From c4a1c57ef8473c5d6b2e27ef7e4e506b4f6662a5 Mon Sep 17 00:00:00 2001 From: Darius Costolas <10818970+meltingice1337@users.noreply.github.com> Date: Wed, 3 Jun 2026 11:16:56 +0300 Subject: [PATCH 2/2] fix: update changelog with correct pull request reference for Transak Native deposits fix --- packages/ramps-controller/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ramps-controller/CHANGELOG.md b/packages/ramps-controller/CHANGELOG.md index 0f3979089c..8dee973bcb 100644 --- a/packages/ramps-controller/CHANGELOG.md +++ b/packages/ramps-controller/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Fix Transak Native deposits failing on staging/UAT with a 400 `paymentMethod is required parameter` error by mapping canonical payment method IDs supplied without the `/payments/` prefix (e.g. `apple-pay`) to their deposit-format equivalents, in addition to the prefixed forms (e.g. `/payments/apple-pay`) ([#8916](https://github.com/MetaMask/core/pull/8916)) +- Fix Transak Native deposits failing on staging/UAT with a 400 `paymentMethod is required parameter` error by mapping canonical payment method IDs supplied without the `/payments/` prefix (e.g. `apple-pay`) to their deposit-format equivalents, in addition to the prefixed forms (e.g. `/payments/apple-pay`) ([#8980](https://github.com/MetaMask/core/pull/8980)) ## [14.1.0]