mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
feat: integrate LemonSqueezy to subscription payment
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
// @ts-nocheck
|
||||
import { useEffect } from "react"
|
||||
import { useMutation, useQueryClient } from "react-query";
|
||||
import { useRequestQuery } from "../useQueryRequest";
|
||||
import useApiRequest from "../useRequest";
|
||||
import { useEffect } from 'react';
|
||||
import { useMutation, useQueryClient } from 'react-query';
|
||||
import { useRequestQuery } from '../useQueryRequest';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { useSetSubscriptions } from '../state/subscriptions';
|
||||
import T from './types';
|
||||
|
||||
@@ -22,9 +22,9 @@ export const usePaymentByVoucher = (props) => {
|
||||
queryClient.invalidateQueries(T.ORGANIZATIONS);
|
||||
},
|
||||
...props,
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetches the organization subscriptions.
|
||||
@@ -41,5 +41,22 @@ export const useOrganizationSubscriptions = (props) => {
|
||||
if (state.isSuccess) {
|
||||
setSubscriptions(state.data);
|
||||
}
|
||||
}, [state.isSuccess, state.data, setSubscriptions])
|
||||
};
|
||||
}, [state.isSuccess, state.data, setSubscriptions]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetches the checkout url of the lemon squeezy.
|
||||
*/
|
||||
export const useGetLemonSqueezyCheckout = (props = {}) => {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(values) =>
|
||||
apiRequest
|
||||
.post('subscription/lemon/checkout_url', values)
|
||||
.then((res) => res.data),
|
||||
{
|
||||
...props,
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user