complite yooMoneyWidged and payments
This commit is contained in:
@@ -37,8 +37,6 @@ export async function makePaymentOperation(email: string, tariffId: number, oper
|
||||
}
|
||||
|
||||
export async function yooKasaCreatePayment(amount: number, tariff: number, operationType: 'TARIFF' | 'TOKEN') {
|
||||
console.log('yooKasaCreatePayment');
|
||||
|
||||
const userEmail = await getSessionData('email');
|
||||
const timestamp = Date.now();
|
||||
const random = Math.random().toString(36).substring(2, 10);
|
||||
@@ -53,27 +51,22 @@ export async function yooKasaCreatePayment(amount: number, tariff: number, opera
|
||||
value: amount.toLocaleString().replace(/\s/g, ''),
|
||||
currency: 'RUB'
|
||||
},
|
||||
/* payment_method_data: {
|
||||
type: 'bank_card'
|
||||
}, */
|
||||
/* payment_method_id: "3138d708-000f-5001-9000-19865cfcca68", */
|
||||
confirmation: {
|
||||
type: 'embedded',
|
||||
/* type: 'redirect',
|
||||
return_url: 'test' */
|
||||
},
|
||||
metadata: {
|
||||
userMail: userEmail,
|
||||
tariff: tariff
|
||||
},
|
||||
merchant_customer_id: userEmail,
|
||||
capture: true
|
||||
capture: true,
|
||||
...(operationType === 'TOKEN' && {save_payment_method: false})
|
||||
};
|
||||
|
||||
try {
|
||||
const payment = await checkout.createPayment(createPayload, idempotenceKey);
|
||||
const response = await makePaymentOperation(userEmail, tariff, payment.id, operationType);
|
||||
console.log(payment);
|
||||
|
||||
if (payment && response) {
|
||||
return payment?.confirmation.confirmation_token;
|
||||
} else {
|
||||
@@ -82,18 +75,6 @@ export async function yooKasaCreatePayment(amount: number, tariff: number, opera
|
||||
} catch (error) {
|
||||
return null
|
||||
}
|
||||
|
||||
/* try {
|
||||
const payment = await checkout.createPayment(createPayload, idempotenceKey);
|
||||
const response = await makePaymentOperation(userEmail, tariff, payment.id, operationType);
|
||||
if (response && payment) {
|
||||
return payment?.confirmation.confirmation_url;
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
} catch (error) {
|
||||
return null
|
||||
} */
|
||||
}
|
||||
|
||||
export async function fetchPaymentsHistory() {
|
||||
|
||||
Reference in New Issue
Block a user