feat(transak): pre-fill fiat amount and currency in widget
Pass fiatAmount, defaultFiatAmount, fiatCurrency, and defaultFiatCurrency to the Transak widget URL so users see the transaction total immediately without manual entry. Applied to both rcart payment sessions and rflows onramp adapter. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
1abb29d18f
commit
ba5ce34620
|
|
@ -1370,7 +1370,7 @@ routes.post("/api/payments/:id/transak-session", async (c) => {
|
|||
|
||||
const host = new URL(c.req.url).hostname;
|
||||
|
||||
const widgetUrl = createTransakWidgetUrl({
|
||||
const widgetParams: Record<string, string> = {
|
||||
apiKey: transakApiKey,
|
||||
referrerDomain: extractRootDomain(host),
|
||||
cryptoCurrencyCode: p.token,
|
||||
|
|
@ -1383,7 +1383,19 @@ routes.post("/api/payments/:id/transak-session", async (c) => {
|
|||
email,
|
||||
themeColor: '6366f1',
|
||||
hideMenu: 'true',
|
||||
});
|
||||
};
|
||||
|
||||
// Pre-fill fiat amount/currency so user sees the total immediately
|
||||
if (p.fiatAmount) {
|
||||
widgetParams.fiatAmount = p.fiatAmount;
|
||||
widgetParams.defaultFiatAmount = p.fiatAmount;
|
||||
}
|
||||
if (p.fiatCurrency) {
|
||||
widgetParams.fiatCurrency = p.fiatCurrency;
|
||||
widgetParams.defaultFiatCurrency = p.fiatCurrency;
|
||||
}
|
||||
|
||||
const widgetUrl = createTransakWidgetUrl(widgetParams);
|
||||
|
||||
return c.json({ widgetUrl });
|
||||
});
|
||||
|
|
|
|||
|
|
@ -30,6 +30,14 @@ export class TransakOnrampAdapter implements OnrampProvider {
|
|||
themeColor: '6366f1',
|
||||
hideMenu: 'true',
|
||||
};
|
||||
if (req.fiatAmount > 0) {
|
||||
widgetParams.fiatAmount = String(req.fiatAmount);
|
||||
widgetParams.defaultFiatAmount = String(req.fiatAmount);
|
||||
}
|
||||
if (req.fiatCurrency) {
|
||||
widgetParams.fiatCurrency = req.fiatCurrency;
|
||||
widgetParams.defaultFiatCurrency = req.fiatCurrency;
|
||||
}
|
||||
if (req.returnUrl) widgetParams.redirectURL = req.returnUrl;
|
||||
|
||||
const widgetUrl = createTransakWidgetUrl(widgetParams);
|
||||
|
|
|
|||
Loading…
Reference in New Issue