const response = await fetch('https://pay.pingpay.io/api/checkout/sessions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
amount: '1000000', // 1 USDC (6 decimals: 1 * 10^6 = 1000000)
recipient: {
address: 'example-merchant.near',
},
asset: {
chain: 'NEAR',
symbol: 'USDC',
},
successUrl: 'https://yoursite.com/success',
cancelUrl: 'https://yoursite.com/cancel',
}),
});
const { sessionUrl, session } = await response.json();
// Redirect user to checkout page
window.location.href = sessionUrl;