import { makeRequest } from "@frontend/kitui"; import { SendPaymentRequest, SendPaymentResponse } from "@root/model/wallet"; import { parseAxiosError } from "@root/utils/parse-error"; const apiUrl = process.env.NODE_ENV === "production" ? "/customer" : "https://hub.pena.digital/customer"; const testPaymentBody: SendPaymentRequest = { type: "bankCard", amount: 15020, currency: "RUB", bankCard: { number: "RUB", expiryYear: "2021", expiryMonth: "05", csc: "05", cardholder: "IVAN IVANOV", }, phoneNumber: "79000000000", login: "login_test", returnUrl: window.location.origin + "/wallet", }; export async function sendPayment( body: SendPaymentRequest = testPaymentBody ): Promise<[SendPaymentResponse | null, string?]> { try { const sendPaymentResponse = await makeRequest< SendPaymentRequest, SendPaymentResponse >({ url: apiUrl + "/wallet", contentType: true, method: "POST", useToken: true, withCredentials: false, body, }); return [sendPaymentResponse]; } catch (nativeError) { const [error] = parseAxiosError(nativeError); return [null, `Ошибка оплаты. ${error}`]; } }