import { Yuno } from '@yuno-payments/sdk-web';
// Initialize SDK
const yuno = await Yuno.initialize('your-public-api-key');
// Create checkout session on your backend
// Your backend calls: POST https://api-sandbox.y.uno/v1/checkout/sessions
const session = await fetch('/api/create-session', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
customer_id: 'customer-123',
amount: { currency: 'USD', value: 1000 },
country: 'US'
})
}).then(r => r.json());
// Configure checkout
yuno.startCheckout({
checkoutSession: session.checkout_session,
elementSelector: '#payment-form',
countryCode: 'US',
async yunoCreatePayment(oneTimeToken) {
// Your backend calls: POST https://api-sandbox.y.uno/v1/payments
// with { payment_method: { token: oneTimeToken }, checkout_session: ... }
const payment = await fetch('/api/process-payment', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
one_time_token: oneTimeToken,
checkout_session: session.checkout_session
})
}).then(r => r.json());
// Required for async payment methods (3DS, PIX, etc.)
yuno.continuePayment();
}
});
// Mount payment form
yuno.mountCheckout();