add tarif operation
This commit is contained in:
@@ -6,12 +6,12 @@ import { API_BASE_URL } from '@/app/actions/definitions';
|
||||
|
||||
const checkout = new YooCheckout({ shopId: '1276731', secretKey: 'test_0Yns_0NHV5GJf6ypJ5HC4NSfnLO8SJkw-1PwrVWsDl4' });
|
||||
|
||||
export async function makePaymentOperation(email: string, tariffId: number, operationUuid: string) {
|
||||
export async function makePaymentOperation(email: string, tariffId: number, operationUuid: string, operationType: 'TARIFF' | 'TOKEN') {
|
||||
const formData = new FormData();
|
||||
|
||||
formData.append('email', email);
|
||||
formData.append('tariffId', tariffId.toString());
|
||||
formData.append('operationType', 'TARIFF');
|
||||
formData.append('operationType', operationType);
|
||||
formData.append('operationUuid', operationUuid);
|
||||
|
||||
try {
|
||||
@@ -35,7 +35,7 @@ export async function makePaymentOperation(email: string, tariffId: number, oper
|
||||
}
|
||||
}
|
||||
|
||||
export async function yooKasaCreatePayment(amount: number, tariff: number) {
|
||||
export async function yooKasaCreatePayment(amount: number, tariff: number, operationType: 'TARIFF' | 'TOKEN') {
|
||||
|
||||
const userEmail = await getSessionData('email');
|
||||
const timestamp = Date.now();
|
||||
@@ -61,12 +61,13 @@ export async function yooKasaCreatePayment(amount: number, tariff: number) {
|
||||
metadata: {
|
||||
userMail: userEmail,
|
||||
tariff: tariff
|
||||
}
|
||||
},
|
||||
capture: true
|
||||
};
|
||||
|
||||
try {
|
||||
const payment = await checkout.createPayment(createPayload, idempotenceKey);
|
||||
const response = await makePaymentOperation(userEmail, tariff, payment.id);
|
||||
const response = await makePaymentOperation(userEmail, tariff, payment.id, operationType);
|
||||
if (response && payment) {
|
||||
return payment?.confirmation.confirmation_url;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user