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' });
|
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();
|
const formData = new FormData();
|
||||||
|
|
||||||
formData.append('email', email);
|
formData.append('email', email);
|
||||||
formData.append('tariffId', tariffId.toString());
|
formData.append('tariffId', tariffId.toString());
|
||||||
formData.append('operationType', 'TARIFF');
|
formData.append('operationType', operationType);
|
||||||
formData.append('operationUuid', operationUuid);
|
formData.append('operationUuid', operationUuid);
|
||||||
|
|
||||||
try {
|
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 userEmail = await getSessionData('email');
|
||||||
const timestamp = Date.now();
|
const timestamp = Date.now();
|
||||||
@@ -61,12 +61,13 @@ export async function yooKasaCreatePayment(amount: number, tariff: number) {
|
|||||||
metadata: {
|
metadata: {
|
||||||
userMail: userEmail,
|
userMail: userEmail,
|
||||||
tariff: tariff
|
tariff: tariff
|
||||||
}
|
},
|
||||||
|
capture: true
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const payment = await checkout.createPayment(createPayload, idempotenceKey);
|
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) {
|
if (response && payment) {
|
||||||
return payment?.confirmation.confirmation_url;
|
return payment?.confirmation.confirmation_url;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export default function PaymentTubBuyTokens() {
|
|||||||
setIsProcessing(true);
|
setIsProcessing(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await yooKasaCreatePayment(value, tokensBundle);
|
const response = await yooKasaCreatePayment(value, tokensBundle, 'TOKEN');
|
||||||
if (response) {
|
if (response) {
|
||||||
window.open(response, '_blank', 'noopener,noreferrer');
|
window.open(response, '_blank', 'noopener,noreferrer');
|
||||||
closeModal(false);
|
closeModal(false);
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export default function PaymentTabTariffs() {
|
|||||||
setIsProcessing(true);
|
setIsProcessing(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await yooKasaCreatePayment(value, tariff);
|
const response = await yooKasaCreatePayment(value, tariff, 'TARIFF');
|
||||||
if (response) {
|
if (response) {
|
||||||
window.open(response, '_blank', 'noopener,noreferrer');
|
window.open(response, '_blank', 'noopener,noreferrer');
|
||||||
closeModal(false);
|
closeModal(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user