feat: YuKassa checkout button on /plans + API route
/plans: кнопка Подключить → fetch /api/billing/checkout → redirect to ЮKassa app/api/billing/checkout/route.js — прокси к engine
This commit is contained in:
+11
-1
@@ -96,7 +96,17 @@ export default function PlansPage() {
|
||||
<Link href="/register" className={`w-full text-center py-2 rounded-lg text-sm ${style.btnClass}`}>Начать бесплатно</Link>
|
||||
) : (
|
||||
<button className={`w-full text-center py-2 text-sm ${style.btnClass}`}
|
||||
onClick={() => alert('ЮKassa — скоро')}>
|
||||
onClick={async () => {
|
||||
try {
|
||||
const res = await fetch('/api/billing/checkout', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ plan_code: plan.code }),
|
||||
}).then(r => r.json());
|
||||
if (res.confirmationUrl) window.location.href = res.confirmationUrl;
|
||||
else alert(res.error || 'Ошибка создания платежа');
|
||||
} catch { alert('Ошибка соединения'); }
|
||||
}}>
|
||||
Подключить
|
||||
</button>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user