chore: add crypto payment
This commit is contained in:
+35
-1
@@ -292,6 +292,8 @@ export const checkoutCart = async (
|
||||
prenom?: string,
|
||||
telephone?: string,
|
||||
use_referral_balance?: boolean,
|
||||
payment_method?: string,
|
||||
pay_currency?: string,
|
||||
): Promise<CheckoutCartResponse> => {
|
||||
const jwtUsername = await getJwtUsername();
|
||||
if (!jwtUsername) return { success: false, message: "Session invalide" };
|
||||
@@ -309,6 +311,8 @@ export const checkoutCart = async (
|
||||
if (nom) payload.nom = nom;
|
||||
if (prenom) payload.prenom = prenom;
|
||||
if (telephone) payload.telephone = telephone;
|
||||
if (payment_method) payload.payment_method = payment_method;
|
||||
if (pay_currency) payload.pay_currency = pay_currency;
|
||||
const { data } = await apiClient.post(`${V1}/checkout`, payload);
|
||||
return {
|
||||
success: true,
|
||||
@@ -320,6 +324,13 @@ export const checkoutCart = async (
|
||||
queue_info: data.queue_info,
|
||||
referral_used: data.referral_used,
|
||||
referral_balance: data.referral_balance,
|
||||
payment_method: data.payment_method,
|
||||
payment_status: data.payment_status,
|
||||
pay_address: data.pay_address,
|
||||
pay_amount: data.pay_amount,
|
||||
pay_currency: data.pay_currency,
|
||||
price_amount: data.price_amount,
|
||||
price_currency: data.price_currency,
|
||||
};
|
||||
} catch (error: any) {
|
||||
const errMsg: string = error.response?.data?.error || "Erreur serveur";
|
||||
@@ -756,10 +767,12 @@ export interface PublicSettings {
|
||||
points_separated: boolean;
|
||||
referral_enabled: boolean;
|
||||
pool_names: string[];
|
||||
crypto_payment_enabled: boolean;
|
||||
nowpayments_currencies: string[];
|
||||
}
|
||||
|
||||
export const getPublicSettings = async (): Promise<PublicSettings> => {
|
||||
const defaults: PublicSettings = { penalties_enabled: true, show_amende_score: true, points_enabled: true, points_separated: true, referral_enabled: true, pool_names: ['Pool 1', 'Pool 2'] };
|
||||
const defaults: PublicSettings = { penalties_enabled: true, show_amende_score: true, points_enabled: true, points_separated: true, referral_enabled: true, pool_names: ['Pool 1', 'Pool 2'], crypto_payment_enabled: false, nowpayments_currencies: [] };
|
||||
try {
|
||||
const { data } = await apiClient.get(`${V1}/app-settings`);
|
||||
return {
|
||||
@@ -771,12 +784,33 @@ export const getPublicSettings = async (): Promise<PublicSettings> => {
|
||||
pool_names: Array.isArray(data.pool_names) && data.pool_names.length > 0
|
||||
? data.pool_names
|
||||
: defaults.pool_names,
|
||||
crypto_payment_enabled: data.crypto_payment_enabled ?? false,
|
||||
nowpayments_currencies: Array.isArray(data.nowpayments_currencies) ? data.nowpayments_currencies : [],
|
||||
};
|
||||
} catch {
|
||||
return defaults;
|
||||
}
|
||||
};
|
||||
|
||||
export interface CryptoPaymentStatus {
|
||||
command_id: number;
|
||||
payment_status: string;
|
||||
pay_address: string;
|
||||
pay_amount: number;
|
||||
pay_currency: string;
|
||||
price_amount: number;
|
||||
price_currency: string;
|
||||
}
|
||||
|
||||
export const getCryptoPaymentStatus = async (commandId: number): Promise<CryptoPaymentStatus | null> => {
|
||||
try {
|
||||
const { data } = await apiClient.get(`${V1}/commands/${commandId}/payment-status`);
|
||||
return data;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export const registerPushToken = async (token: string): Promise<void> => {
|
||||
try {
|
||||
await apiClient.post(`${V1}/push-token`, { token });
|
||||
|
||||
@@ -764,6 +764,14 @@ export interface CheckoutCartResponse {
|
||||
};
|
||||
referral_used?: number;
|
||||
referral_balance?: number;
|
||||
// Crypto payment fields
|
||||
payment_method?: string;
|
||||
payment_status?: string;
|
||||
pay_address?: string;
|
||||
pay_amount?: number;
|
||||
pay_currency?: string;
|
||||
price_amount?: number;
|
||||
price_currency?: string;
|
||||
}
|
||||
|
||||
export interface ConfirmReceptionResponse {
|
||||
|
||||
Reference in New Issue
Block a user