'use server' import { YooCheckout, ICreatePayment } from '@a2seven/yoo-checkout'; import { getSessionData } from '@/app/actions/session'; const checkout = new YooCheckout({ shopId: '1276731', secretKey: 'test_0Yns_0NHV5GJf6ypJ5HC4NSfnLO8SJkw-1PwrVWsDl4' }); const idempotenceKey = '02347fc4-a1f0-49db-807e-f0d67c2ed5a5'; export async function yooKasaCreatePayment(amount: number, tariff: string) { console.log(amount); console.log(tariff); /* return true; */ const userEmail = await getSessionData('email'); const createPayload: ICreatePayment = { amount: { value: amount.toLocaleString(), currency: 'RUB' }, payment_method_data: { type: 'bank_card' }, confirmation: { type: 'redirect', return_url: 'test' }, metadata: { userId: userEmail, tariff: tariff } }; try { const payment = await checkout.createPayment(createPayload, Date.now().toLocaleString()); console.log(payment); return payment?.confirmation.confirmation_url; /* return payment; */ } catch (error) { console.error(error); } }