mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
feat: Stripe connect using OAuth
This commit is contained in:
@@ -12,7 +12,6 @@ import { transformToCamelCase, transfromToSnakeCase } from '@/utils';
|
||||
const PaymentServicesQueryKey = 'PaymentServices';
|
||||
const PaymentServicesStateQueryKey = 'PaymentServicesState';
|
||||
|
||||
|
||||
// # Get payment services.
|
||||
// -----------------------------------------
|
||||
export interface GetPaymentServicesResponse {}
|
||||
@@ -48,12 +47,15 @@ export const useGetPaymentServices = (
|
||||
export interface GetPaymentServicesStateResponse {
|
||||
stripe: {
|
||||
isStripeAccountCreated: boolean;
|
||||
isStripePaymentActive: boolean;
|
||||
isStripePaymentEnabled: boolean;
|
||||
isStripePayoutEnabled: boolean;
|
||||
isStripeEnabled: boolean;
|
||||
isStripeServerConfigured: boolean;
|
||||
stripeAccountId: string | null;
|
||||
stripePaymentMethodId: number | null;
|
||||
stripeCurrencies: string[];
|
||||
stripePublishableKey: string;
|
||||
stripeAuthLink: string;
|
||||
stripeRedirectUrl: string;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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