Start accepting crypto payments with automatic KolayMiles rewards. Simple integration, powerful results.
# Install dependencies
npm install ethers axios
# Copy config template
cp .env.example .env# BSC Testnet Configuration
FACILITATOR_ADDRESS=0x565a7Af88C3C00757a00098f3fcc6b8fB355c899
PAYMENTS_API_URL=http://localhost:8081
FACILITATOR_API_URL=http://localhost:8082
USDC_ADDRESS=0x64544969ed7EBf5f083679233325356EbE738930
# Your merchant wallet
MERCHANT_ADDRESS=YOUR_MERCHANT_WALLET_ADDRESSimport { ethers } from 'ethers';
export function PayWithKolayButton({ amount }: { amount: string }) {
const handlePay = async () => {
// 1. Connect wallet
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
const payer = await signer.getAddress();
// 2. Get payment data
const res = await fetch('http://localhost:8082/api/v1/prepare-payment', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
payer,
merchant: process.env.MERCHANT_ADDRESS,
asset: process.env.USDC_ADDRESS,
amount: ethers.parseUnits(amount, 18).toString()
})
});
const { payment, oracle } = await res.json();
// 3. Approve & Pay
const erc20 = new ethers.Contract(
process.env.USDC_ADDRESS,
['function approve(address,uint256) returns(bool)'],
signer
);
await erc20.approve(process.env.FACILITATOR_ADDRESS, payment.amount);
const facilitator = new ethers.Contract(
process.env.FACILITATOR_ADDRESS,
facilitatorABI,
signer
);
const tx = await facilitator.payWithKolay(
process.env.USDC_ADDRESS,
payment.amount,
process.env.MERCHANT_ADDRESS,
`ORDER-${Date.now()}`,
oracle.payload,
oracle.signature
);
alert(`Payment sent! TX: ${tx.hash}`);
};
return <button onClick={handlePay}>Pay {amount} USDC</button>;
}# Start local services
npm run dev
# In browser console:
payButton.click()Visit your merchant dashboard to track transactions and customer miles
Visit: http://localhost:3001/merchant
Transactions
Miles Earned
Conversion Stats
Perfect for various payment scenarios
We use cookies to improve your experience. Strictly necessary cookies are always on. Others require your consent.
See our Cookie Policy for details.