Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/dashboard/src/data/billing/create-hold-payment-intent-mutation.ts
2501 views
1
/**
2
* Copyright (c) 2023 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
7
import { useMutation } from "@tanstack/react-query";
8
import { getGitpodService } from "../../service/service";
9
import { useCurrency } from "../../payment-context";
10
11
export const useCreateHoldPaymentIntentMutation = () => {
12
const { currency } = useCurrency();
13
14
return useMutation(async (attributionId: string) => {
15
// Create stripe customer if needed
16
await getGitpodService().server.createStripeCustomerIfNeeded(attributionId, currency);
17
18
// create payment intent for hold and for subscription
19
return await getGitpodService().server.createHoldPaymentIntent(attributionId);
20
});
21
};
22
23