From c7c78e303cc79049e0fec5ab47ee1e97e76ff5b7 Mon Sep 17 00:00:00 2001 From: smanylov Date: Thu, 19 Feb 2026 17:45:40 +0700 Subject: [PATCH] add tarif operation --- src/app/actions/yooKassa.ts | 11 ++++++----- src/app/ui/payment/payment-tab-buy-tokens.tsx | 2 +- src/app/ui/payment/payment-tab-tariffs.tsx | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/app/actions/yooKassa.ts b/src/app/actions/yooKassa.ts index a6a00de..8c0cc68 100644 --- a/src/app/actions/yooKassa.ts +++ b/src/app/actions/yooKassa.ts @@ -6,12 +6,12 @@ import { API_BASE_URL } from '@/app/actions/definitions'; const checkout = new YooCheckout({ shopId: '1276731', secretKey: 'test_0Yns_0NHV5GJf6ypJ5HC4NSfnLO8SJkw-1PwrVWsDl4' }); -export async function makePaymentOperation(email: string, tariffId: number, operationUuid: string) { +export async function makePaymentOperation(email: string, tariffId: number, operationUuid: string, operationType: 'TARIFF' | 'TOKEN') { const formData = new FormData(); formData.append('email', email); formData.append('tariffId', tariffId.toString()); - formData.append('operationType', 'TARIFF'); + formData.append('operationType', operationType); formData.append('operationUuid', operationUuid); try { @@ -35,7 +35,7 @@ export async function makePaymentOperation(email: string, tariffId: number, oper } } -export async function yooKasaCreatePayment(amount: number, tariff: number) { +export async function yooKasaCreatePayment(amount: number, tariff: number, operationType: 'TARIFF' | 'TOKEN') { const userEmail = await getSessionData('email'); const timestamp = Date.now(); @@ -61,12 +61,13 @@ export async function yooKasaCreatePayment(amount: number, tariff: number) { metadata: { userMail: userEmail, tariff: tariff - } + }, + capture: true }; try { const payment = await checkout.createPayment(createPayload, idempotenceKey); - const response = await makePaymentOperation(userEmail, tariff, payment.id); + const response = await makePaymentOperation(userEmail, tariff, payment.id, operationType); if (response && payment) { return payment?.confirmation.confirmation_url; } else { diff --git a/src/app/ui/payment/payment-tab-buy-tokens.tsx b/src/app/ui/payment/payment-tab-buy-tokens.tsx index 2e64eee..4b2feaa 100644 --- a/src/app/ui/payment/payment-tab-buy-tokens.tsx +++ b/src/app/ui/payment/payment-tab-buy-tokens.tsx @@ -56,7 +56,7 @@ export default function PaymentTubBuyTokens() { setIsProcessing(true); try { - const response = await yooKasaCreatePayment(value, tokensBundle); + const response = await yooKasaCreatePayment(value, tokensBundle, 'TOKEN'); if (response) { window.open(response, '_blank', 'noopener,noreferrer'); closeModal(false); diff --git a/src/app/ui/payment/payment-tab-tariffs.tsx b/src/app/ui/payment/payment-tab-tariffs.tsx index 9570d37..b914972 100644 --- a/src/app/ui/payment/payment-tab-tariffs.tsx +++ b/src/app/ui/payment/payment-tab-tariffs.tsx @@ -56,7 +56,7 @@ export default function PaymentTabTariffs() { setIsProcessing(true); try { - const response = await yooKasaCreatePayment(value, tariff); + const response = await yooKasaCreatePayment(value, tariff, 'TARIFF'); if (response) { window.open(response, '_blank', 'noopener,noreferrer'); closeModal(false);