add payments history tanstak-table

This commit is contained in:
smanylov
2026-02-21 15:07:37 +07:00
parent 4f7b464bed
commit c88646b64c
8 changed files with 616 additions and 29 deletions
+39 -1
View File
@@ -1,7 +1,7 @@
'use server'
import { YooCheckout, ICreatePayment } from '@a2seven/yoo-checkout';
import { getSessionData } from '@/app/actions/session';
import { getSessionData, deleteSession } from '@/app/actions/session';
import { API_BASE_URL } from '@/app/actions/definitions';
const checkout = new YooCheckout({ shopId: '1276731', secretKey: 'test_0Yns_0NHV5GJf6ypJ5HC4NSfnLO8SJkw-1PwrVWsDl4' });
@@ -77,3 +77,41 @@ export async function yooKasaCreatePayment(amount: number, tariff: number, opera
return null
}
}
export async function fetchPaymentsHistory() {
const email = await getSessionData('email');
try {
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
method: 'POST',
body: JSON.stringify({
version: 1,
msg_id: 30005,
message_body: {
action: 'user_payments',
email: email
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
});
if (response.ok) {
const parsed = await response.json();
if (parsed.message_code === 0) {
return {
payments: parsed.message_body.payments,
error: null
};
} else {
throw parsed.message_code;
}
} else {
return null
}
} catch (error) {
return null
}
}