mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat: Stripe payment checkout session
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
UseMutationResult,
|
||||
} from 'react-query';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { transformToCamelCase } from '@/utils';
|
||||
|
||||
interface AccountSessionValues {
|
||||
connectedAccountId?: string;
|
||||
@@ -57,3 +58,42 @@ export const useCreateStripeAccount = (
|
||||
{ ...options },
|
||||
);
|
||||
};
|
||||
|
||||
interface CreateCheckoutSessionValues {
|
||||
linkId: string;
|
||||
}
|
||||
|
||||
interface CreateCheckoutSessionResponse {
|
||||
sessionId: string;
|
||||
publishableKey: string;
|
||||
redirectTo: string;
|
||||
}
|
||||
|
||||
export const useCreateStripeCheckoutSession = (
|
||||
options?: UseMutationOptions<
|
||||
CreateCheckoutSessionResponse,
|
||||
Error,
|
||||
CreateCheckoutSessionValues
|
||||
>,
|
||||
): UseMutationResult<
|
||||
CreateCheckoutSessionResponse,
|
||||
Error,
|
||||
CreateCheckoutSessionValues
|
||||
> => {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(values: CreateCheckoutSessionValues) => {
|
||||
return apiRequest
|
||||
.post(
|
||||
`/stripe_integration/${values.linkId}/create_checkout_session`,
|
||||
values,
|
||||
)
|
||||
.then(
|
||||
(res) =>
|
||||
transformToCamelCase(res.data) as CreateCheckoutSessionResponse,
|
||||
);
|
||||
},
|
||||
{ ...options },
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user