Enabled payment for Corporate along with increasing every single one of their students/teachers expiry date as well

This commit is contained in:
Tiago Ribeiro
2023-11-26 11:01:27 +00:00
parent 7e91a989b3
commit fa544bf4e8
3 changed files with 127 additions and 84 deletions

View File

@@ -10,10 +10,11 @@ interface Props {
price: number;
duration: number;
duration_unit: DurationUnit;
setIsLoading: (isLoading: boolean) => void;
onSuccess: (duration: number, duration_unit: DurationUnit) => void;
}
export default function PayPalPayment({price, currency, duration, duration_unit, onSuccess}: Props) {
export default function PayPalPayment({price, currency, duration, duration_unit, setIsLoading, onSuccess}: Props) {
const [{options}, dispatch] = usePayPalScriptReducer();
useEffect(() => {
@@ -28,7 +29,7 @@ export default function PayPalPayment({price, currency, duration, duration_unit,
}, [currency]);
const createOrder = async (data: CreateOrderData, actions: CreateOrderActions): Promise<string> => {
console.log(data, actions);
setIsLoading(true);
return axios
.post<OrderResponseBody>("/api/paypal", {currencyCode: currency, price})
@@ -49,13 +50,11 @@ export default function PayPalPayment({price, currency, duration, duration_unit,
};
const onError = async (data: Record<string, unknown>) => {
console.log(data);
toast.error("ERROR!");
setIsLoading(false);
};
const onCancel = async (data: Record<string, unknown>, actions: OnCancelledActions) => {
console.log(data, actions);
toast.error("CANCEL!");
setIsLoading(false);
};
return (