Loading...
;
if (!config) return
setAmount(e.target.value)}
placeholder="Amount in USD"
/>
{quotesLoading &&
Fetching quotes...
}
{quotes?.quotes.map(quote => (
{quote.gatewayName} {quote.isBestRate && '(Best Rate)'}
You receive: {quote.cryptoAmount} {quote.cryptoCurrency}
Rate: 1 {quote.cryptoCurrency} = {quote.exchangeRate} {quote.fiatCurrency}
Fees: {quote.fees.totalFee} {quote.fiatCurrency} ({quote.fees.feePercentage}%)
Time: {quote.estimatedTime}
KYC: {quote.kycRequired}
))}
{quotes?.unavailableGateways.map(gw => (
{gw.gatewayName}: {gw.reason}
))}
);
}
```
### Step 3: Create Checkout Intent
```tsx theme={null}
import { useCheckoutIntent, useTransaction } from '@nowramp/form';
function CheckoutFlow() {
const apiConfig = {
apiUrl: 'https://api.nowramp.com',
projectId: 'your_project_id'
};
const { order, loading, createOrder } = useCheckoutIntent(apiConfig);
const handleSelectQuote = async (quote) => {
const intent = await createOrder({
gateway: quote.gatewayId,
fiatCurrency: quote.fiatCurrency,
fiatAmount: quote.fiatAmount,
cryptoCurrency: quote.cryptoCurrency,
network: quote.network,
walletAddress: '0x742d35Cc6634C0532925a3b844Bc9e7595f1bD21',
externalCustomerId: 'user_123',
});
// Handle checkout based on method
if (intent.checkout.method === 'iframe') {
// Show iframe in your UI
setIframeUrl(intent.checkout.url);
} else if (intent.checkout.method === 'redirect') {
window.location.href = intent.checkout.url;
}
};
return (
Loading order status...
;
switch (status.status) {
case 'pending':
return Waiting for payment...
;
case 'processing':
return Processing your order...
;
case 'completed':
return (
Purchase complete!
Received: {status.cryptoAmount} {status.cryptoCurrency}
{status.transactionHash &&
TX: {status.transactionHash}
}
);
case 'failed':
return Order failed. Please try again.
;
default:
return