This commit is contained in:
ct
2025-07-03 00:48:06 +08:00
parent 0aa0d9569f
commit db892fc4f5
26 changed files with 807 additions and 59 deletions

View File

@@ -14,6 +14,33 @@ const usePricingStore = create(
isCheckingOut: false,
checkoutPurchase: async (price_id) => {
console.log('checkoutPurchase', price_id);
set({ isCheckingOut: true });
try {
const response = await axiosInstance.post(route('api.user.purchase'), { price_id: price_id });
console.log(response);
if (response?.data?.success?.data) {
if (response.data.success.data.redirect) {
window.location.href = response.data.success.data.redirect;
}
} else {
throw 'Invalid API response';
}
} catch (error) {
console.error(route('api.user.purchase'));
console.error('Error fetching:', error);
set({ isCheckingOut: false });
if (error?.response?.data?.error?.message?.length > 0) {
toast.error(error.response.data.error.message);
}
throw error;
} finally {
set({ isCheckingOut: false });
}
},
checkoutSubscribe: async (price_id) => {
console.log('checkoutSubscribe', price_id);