Skip to content

[READY] /supported-payment-methods & /supported-cryptocurrencies#696

Merged
ebma merged 15 commits into
stagingfrom
679-build-an-endpoint-to-fetch-payment-methods-supported-by-vortex
Jun 6, 2025
Merged

[READY] /supported-payment-methods & /supported-cryptocurrencies#696
ebma merged 15 commits into
stagingfrom
679-build-an-endpoint-to-fetch-payment-methods-supported-by-vortex

Conversation

@Sharqiewicz
Copy link
Copy Markdown
Member

@Sharqiewicz Sharqiewicz commented Jun 2, 2025

Add:

  • /supported-payment-methods with params: type={ sell (default) | buy }, fiat={ ars, brl, eur }

Example response:

{
    paymentMethods: [
      { id: 'sepa', name: 'SEPA', supportedFiats: ['eurc'], limits: { min: 10, max: 50000 } },
      { id: 'pix', name: 'PIX', supportedFiats: ['brl'], limits: { min: 1, max: 500000 } },
      { id: 'cbu', name: 'CBU', supportedFiats: ['ars'], limits: { min: 1, max: 500000 } },
    ],
};
  • supported-cryptocurrencies with params: network={ polygon(default), assethub... ...base }

Example response:

{
    cryptocurrencies: [
      {
        assetSymbol: 'USDC',
        assetContractAddress: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359',
        assetNetwork: 'polygon',
        assetDecimals: 6,
      },
      {
        assetSymbol: 'USDT',
        assetContractAddress: '0xc2132d05d31c914a87c6611c10748aeb04b58e8f',
        assetNetwork: 'polygon',
        assetDecimals: 6,
      },
      {
        assetSymbol: 'USDC.e',
        assetContractAddress: '0x2791bca1f2de4661ed88a30c99a7a9449aa84174',
        assetNetwork: 'polygon',
        assetDecimals: 6,
      },
    ],
  };

For the implementation I used the tokens already defined in the shared so we have only one-source-of-truth for the tokens config.

@Sharqiewicz Sharqiewicz linked an issue Jun 2, 2025 that may be closed by this pull request
@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 2, 2025

Deploy Preview for pendulum-pay canceled.

Name Link
🔨 Latest commit f69a990
🔍 Latest deploy log https://app.netlify.com/projects/pendulum-pay/deploys/6841d777787c7f0008dd08f4

Comment thread api/src/config/payment-methods.config.ts
@Sharqiewicz Sharqiewicz changed the title implement /supported-payment-methods api endpoint with type (buy/sell… /supported-payment-methods & /supported-cryptocurrencies Jun 3, 2025
@Sharqiewicz Sharqiewicz requested a review from Copilot June 3, 2025 14:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for fetching available fiat payment methods and on-chain cryptocurrencies via new endpoints, refactors network helper functions for case-insensitive lookup, and wires up corresponding API routes and configurations.

  • Refactor shared/helpers/networks.ts to centralize and normalize network metadata lookups.
  • Introduce supported-payment-methods and supported-cryptocurrencies endpoints (types, controllers, routes).
  • Add API configs for payment methods and cryptocurrencies and mount new routes in api.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
shared/src/tokens/utils/helpers.ts Removed unused imports
shared/src/helpers/networks.ts Refactored network lookup functions
shared/src/endpoints/supported-cryptocurrencies.endpoints.ts Defined types for supported cryptocurrencies
shared/src/endpoints/payment-methods.endpoints.ts Defined types for supported payment methods
shared/src/endpoints/index.ts Exported new endpoint modules
api/src/config/payment-methods.config.ts Configured fiat payment methods
api/src/config/cryptocurrencies.config.ts Configured on-chain cryptocurrency details
api/src/api/services/transactions/squidrouter/offramp.ts Removed unused gas fee variable
api/src/api/routes/v1/payment-methods.route.ts Added payment methods route
api/src/api/routes/v1/cryptocurrencies.route.ts Added cryptocurrencies route
api/src/api/routes/v1/index.ts Mounted new v1 routes
api/src/api/middlewares/validators.ts Reordered imports to include new endpoints
api/src/api/controllers/payment-methods.controller.ts Implemented payment methods controller
api/src/api/controllers/cryptocurrencies.controller.ts Implemented cryptocurrencies controller
Comments suppressed due to low confidence (3)

shared/src/helpers/networks.ts:109

  • Calling getNetworkMetadata and performing a find on each isNetworkEVM check adds unnecessary overhead. Consider using a direct lookup: NETWORK_METADATA[network].isEVM for O(1) access.
return getNetworkMetadata(network)?.isEVM ?? false;

shared/src/helpers/networks.ts:116

  • Changed return type to number | undefined may break callers that expect a guaranteed number. Either restore the original behavior (always return a valid number) or explicitly handle the undefined case where this function is used.
export function getNetworkId(network: Networks): number | undefined {

shared/src/helpers/networks.ts:120

  • This now returns string | undefined, which could introduce runtime undefined errors for callers that assume a string. Consider preserving the original contract (always returning a string) or updating callers to handle undefined.
export function getNetworkDisplayName(network: Networks): string | undefined {

Comment thread api/src/api/controllers/payment-methods.controller.ts
@Sharqiewicz Sharqiewicz requested a review from a team June 3, 2025 15:00
@Sharqiewicz Sharqiewicz changed the title /supported-payment-methods & /supported-cryptocurrencies [READY] /supported-payment-methods & /supported-cryptocurrencies Jun 4, 2025
Comment thread frontend/src/contexts/events.tsx Outdated
Copy link
Copy Markdown
Contributor

@gianfra-t gianfra-t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I wonder one thing, will we need an endpoint that returns all supported payments and cryptocurrencies without any sort selection param? For instance, returning results for all networks.

Copy link
Copy Markdown
Member

@ebma ebma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We either add handling I suggested in my comment or we go a different route.
Instead of returning nothing when the endpoint is called without a parameter (fiat and type for the payment method, or network for the cryptocurrencies) we could also return all available items.

If it's too much effort, let's stick to at least return a response that indicates the parameters that are required.

Comment on lines +39 to +40
const paymentMethodsByType = getPaymentMethodsByType(type);
const paymentMethodsByFiat = getPaymentMethodsByFiat(paymentMethodsByType, fiat);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If type is not provided, we should return an http status with an error that indicates that the type is missing and needs to be provided. Same goes for fiat.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ebma When the supported-payment-methods endpoint is called without any parameters, the default values are applied—specifically, type=sell - the endpoint returns all payment methods available for sell.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ebma When we call the supported-cryptocurrencies endpoint without any parameters, we apply the default value which is network=polygon and we return all the cryptocurrencies supported on polygon.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ebma Done ✅

@ebma ebma merged commit c94420b into staging Jun 6, 2025
4 of 5 checks passed
@ebma ebma deleted the 679-build-an-endpoint-to-fetch-payment-methods-supported-by-vortex branch June 6, 2025 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build an endpoint to fetch payment methods supported by Vortex

4 participants