From 2c80b7095ed2c4f472084115e3588e2c0d6385bd Mon Sep 17 00:00:00 2001 From: alsaze Date: Fri, 3 Oct 2025 20:07:03 +0300 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D1=8E=20=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D0=B5=D0=B3=D1=83=20=D1=82=D0=BE=D0=B2=D0=B0=D1=80?= =?UTF-8?q?=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/endpoints/bspb/index.ts | 79 ---------------------------------- api/endpoints/index.ts | 1 + api/mutations/index.ts | 1 + api/mutations/wp/index.ts | 1 + api/queries/index.ts | 1 + composables/useProductsList.ts | 1 + pages/cart.vue | 11 +++-- server/api/bspb.ts | 5 +++ 8 files changed, 17 insertions(+), 83 deletions(-) delete mode 100644 api/endpoints/bspb/index.ts create mode 100644 api/endpoints/index.ts create mode 100644 api/mutations/index.ts create mode 100644 api/queries/index.ts create mode 100644 server/api/bspb.ts diff --git a/api/endpoints/bspb/index.ts b/api/endpoints/bspb/index.ts deleted file mode 100644 index ab5c8cd..0000000 --- a/api/endpoints/bspb/index.ts +++ /dev/null @@ -1,79 +0,0 @@ -const fs = require('node:fs') -const https = require('node:https') - -// URL, на который отправляется запрос -const url = 'https://pgtest.bspb.ru:5443/order' - -// Данные для отправки в формате JSON -const data = { - order: { - typeRid: 'Purchase', - amount: 100, - currency: 'RUB', - title: 'Название заказа', - description: 'Описание заказа', - }, -} - -const options = { - method: 'POST', - // Путь к ключу и сертификату - key: fs.readFileSync('./crt/bspb_test.key'), - cert: fs.readFileSync('./crt/bspb_test.pem'), - // Установка заголовков для отправки JSON и базовой авторизации - headers: { - 'Content-Type': 'application/json', - 'Authorization': `Basic ${Buffer.from('' + ':' + '').toString('base64')}`, - }, -} - -// Отправка запроса и обработка ответа -const req = https.request(url, options, (res) => { - let responseData = '' - - res.on('data', (chunk) => { - responseData += chunk - }) - - res.on('end', () => { - // Проверка кода ответа - if (res.statusCode === 200) { - try { - const parsedData = JSON.parse(responseData) - - // Проверка наличия объекта order в ответе - if (parsedData.order) { - const order = parsedData.order - - // Проверка наличия необходимых полей в объекте order - if (order.hppUrl && order.id && order.password) { - // Формирование итоговой ссылки - const finalUrl = `${order.hppUrl}?orderid=${order.id}&password=${order.password}` - - // Использование итоговой ссылки - console.log(`Итоговая ссылка: ${finalUrl}`) - } - else { - console.log('Объект order не содержит необходимых данных.') - } - } - else { - console.log('Ответ не содержит объекта order.') - } - } - catch (error) { - console.error('Ошибка:', error) - } - } - else { - console.error(`Ошибка ${res.statusCode} при запросе: ${responseData}`) - } - }) -}) - -req.on('error', (error) => { - console.error('Ошибка запроса:', error) -}) - -req.write(JSON.stringify(data)) -req.end() diff --git a/api/endpoints/index.ts b/api/endpoints/index.ts new file mode 100644 index 0000000..0d6303b --- /dev/null +++ b/api/endpoints/index.ts @@ -0,0 +1 @@ +export * from './wp/index' diff --git a/api/mutations/index.ts b/api/mutations/index.ts new file mode 100644 index 0000000..0d6303b --- /dev/null +++ b/api/mutations/index.ts @@ -0,0 +1 @@ +export * from './wp/index' diff --git a/api/mutations/wp/index.ts b/api/mutations/wp/index.ts index 2801c31..360189b 100644 --- a/api/mutations/wp/index.ts +++ b/api/mutations/wp/index.ts @@ -1 +1,2 @@ export * from './usePostOrdersCreate' +export * from '~/api/endpoints/bspb' diff --git a/api/queries/index.ts b/api/queries/index.ts new file mode 100644 index 0000000..0d6303b --- /dev/null +++ b/api/queries/index.ts @@ -0,0 +1 @@ +export * from './wp/index' diff --git a/composables/useProductsList.ts b/composables/useProductsList.ts index ac940b4..b0c2b80 100644 --- a/composables/useProductsList.ts +++ b/composables/useProductsList.ts @@ -1,4 +1,5 @@ import { useGetProductsList } from '~/api/queries/wp' +import { useProduct } from '~/composables' export const useProductsList = () => { const { getAttribute } = useProduct() diff --git a/pages/cart.vue b/pages/cart.vue index c4f182c..0a2346f 100644 --- a/pages/cart.vue +++ b/pages/cart.vue @@ -20,13 +20,16 @@ diff --git a/server/api/bspb.ts b/server/api/bspb.ts new file mode 100644 index 0000000..36960f7 --- /dev/null +++ b/server/api/bspb.ts @@ -0,0 +1,5 @@ +export default defineEventHandler((event) => { + return { + hello: 'world', + } +})