-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: get payments methods to check if there's any payment info saved
- Loading branch information
Showing
5 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...es/react-query/registry-server/getPaymentMethodsQuery/getPaymentMethodsQuery.constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const GET_PAYMENT_METHODS_QUERY_KEY = 'getPost'; |
31 changes: 31 additions & 0 deletions
31
...lib/queries/react-query/registry-server/getPaymentMethodsQuery/getPaymentMethodsQuery.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { apiUri } from 'lib/apiUri'; | ||
|
||
import { GET_PAYMENT_METHODS_QUERY_KEY } from './getPaymentMethodsQuery.constants'; | ||
import { | ||
ReactQueryGetPostQueryParams, | ||
ReactQueryGetPostQueryResponse, | ||
} from './getPaymentMethodsQuery.types'; | ||
|
||
export const getPaymentMethodsQuery = ({ | ||
limit, | ||
...params | ||
}: ReactQueryGetPostQueryParams): ReactQueryGetPostQueryResponse => ({ | ||
queryKey: [GET_PAYMENT_METHODS_QUERY_KEY, limit], | ||
queryFn: async () => { | ||
try { | ||
const resp = await fetch( | ||
`${apiUri}/marketplace/v1/stripe/payment-methods${ | ||
limit ? `?limit=${limit}` : '' | ||
}`, | ||
{ | ||
method: 'GET', | ||
credentials: 'include', | ||
}, | ||
); | ||
return await resp.json(); | ||
} catch (e) { | ||
return null; | ||
} | ||
}, | ||
...params, | ||
}); |
12 changes: 12 additions & 0 deletions
12
...ueries/react-query/registry-server/getPaymentMethodsQuery/getPaymentMethodsQuery.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { PaymentMethod } from '@stripe/stripe-js'; | ||
import { QueryObserverOptions } from '@tanstack/react-query'; | ||
|
||
import { ReactQueryBuilderResponse } from '../../types/react-query.types'; | ||
|
||
export type ReactQueryGetPostQueryResponse = QueryObserverOptions<{ | ||
paymentMethods?: PaymentMethod[] | null; | ||
}>; | ||
|
||
export type ReactQueryGetPostQueryParams = { | ||
limit?: number; | ||
} & ReactQueryBuilderResponse<ReactQueryGetPostQueryResponse>; |