/
TryToNotTry
/
hosting-site
Обзор
Документация
Войти
/
TryToNotTry
/
hosting-site
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
static/js/payment.js
35 строк
1 KB
TryToNotTry
create: config.py, requirements.txt, run.py, api.py, forms.py, models.py, routes.py, __init__.py, style.css, payment.js, script.js, base.html, cabinet.html, index.html, login.html, order.html, payment.html, register.html, services.html
19 май 2026, 17:41
Верифицирован
19 май 2026, 17:41
0d82dce
Код
Авторство
О чём код?
// Пример для payment.html — интеграция с YooKassa Checkout API v4+ document.addEventListener('DOMContentLoaded', function () { const shopId = 'ВАШ_ID_МАГАЗИНА'; // из личного кабинета YooKassa! const apiKey = 'ВАШ_SECRET_KEY'; // Секретный ключ! const amountEl = document.getElementById('amount'); const orderIdEl = document.getElementById('order-id'); const yookassaCheckout = new window.YooMoneyCheckout({shopId}); document.getElementById('pay-button').onclick = function () { const amountValue = parseFloat(amountEl.value); if (isNaN(amountValue) || amountValue <= 0) { alert('Укажите корректную сумму!'); return; } yookassaCheckout.createPayment({ amount: { value: amountValue, currency: 'RUB' }, description: `Оплата заказа №${orderIdEl.value}`, capture: true, confirmation: { type: 'redirect', return_url: window.location.origin + '/payment/success' } }, apiKey).then(function (response) { window.location.href = response.confirmation.confirmation_url; }).catch(function (error) { console.error(error); alert('Ошибка при создании платежа.'); }); }; });