This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import https from 'node:https'
|
||||
import axios from 'axios'
|
||||
import { defineEventHandler } from 'h3'
|
||||
import { defineEventHandler, readBody } from 'h3'
|
||||
|
||||
export default defineEventHandler(async () => {
|
||||
export default defineEventHandler(async (event) => {
|
||||
const merchantId = process.env.BSPB_MERCHANT_ID!
|
||||
const merchantPassword = process.env.BSPB_MERCHANT_PASSWORD!
|
||||
const apiUrl = process.env.BSPB_API_URL!
|
||||
@@ -18,18 +18,9 @@ export default defineEventHandler(async () => {
|
||||
rejectUnauthorized: false,
|
||||
})
|
||||
|
||||
const data = {
|
||||
order: {
|
||||
typeRid: 'Purchase',
|
||||
amount: 100,
|
||||
currency: 'RUB',
|
||||
title: 'Название заказа',
|
||||
description: 'Описание заказа',
|
||||
hppRedirectUrl: 'http://localhost:3000/cart',
|
||||
},
|
||||
}
|
||||
const orderData = await readBody(event)
|
||||
|
||||
const response = await axios.post(`${apiUrl}/order`, data, {
|
||||
const response = await axios.post(`${apiUrl}/order`, orderData, {
|
||||
httpsAgent: agent,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
Reference in New Issue
Block a user