Skip to content

feat(checkout): read sol_price_usd from payment object (closes #1 widget portion)#5

Open
relayhop wants to merge 2 commits into
Cypher-CP0:mainfrom
relayhop:feat/sol-price-from-payment
Open

feat(checkout): read sol_price_usd from payment object (closes #1 widget portion)#5
relayhop wants to merge 2 commits into
Cypher-CP0:mainfrom
relayhop:feat/sol-price-from-payment

Conversation

@relayhop

@relayhop relayhop commented May 3, 2026

Copy link
Copy Markdown

Closes Cypher-CP0/fluxpay#1 (widget portion). Pairs with Cypher-CP0/fluxpay#2 (backend portion).

Problem

The widget made a second HTTP call to GET /api/price/sol to learn the SOL/USD rate, even though the issue says: Read sol_price_usd from the payment object returned by the backend.

Change

  • src/types.ts: add optional sol_price_usd?: number to the Payment interface (optional preserves backward compatibility with backends that have not been upgraded yet).
  • src/CheckoutModal.tsx: prefer payment.sol_price_usd once the polled payment object provides it; fall back to a single /api/price/sol GET if the backend has not been upgraded.
  • Initial solPrice state is null instead of the hardcoded 165, so the widget waits for a real price before showing a SOL amount (renders 0 SOL for the brief instant before the first poll lands rather than a misleading number).

Result

  • One fewer HTTP roundtrip per checkout once the backend returns sol_price_usd.
  • The displayed SOL amount matches what the backend computed at payment-creation time (no oracle drift between the widget price call and the create call).
  • Older backends still work — the fallback path is preserved.

Tests

Manual:

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.

feat: replace hardcoded SOL price with live price feed from backend

1 participant