Skip to content

feat(api-gateway): add fx-engine HTTP client for payment quotes#196

Open
DANTE-1903 wants to merge 1 commit into
Betta-Pay:mainfrom
DANTE-1903:feat/api-gateway-fx-client
Open

feat(api-gateway): add fx-engine HTTP client for payment quotes#196
DANTE-1903 wants to merge 1 commit into
Betta-Pay:mainfrom
DANTE-1903:feat/api-gateway-fx-client

Conversation

@DANTE-1903

Copy link
Copy Markdown

Summary

Closes #114

Implements an HTTP client within api-gateway to integrate seamlessly with fx-engine. Payment creation flows now support fetching automated currency conversion quotes when the optional convertTo parameter is supplied.

What Changed

  • Created services/api-gateway/src/clients/fx-client.ts implementing getQuote with a strict 5-second timeout, x-service-token authentication propagation, and structured metric/error logging.
  • Created services/api-gateway/src/clients/fx-client.test.ts providing 18 robust test variations covering happy paths, timeout scenarios, network drops, and fallback behaviors.
  • Modified prisma/schema.prisma to include core FX fields (convertTo, convertedAmount, fxRate, fxQuoteId, fxQuoteExpiresAt) directly on the Payment model.
  • Modified shared/validation/schemas.ts to cleanly validate the incoming optional convertTo payload attribute.
  • Modified services/api-gateway/src/index.ts to orchestrate client execution gracefully (ensuring payments proceed unhindered if the fx-engine undergoes an outage).

Checklist

  • Create an HTTP client in api-gateway that calls the fx-engine
  • On payment creation, optionally fetch a quote if convertTo parameter is provided
  • Pass the merchant's JWT or a service token for inter-service auth
  • Handle fx-engine unavailability gracefully (timeout, fallback)
  • Log inter-service call metrics
  • Ensure full typecheck (tsc --noEmit) and all tests pass cleanly

Security & Resilience Note

Inter-service calls explicitly enforce a strict 5-second fallback ceiling. If the downstream fx-engine is unavailable, timeouts or errors are caught safely, falling back gracefully to log metrics and allow local payment transactions to process normally without cascading failures.

Payment creation can now fetch FX quotes from the fx-engine when a convertTo currency is specified, enabling multi-currency payments.
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@DANTE-1903 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@therealjhay

Copy link
Copy Markdown
Contributor

Kindly resolve conflict

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.

Implement api-gateway → fx-engine HTTP client

2 participants