updates
This commit is contained in:
@@ -29,6 +29,9 @@ export interface Booking {
|
||||
check_out_date: string;
|
||||
guest_count: number;
|
||||
total_price: number;
|
||||
original_price?: number;
|
||||
discount_amount?: number;
|
||||
promotion_code?: string;
|
||||
status:
|
||||
| 'pending'
|
||||
| 'confirmed'
|
||||
@@ -70,6 +73,13 @@ export interface Booking {
|
||||
phone_number?: string;
|
||||
};
|
||||
payments?: Payment[];
|
||||
payment_balance?: {
|
||||
total_paid: number;
|
||||
total_price: number;
|
||||
remaining_balance: number;
|
||||
is_fully_paid: boolean;
|
||||
payment_percentage: number;
|
||||
};
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
@@ -365,6 +365,30 @@ export const capturePayPalPayment = async (
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Cancel PayPal payment (when user cancels on PayPal page)
|
||||
* POST /api/payments/paypal/cancel
|
||||
*/
|
||||
export const cancelPayPalPayment = async (
|
||||
bookingId: number
|
||||
): Promise<{
|
||||
success: boolean;
|
||||
message?: string;
|
||||
}> => {
|
||||
const response = await apiClient.post(
|
||||
'/payments/paypal/cancel',
|
||||
{
|
||||
booking_id: bookingId,
|
||||
}
|
||||
);
|
||||
// Map backend response format (status: "success") to frontend format (success: true)
|
||||
const data = response.data;
|
||||
return {
|
||||
success: data.status === "success" || data.success === true,
|
||||
message: data.message,
|
||||
};
|
||||
};
|
||||
|
||||
export default {
|
||||
createPayment,
|
||||
getPayments,
|
||||
@@ -378,4 +402,5 @@ export default {
|
||||
confirmStripePayment,
|
||||
createPayPalOrder,
|
||||
capturePayPalPayment,
|
||||
cancelPayPalPayment,
|
||||
};
|
||||
|
||||
@@ -107,6 +107,7 @@ export interface CompanySettingsResponse {
|
||||
company_phone: string;
|
||||
company_email: string;
|
||||
company_address: string;
|
||||
tax_rate: number;
|
||||
updated_at?: string | null;
|
||||
updated_by?: string | null;
|
||||
};
|
||||
@@ -119,6 +120,7 @@ export interface UpdateCompanySettingsRequest {
|
||||
company_phone?: string;
|
||||
company_email?: string;
|
||||
company_address?: string;
|
||||
tax_rate?: number;
|
||||
}
|
||||
|
||||
export interface UploadLogoResponse {
|
||||
@@ -139,6 +141,49 @@ export interface UploadFaviconResponse {
|
||||
};
|
||||
}
|
||||
|
||||
export interface RecaptchaSettingsResponse {
|
||||
status: string;
|
||||
data: {
|
||||
recaptcha_site_key: string;
|
||||
recaptcha_enabled: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface RecaptchaSettingsAdminResponse {
|
||||
status: string;
|
||||
data: {
|
||||
recaptcha_site_key: string;
|
||||
recaptcha_secret_key: string;
|
||||
recaptcha_secret_key_masked: string;
|
||||
recaptcha_enabled: boolean;
|
||||
has_site_key: boolean;
|
||||
has_secret_key: boolean;
|
||||
updated_at?: string | null;
|
||||
updated_by?: string | null;
|
||||
};
|
||||
}
|
||||
|
||||
export interface UpdateRecaptchaSettingsRequest {
|
||||
recaptcha_site_key?: string;
|
||||
recaptcha_secret_key?: string;
|
||||
recaptcha_enabled?: boolean;
|
||||
}
|
||||
|
||||
export interface VerifyRecaptchaRequest {
|
||||
token: string;
|
||||
}
|
||||
|
||||
export interface VerifyRecaptchaResponse {
|
||||
status: string;
|
||||
data: {
|
||||
verified: boolean;
|
||||
score?: number;
|
||||
action?: string;
|
||||
error_codes?: string[];
|
||||
message?: string;
|
||||
};
|
||||
}
|
||||
|
||||
const systemSettingsService = {
|
||||
/**
|
||||
* Get platform currency (public endpoint)
|
||||
@@ -311,7 +356,56 @@ const systemSettingsService = {
|
||||
},
|
||||
};
|
||||
|
||||
const recaptchaService = {
|
||||
/**
|
||||
* Get reCAPTCHA settings (public endpoint)
|
||||
*/
|
||||
getRecaptchaSettings: async (): Promise<RecaptchaSettingsResponse> => {
|
||||
const response = await apiClient.get<RecaptchaSettingsResponse>(
|
||||
'/api/admin/system-settings/recaptcha'
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get reCAPTCHA settings (admin only)
|
||||
*/
|
||||
getRecaptchaSettingsAdmin: async (): Promise<RecaptchaSettingsAdminResponse> => {
|
||||
const response = await apiClient.get<RecaptchaSettingsAdminResponse>(
|
||||
'/api/admin/system-settings/recaptcha/admin'
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Update reCAPTCHA settings (admin only)
|
||||
*/
|
||||
updateRecaptchaSettings: async (
|
||||
settings: UpdateRecaptchaSettingsRequest
|
||||
): Promise<RecaptchaSettingsAdminResponse> => {
|
||||
const response = await apiClient.put<RecaptchaSettingsAdminResponse>(
|
||||
'/api/admin/system-settings/recaptcha',
|
||||
settings
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Verify reCAPTCHA token
|
||||
*/
|
||||
verifyRecaptcha: async (
|
||||
token: string
|
||||
): Promise<VerifyRecaptchaResponse> => {
|
||||
const response = await apiClient.post<VerifyRecaptchaResponse>(
|
||||
'/api/admin/system-settings/recaptcha/verify',
|
||||
{ token }
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
|
||||
export default systemSettingsService;
|
||||
export { recaptchaService };
|
||||
|
||||
export type {
|
||||
PlatformCurrencyResponse,
|
||||
@@ -328,5 +422,10 @@ export type {
|
||||
UpdateCompanySettingsRequest,
|
||||
UploadLogoResponse,
|
||||
UploadFaviconResponse,
|
||||
RecaptchaSettingsResponse,
|
||||
RecaptchaSettingsAdminResponse,
|
||||
UpdateRecaptchaSettingsRequest,
|
||||
VerifyRecaptchaRequest,
|
||||
VerifyRecaptchaResponse,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user