This commit is contained in:
smanylov
2026-03-06 14:46:42 +07:00
parent 5a6dcf33fa
commit 1a17683897
+11
View File
@@ -36,6 +36,8 @@ export async function makePaymentOperation(email: string, tariffId: number, oper
}
export async function yooKasaCreatePayment(amount: number, tariff: number, operationType: 'TARIFF' | 'TOKEN') {
console.log('yooKasaCreatePayment');
console.log(`amount => ${amount}`);
const userEmail = await getSessionData('email');
const timestamp = Date.now();
const random = Math.random().toString(36).substring(2, 10);
@@ -45,6 +47,10 @@ export async function yooKasaCreatePayment(amount: number, tariff: number, opera
return null;
}
console.log(`converted amount => ${amount.toLocaleString()}`);
console.log(`amount => ${amount.toLocaleString()}`);
console.log(`amount => ${amount.toLocaleString().replace(/[,\s.]/g, '')}`);
const createPayload: ICreatePayment = {
amount: {
value: amount.toLocaleString().replace(/[,\s.]/g, ''),
@@ -62,9 +68,14 @@ export async function yooKasaCreatePayment(amount: number, tariff: number, opera
...(operationType === 'TOKEN' && {save_payment_method: false})
};
console.log(createPayload);
try {
const payment = await checkout.createPayment(createPayload, idempotenceKey);
const response = await makePaymentOperation(userEmail, tariff, payment.id, operationType);
console.log(payment);
console.log('payment-------response');
console.log(response);
if (payment && response) {
return payment?.confirmation.confirmation_token;