mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
feat: Stripe connect using OAuth
This commit is contained in:
@@ -7,7 +7,6 @@ import {
|
||||
import useApiRequest from '../useRequest';
|
||||
import { transformToCamelCase } from '@/utils';
|
||||
|
||||
|
||||
// Create Stripe Account Link.
|
||||
// ------------------------------------
|
||||
interface StripeAccountLinkResponse {
|
||||
@@ -47,7 +46,6 @@ export const useCreateStripeAccountLink = (
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// Create Stripe Account Session.
|
||||
// ------------------------------------
|
||||
interface AccountSessionValues {
|
||||
@@ -149,3 +147,70 @@ export const useCreateStripeCheckoutSession = (
|
||||
{ ...options },
|
||||
);
|
||||
};
|
||||
|
||||
// Create Stripe Account OAuth Link.
|
||||
// ------------------------------------
|
||||
interface StripeAccountLinkResponse {
|
||||
clientSecret: {
|
||||
created: number;
|
||||
expiresAt: number;
|
||||
object: string;
|
||||
url: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface StripeAccountLinkValues {
|
||||
stripeAccountId: string;
|
||||
}
|
||||
|
||||
export const useGetStripeAccountLink = (
|
||||
options?: UseQueryOptions<StripeAccountLinkResponse, Error>,
|
||||
): UseQueryResult<StripeAccountLinkResponse, Error> => {
|
||||
const apiRequest = useApiRequest();
|
||||
return useQuery(
|
||||
'getStripeAccountLink',
|
||||
() => {
|
||||
return apiRequest
|
||||
.get('/stripe_integration/link')
|
||||
.then((res) => transformToCamelCase(res.data));
|
||||
},
|
||||
{ ...options },
|
||||
);
|
||||
};
|
||||
|
||||
// Get Stripe Account OAuth Callback Mutation.
|
||||
// ------------------------------------
|
||||
interface StripeAccountCallbackMutationValues {
|
||||
code: string;
|
||||
}
|
||||
|
||||
interface StripeAccountCallbackMutationResponse {
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
export const useSetStripeAccountCallback = (
|
||||
options?: UseMutationOptions<
|
||||
StripeAccountCallbackMutationResponse,
|
||||
Error,
|
||||
StripeAccountCallbackMutationValues
|
||||
>,
|
||||
): UseMutationResult<
|
||||
StripeAccountCallbackMutationResponse,
|
||||
Error,
|
||||
StripeAccountCallbackMutationValues
|
||||
> => {
|
||||
const apiRequest = useApiRequest();
|
||||
return useMutation(
|
||||
(values: StripeAccountCallbackMutationValues) => {
|
||||
return apiRequest
|
||||
.post(`/stripe_integration/callback`, values)
|
||||
.then(
|
||||
(res) =>
|
||||
transformToCamelCase(
|
||||
res.data,
|
||||
) as StripeAccountCallbackMutationResponse,
|
||||
);
|
||||
},
|
||||
{ ...options },
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user