The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Convert POST setup intent in AddNewPaymentMethod to RQ, and update API spec
Joshen Limd5724edd6aa7
diff --git a/studio/components/interfaces/BillingV2/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx b/studio/components/interfaces/BillingV2/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsxindex 6b1753d3086..c4c427db142 100644--- a/studio/components/interfaces/BillingV2/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx+++ b/studio/components/interfaces/BillingV2/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx@@ -1,14 +1,14 @@import HCaptcha from '@hcaptcha/react-hcaptcha'import { Elements } from '@stripe/react-stripe-js'import { loadStripe } from '@stripe/stripe-js'-import { FC, useCallback, useEffect, useState } from 'react'-import { useTheme } from 'common'+import { useCallback, useEffect, useState } from 'react'+import { Modal } from 'ui'++import { useOrganizationPaymentMethodSetupIntent } from 'data/organizations/organization-payment-method-setup-intent-mutation'import { useSelectedOrganization, useStore } from 'hooks'-import { post } from 'lib/common/fetch'-import { API_URL, STRIPE_PUBLIC_KEY } from 'lib/constants'+import { STRIPE_PUBLIC_KEY } from 'lib/constants'import { useIsHCaptchaLoaded } from 'stores/hcaptcha-loaded-store'-import { Modal } from 'ui'import AddPaymentMethodForm from './AddPaymentMethodForm'interface AddNewPaymentMethodModalProps {@@ -28,12 +28,26 @@ const AddNewPaymentMethodModal = ({}: AddNewPaymentMethodModalProps) => {const { ui } = useStore()const [intent, setIntent] = useState<any>()+ const selectedOrganization = useSelectedOrganization()const captchaLoaded = useIsHCaptchaLoaded()const [captchaToken, setCaptchaToken] = useState<string | null>(null)const [captchaRef, setCaptchaRef] = useState<HCaptcha | null>(null)+ const { mutate: setupIntent } = useOrganizationPaymentMethodSetupIntent({+ onSuccess: (intent) => {+ setIntent(intent)+ },+ onError: (error) => {+ ui.setNotification({+ category: 'error',+ error: intent.error,+ message: `Failed to setup intent: ${error.message}`,+ })+ },+ })+const captchaRefCallback = useCallback((node) => {setCaptchaRef(node)}, [])@@ -52,7 +66,7 @@ const AddNewPaymentMethodModal = ({return}- await setupIntent(token ?? undefined)+ await initSetupIntent(token ?? undefined)resetCaptcha()}}@@ -65,25 +79,13 @@ const AddNewPaymentMethodModal = ({captchaRef?.resetCaptcha()}- const selectedOrganization = useSelectedOrganization()+ const initSetupIntent = async (hcaptchaToken: string | undefined) => {+ const slug = selectedOrganization?.slug+ if (!slug) return console.error('Slug is required')+ if (!hcaptchaToken) return console.error('HCaptcha token required')- const setupIntent = async (hcaptchaToken: string | undefined) => {setIntent(undefined)-- const orgSlug = selectedOrganization?.slug ?? ''- const intent = await post(`${API_URL}/organizations/${orgSlug}/payments/setup-intent`, {- hcaptchaToken,- })-- if (intent.error) {- return ui.setNotification({- category: 'error',- error: intent.error,- message: `Failed to setup intent: ${intent.error.message}`,- })- } else {- setIntent(intent)- }+ setupIntent({ slug, hcaptchaToken })}const { isDarkMode } = useTheme()diff --git a/studio/components/interfaces/BillingV2/Subscription/Tier/AddNewPaymentMethodForm.tsx b/studio/components/interfaces/BillingV2/Subscription/Tier/AddNewPaymentMethodForm.tsxdeleted file mode 100644index bf192b0f350..00000000000--- a/studio/components/interfaces/BillingV2/Subscription/Tier/AddNewPaymentMethodForm.tsx+++ /dev/null@@ -1,90 +0,0 @@-import { useState } from 'react'-import { Button, Modal } from 'ui'-import { useStripe, useElements, PaymentElement } from '@stripe/react-stripe-js'-import { useStore } from 'hooks'--interface AddNewPaymentMethodFormProps {- returnUrl: string- onCancel: () => void- onConfirm: () => void-}--// [Joshen] Directly brought over from old Billing folder, so we can deprecate that folder easily next time--// Stripe docs recommend to use the new SetupIntent flow over-// manually creating and attaching payment methods via the API-// Small UX annoyance here, that the page will be refreshed--const AddNewPaymentMethodForm = ({- returnUrl,- onCancel,- onConfirm,-}: AddNewPaymentMethodFormProps) => {- const { ui } = useStore()- const stripe = useStripe()- const elements = useElements()-- const [isSaving, setIsSaving] = useState(false)-- const handleSubmit = async (event: any) => {- event.preventDefault()-- if (!stripe || !elements) {- console.error('Stripe.js has not loaded')- return- }-- setIsSaving(true)-- if (document !== undefined) {- // [Joshen] This is to ensure that any 3DS popup from Stripe remains clickable- document.body.classList.add('!pointer-events-auto')- }-- const { error } = await stripe.confirmSetup({- elements,- redirect: 'if_required',- confirmParams: { return_url: returnUrl },- })-- if (error) {- setIsSaving(false)- ui.setNotification({- category: 'error',- message: error?.message ?? ' Failed to save card details',- })- } else {- setIsSaving(false)- onConfirm()- }-- if (document !== undefined) {- document.body.classList.remove('!pointer-events-auto')- }- }-- return (- <form onSubmit={handleSubmit}>- <Modal.Content>- <div- className={`transition ${isSaving ? 'pointer-events-none opacity-75' : 'opacity-100'}`}- >- <PaymentElement />- </div>- </Modal.Content>- <Modal.Separator />- <Modal.Content>- <div className="flex items-center space-x-2 pt-2">- <Button block htmlType="submit" type="primary" loading={isSaving} disabled={isSaving}>- Save- </Button>- <Button htmlType="button" type="default" onClick={onCancel} block disabled={isSaving}>- Cancel- </Button>- </div>- </Modal.Content>- </form>- )-}--export default AddNewPaymentMethodFormdiff --git a/studio/components/interfaces/BillingV2/Subscription/Tier/AddNewPaymentMethodModal.tsx b/studio/components/interfaces/BillingV2/Subscription/Tier/AddNewPaymentMethodModal.tsxdeleted file mode 100644index d970f551535..00000000000--- a/studio/components/interfaces/BillingV2/Subscription/Tier/AddNewPaymentMethodModal.tsx+++ /dev/null@@ -1,162 +0,0 @@-import HCaptcha from '@hcaptcha/react-hcaptcha'-import { Elements } from '@stripe/react-stripe-js'-import { loadStripe } from '@stripe/stripe-js'-import { useCallback, useEffect, useState } from 'react'--import { useTheme } from 'common'-import ShimmeringLoader from 'components/ui/ShimmeringLoader'-import { useSelectedOrganization, useStore } from 'hooks'-import { post } from 'lib/common/fetch'-import { API_URL, STRIPE_PUBLIC_KEY } from 'lib/constants'-import { useIsHCaptchaLoaded } from 'stores/hcaptcha-loaded-store'-import { Modal } from 'ui'-import AddNewPaymentMethodForm from './AddNewPaymentMethodForm'--// [Joshen] Directly brought over from old Billing folder, so we can deprecate that folder easily next time--interface AddNewPaymentMethodModalProps {- visible: boolean- returnUrl: string- onCancel: () => void- onConfirm: () => void-}--const stripePromise = loadStripe(STRIPE_PUBLIC_KEY)--const AddNewPaymentMethodModal = ({- visible,- returnUrl,- onCancel,- onConfirm,-}: AddNewPaymentMethodModalProps) => {- const { ui } = useStore()- const [intent, setIntent] = useState<any>()-- const captchaLoaded = useIsHCaptchaLoaded()- const [captchaToken, setCaptchaToken] = useState<string | null>(null)- const [captchaRef, setCaptchaRef] = useState<HCaptcha | null>(null)-- const captchaRefCallback = useCallback((node) => {- setCaptchaRef(node)- }, [])-- useEffect(() => {- const loadPaymentForm = async () => {- if (visible && captchaRef && captchaLoaded) {- let token = captchaToken-- try {- if (!token) {- const captchaResponse = await captchaRef.execute({ async: true })- token = captchaResponse?.response ?? null- }- } catch (error) {- return- }-- await setupIntent(token ?? undefined)- resetCaptcha()- }- }-- loadPaymentForm()- }, [visible, captchaRef, captchaLoaded])-- const resetCaptcha = () => {- setCaptchaToken(null)- captchaRef?.resetCaptcha()- }-- const selectedOrganization = useSelectedOrganization()-- const setupIntent = async (hcaptchaToken: string | undefined) => {- setIntent(undefined)-- const orgSlug = selectedOrganization?.slug ?? ''- const intent = await post(`${API_URL}/organizations/${orgSlug}/payments/setup-intent`, {- hcaptchaToken,- })-- if (intent.error) {- return ui.setNotification({- category: 'error',- error: intent.error,- message: `Failed to setup intent: ${intent.error.message}`,- })- } else {- setIntent(intent)- }- }-- const { isDarkMode } = useTheme()-- const options = {- clientSecret: intent ? intent.client_secret : '',- appearance: { theme: isDarkMode ? 'night' : 'flat', labels: 'floating' },- } as any-- const onLocalCancel = () => {- setIntent(undefined)- return onCancel()- }-- const onLocalConfirm = () => {- setIntent(undefined)- return onConfirm()- }-- return (- <>- <HCaptcha- id="supabase-captcha"- ref={captchaRefCallback}- sitekey={process.env.NEXT_PUBLIC_HCAPTCHA_SITE_KEY!}- size="invisible"- onOpen={() => {- // [Joshen] This is to ensure that hCaptcha popup remains clickable- if (document !== undefined) document.body.classList.add('!pointer-events-auto')- }}- onClose={() => {- onLocalCancel()- if (document !== undefined) document.body.classList.remove('!pointer-events-auto')- }}- onVerify={(token) => {- setCaptchaToken(token)- if (document !== undefined) document.body.classList.remove('!pointer-events-auto')- }}- onExpire={() => {- setCaptchaToken(null)- }}- />-- <Modal- hideFooter- size="medium"- visible={visible}- header="Add new payment method"- onCancel={() => onLocalCancel()}- className="PAYMENT"- >- <div className="py-4">- {intent === undefined ? (- <div className="px-6 space-y-2">- <ShimmeringLoader className="w-full" />- <ShimmeringLoader className="w-3/4" />- <ShimmeringLoader className="w-1/2" />- </div>- ) : (- <Elements stripe={stripePromise} options={options}>- <AddNewPaymentMethodForm- returnUrl={returnUrl}- onCancel={onLocalCancel}- onConfirm={onLocalConfirm}- />- </Elements>- )}- </div>- </Modal>- </>- )-}--export default AddNewPaymentMethodModaldiff --git a/studio/components/interfaces/BillingV2/Subscription/Tier/PaymentMethodSelection.tsx b/studio/components/interfaces/BillingV2/Subscription/Tier/PaymentMethodSelection.tsxindex 877d1cc9f94..c1e5151a91d 100644--- a/studio/components/interfaces/BillingV2/Subscription/Tier/PaymentMethodSelection.tsx+++ b/studio/components/interfaces/BillingV2/Subscription/Tier/PaymentMethodSelection.tsx@@ -9,7 +9,7 @@ import { useCheckPermissions, useSelectedOrganization, useStore } from 'hooks'import { BASE_PATH } from 'lib/constants'import { getURL } from 'lib/helpers'import { Button, IconAlertCircle, IconCreditCard, IconLoader, IconPlus, Listbox } from 'ui'-import AddNewPaymentMethodModal from './AddNewPaymentMethodModal'+import { AddNewPaymentMethodModal } from 'components/interfaces/BillingV2'export interface PaymentMethodSelectionProps {selectedPaymentMethod?: stringdiff --git a/studio/data/api.d.ts b/studio/data/api.d.tsindex 0ee3535b234..30c7c2551c9 100644--- a/studio/data/api.d.ts+++ b/studio/data/api.d.ts@@ -1493,10 +1493,8 @@ export interface paths {put: operations["AuthPostgresConfigController_updateConfig"];};"/v1/projects/{ref}/config/database/pgbouncer": {- /** Gets project's pgbouncer config */- get: operations["V1PgbouncerConfigController_getPgbouncerConfig"];- /** Updates project's pgbouncer config */- patch: operations["V1PgbouncerConfigController_updatePgbouncerConfig"];+ /** Get project's pgbouncer config */+ get: operations["V1PgbouncerConfigController_v1GetPgbouncerConfig"];};"/v1/projects/{ref}/config/auth": {/** Gets project's auth config */@@ -1775,126 +1773,126 @@ export interface components {EXTERNAL_ZOOM_SECRET: string;};UpdateGoTrueConfigBody: {- SITE_URL: string;- DISABLE_SIGNUP: boolean;- JWT_EXP: number;- SMTP_ADMIN_EMAIL: string;- SMTP_HOST: string;- SMTP_PORT: string;- SMTP_USER: string;+ SITE_URL?: string;+ DISABLE_SIGNUP?: boolean;+ JWT_EXP?: number;+ SMTP_ADMIN_EMAIL?: string;+ SMTP_HOST?: string;+ SMTP_PORT?: string;+ SMTP_USER?: string;SMTP_PASS?: string | null;SMTP_PASS_ENCRYPTED?: string | null;- SMTP_MAX_FREQUENCY: number;+ SMTP_MAX_FREQUENCY?: number;SMTP_SENDER_NAME?: string;- MAILER_AUTOCONFIRM: boolean;- MAILER_SUBJECTS_INVITE: string;- MAILER_SUBJECTS_CONFIRMATION: string;- MAILER_SUBJECTS_RECOVERY: string;- MAILER_SUBJECTS_EMAIL_CHANGE: string;- MAILER_SUBJECTS_MAGIC_LINK: string;- MAILER_TEMPLATES_INVITE_CONTENT: string;- MAILER_TEMPLATES_CONFIRMATION_CONTENT: string;- MAILER_TEMPLATES_RECOVERY_CONTENT: string;- MAILER_TEMPLATES_EMAIL_CHANGE_CONTENT: string;- MAILER_TEMPLATES_MAGIC_LINK_CONTENT: string;- MFA_MAX_ENROLLED_FACTORS: number;- URI_ALLOW_LIST: string;- EXTERNAL_EMAIL_ENABLED: boolean;- EXTERNAL_PHONE_ENABLED: boolean;+ MAILER_AUTOCONFIRM?: boolean;+ MAILER_SUBJECTS_INVITE?: string;+ MAILER_SUBJECTS_CONFIRMATION?: string;+ MAILER_SUBJECTS_RECOVERY?: string;+ MAILER_SUBJECTS_EMAIL_CHANGE?: string;+ MAILER_SUBJECTS_MAGIC_LINK?: string;+ MAILER_TEMPLATES_INVITE_CONTENT?: string;+ MAILER_TEMPLATES_CONFIRMATION_CONTENT?: string;+ MAILER_TEMPLATES_RECOVERY_CONTENT?: string;+ MAILER_TEMPLATES_EMAIL_CHANGE_CONTENT?: string;+ MAILER_TEMPLATES_MAGIC_LINK_CONTENT?: string;+ MFA_MAX_ENROLLED_FACTORS?: number;+ URI_ALLOW_LIST?: string;+ EXTERNAL_EMAIL_ENABLED?: boolean;+ EXTERNAL_PHONE_ENABLED?: boolean;SAML_ENABLED?: boolean;- SECURITY_CAPTCHA_ENABLED: boolean;- SECURITY_CAPTCHA_PROVIDER: string;- SECURITY_CAPTCHA_SECRET: string;- RATE_LIMIT_EMAIL_SENT: number;- RATE_LIMIT_SMS_SENT: number;- MAILER_SECURE_EMAIL_CHANGE_ENABLED: boolean;- REFRESH_TOKEN_ROTATION_ENABLED: boolean;- PASSWORD_MIN_LENGTH: number;- SECURITY_UPDATE_PASSWORD_REQUIRE_REAUTHENTICATION: boolean;- SECURITY_REFRESH_TOKEN_REUSE_INTERVAL: number;- MAILER_OTP_EXP: number;- SMS_AUTOCONFIRM: boolean;- SMS_MAX_FREQUENCY: number;- SMS_OTP_EXP: number;- SMS_OTP_LENGTH: number;- SMS_PROVIDER: string;- SMS_MESSAGEBIRD_ACCESS_KEY: string;- SMS_MESSAGEBIRD_ORIGINATOR: string;- SMS_TEXTLOCAL_API_KEY: string;- SMS_TEXTLOCAL_SENDER: string;- SMS_TWILIO_ACCOUNT_SID: string;- SMS_TWILIO_AUTH_TOKEN: string;- SMS_TWILIO_MESSAGE_SERVICE_SID: string;- SMS_TWILIO_VERIFY_ACCOUNT_SID: string;- SMS_TWILIO_VERIFY_AUTH_TOKEN: string;- SMS_TWILIO_VERIFY_MESSAGE_SERVICE_SID: string;- SMS_VONAGE_API_KEY: string;- SMS_VONAGE_API_SECRET: string;- SMS_VONAGE_FROM: string;- SMS_TEMPLATE: string;- EXTERNAL_APPLE_ENABLED: boolean;- EXTERNAL_APPLE_CLIENT_ID: string;- EXTERNAL_APPLE_SECRET: string;+ SECURITY_CAPTCHA_ENABLED?: boolean;+ SECURITY_CAPTCHA_PROVIDER?: string;+ SECURITY_CAPTCHA_SECRET?: string;+ RATE_LIMIT_EMAIL_SENT?: number;+ RATE_LIMIT_SMS_SENT?: number;+ MAILER_SECURE_EMAIL_CHANGE_ENABLED?: boolean;+ REFRESH_TOKEN_ROTATION_ENABLED?: boolean;+ PASSWORD_MIN_LENGTH?: number;+ SECURITY_UPDATE_PASSWORD_REQUIRE_REAUTHENTICATION?: boolean;+ SECURITY_REFRESH_TOKEN_REUSE_INTERVAL?: number;+ MAILER_OTP_EXP?: number;+ SMS_AUTOCONFIRM?: boolean;+ SMS_MAX_FREQUENCY?: number;+ SMS_OTP_EXP?: number;+ SMS_OTP_LENGTH?: number;+ SMS_PROVIDER?: string;+ SMS_MESSAGEBIRD_ACCESS_KEY?: string;+ SMS_MESSAGEBIRD_ORIGINATOR?: string;+ SMS_TEXTLOCAL_API_KEY?: string;+ SMS_TEXTLOCAL_SENDER?: string;+ SMS_TWILIO_ACCOUNT_SID?: string;+ SMS_TWILIO_AUTH_TOKEN?: string;+ SMS_TWILIO_MESSAGE_SERVICE_SID?: string;+ SMS_TWILIO_VERIFY_ACCOUNT_SID?: string;+ SMS_TWILIO_VERIFY_AUTH_TOKEN?: string;+ SMS_TWILIO_VERIFY_MESSAGE_SERVICE_SID?: string;+ SMS_VONAGE_API_KEY?: string;+ SMS_VONAGE_API_SECRET?: string;+ SMS_VONAGE_FROM?: string;+ SMS_TEMPLATE?: string;+ EXTERNAL_APPLE_ENABLED?: boolean;+ EXTERNAL_APPLE_CLIENT_ID?: string;+ EXTERNAL_APPLE_SECRET?: string;EXTERNAL_APPLE_ADDITIONAL_CLIENT_IDS?: string;- EXTERNAL_AZURE_ENABLED: boolean;- EXTERNAL_AZURE_CLIENT_ID: string;- EXTERNAL_AZURE_SECRET: string;- EXTERNAL_AZURE_URL: string;- EXTERNAL_BITBUCKET_ENABLED: boolean;- EXTERNAL_BITBUCKET_CLIENT_ID: string;- EXTERNAL_BITBUCKET_SECRET: string;- EXTERNAL_DISCORD_ENABLED: boolean;- EXTERNAL_DISCORD_CLIENT_ID: string;- EXTERNAL_DISCORD_SECRET: string;- EXTERNAL_FACEBOOK_ENABLED: boolean;- EXTERNAL_FACEBOOK_CLIENT_ID: string;- EXTERNAL_FACEBOOK_SECRET: string;- EXTERNAL_FIGMA_ENABLED: boolean;- EXTERNAL_FIGMA_CLIENT_ID: string;- EXTERNAL_FIGMA_SECRET: string;- EXTERNAL_GITHUB_ENABLED: boolean;- EXTERNAL_GITHUB_CLIENT_ID: string;- EXTERNAL_GITHUB_SECRET: string;- EXTERNAL_GITLAB_ENABLED: boolean;- EXTERNAL_GITLAB_CLIENT_ID: string;- EXTERNAL_GITLAB_SECRET: string;- EXTERNAL_GITLAB_URL: string;- EXTERNAL_GOOGLE_ENABLED: boolean;- EXTERNAL_GOOGLE_CLIENT_ID: string;- EXTERNAL_GOOGLE_SECRET: string;+ EXTERNAL_AZURE_ENABLED?: boolean;+ EXTERNAL_AZURE_CLIENT_ID?: string;+ EXTERNAL_AZURE_SECRET?: string;+ EXTERNAL_AZURE_URL?: string;+ EXTERNAL_BITBUCKET_ENABLED?: boolean;+ EXTERNAL_BITBUCKET_CLIENT_ID?: string;+ EXTERNAL_BITBUCKET_SECRET?: string;+ EXTERNAL_DISCORD_ENABLED?: boolean;+ EXTERNAL_DISCORD_CLIENT_ID?: string;+ EXTERNAL_DISCORD_SECRET?: string;+ EXTERNAL_FACEBOOK_ENABLED?: boolean;+ EXTERNAL_FACEBOOK_CLIENT_ID?: string;+ EXTERNAL_FACEBOOK_SECRET?: string;+ EXTERNAL_FIGMA_ENABLED?: boolean;+ EXTERNAL_FIGMA_CLIENT_ID?: string;+ EXTERNAL_FIGMA_SECRET?: string;+ EXTERNAL_GITHUB_ENABLED?: boolean;+ EXTERNAL_GITHUB_CLIENT_ID?: string;+ EXTERNAL_GITHUB_SECRET?: string;+ EXTERNAL_GITLAB_ENABLED?: boolean;+ EXTERNAL_GITLAB_CLIENT_ID?: string;+ EXTERNAL_GITLAB_SECRET?: string;+ EXTERNAL_GITLAB_URL?: string;+ EXTERNAL_GOOGLE_ENABLED?: boolean;+ EXTERNAL_GOOGLE_CLIENT_ID?: string;+ EXTERNAL_GOOGLE_SECRET?: string;EXTERNAL_GOOGLE_ADDITIONAL_CLIENT_IDS?: string;- EXTERNAL_KAKAO_ENABLED: boolean;- EXTERNAL_KAKAO_CLIENT_ID: string;- EXTERNAL_KAKAO_SECRET: string;- EXTERNAL_KEYCLOAK_ENABLED: boolean;- EXTERNAL_KEYCLOAK_CLIENT_ID: string;- EXTERNAL_KEYCLOAK_SECRET: string;- EXTERNAL_KEYCLOAK_URL: string;- EXTERNAL_LINKEDIN_ENABLED: boolean;- EXTERNAL_LINKEDIN_CLIENT_ID: string;- EXTERNAL_LINKEDIN_SECRET: string;- EXTERNAL_NOTION_ENABLED: boolean;- EXTERNAL_NOTION_CLIENT_ID: string;- EXTERNAL_NOTION_SECRET: string;- EXTERNAL_SLACK_ENABLED: boolean;- EXTERNAL_SLACK_CLIENT_ID: string;- EXTERNAL_SLACK_SECRET: string;- EXTERNAL_SPOTIFY_ENABLED: boolean;- EXTERNAL_SPOTIFY_CLIENT_ID: string;- EXTERNAL_SPOTIFY_SECRET: string;- EXTERNAL_TWITCH_ENABLED: boolean;- EXTERNAL_TWITCH_CLIENT_ID: string;- EXTERNAL_TWITCH_SECRET: string;- EXTERNAL_TWITTER_ENABLED: boolean;- EXTERNAL_TWITTER_CLIENT_ID: string;- EXTERNAL_TWITTER_SECRET: string;- EXTERNAL_WORKOS_ENABLED: boolean;- EXTERNAL_WORKOS_CLIENT_ID: string;- EXTERNAL_WORKOS_SECRET: string;- EXTERNAL_WORKOS_URL: string;- EXTERNAL_ZOOM_ENABLED: boolean;- EXTERNAL_ZOOM_CLIENT_ID: string;- EXTERNAL_ZOOM_SECRET: string;+ EXTERNAL_KAKAO_ENABLED?: boolean;+ EXTERNAL_KAKAO_CLIENT_ID?: string;+ EXTERNAL_KAKAO_SECRET?: string;+ EXTERNAL_KEYCLOAK_ENABLED?: boolean;+ EXTERNAL_KEYCLOAK_CLIENT_ID?: string;+ EXTERNAL_KEYCLOAK_SECRET?: string;+ EXTERNAL_KEYCLOAK_URL?: string;+ EXTERNAL_LINKEDIN_ENABLED?: boolean;+ EXTERNAL_LINKEDIN_CLIENT_ID?: string;+ EXTERNAL_LINKEDIN_SECRET?: string;+ EXTERNAL_NOTION_ENABLED?: boolean;+ EXTERNAL_NOTION_CLIENT_ID?: string;+ EXTERNAL_NOTION_SECRET?: string;+ EXTERNAL_SLACK_ENABLED?: boolean;+ EXTERNAL_SLACK_CLIENT_ID?: string;+ EXTERNAL_SLACK_SECRET?: string;+ EXTERNAL_SPOTIFY_ENABLED?: boolean;+ EXTERNAL_SPOTIFY_CLIENT_ID?: string;+ EXTERNAL_SPOTIFY_SECRET?: string;+ EXTERNAL_TWITCH_ENABLED?: boolean;+ EXTERNAL_TWITCH_CLIENT_ID?: string;+ EXTERNAL_TWITCH_SECRET?: string;+ EXTERNAL_TWITTER_ENABLED?: boolean;+ EXTERNAL_TWITTER_CLIENT_ID?: string;+ EXTERNAL_TWITTER_SECRET?: string;+ EXTERNAL_WORKOS_ENABLED?: boolean;+ EXTERNAL_WORKOS_CLIENT_ID?: string;+ EXTERNAL_WORKOS_SECRET?: string;+ EXTERNAL_WORKOS_URL?: string;+ EXTERNAL_ZOOM_ENABLED?: boolean;+ EXTERNAL_ZOOM_CLIENT_ID?: string;+ EXTERNAL_ZOOM_SECRET?: string;};GoTrueConfig: {SITE_URL: string;@@ -3232,6 +3230,7 @@ export interface components {organization_id: number;subscription_id: string;region: string;+ cloud_provider: string;back_ups: (components["schemas"]["BackupId"])[];};RestartServiceRequest: {@@ -3338,22 +3337,23 @@ export interface components {}, string]>;result?: (Record<string, never>)[];};- ProjectPgBouncerConfig: {+ PgbouncerConfigResponse: {+ default_pool_size?: number;+ ignore_startup_parameters?: string;+ max_client_conn?: number;+ /** @enum {string} */+ pool_mode?: "transaction" | "session" | "statement";+ inserted_at: string;db_dns_name: string;+ db_user: string;db_host: string;- db_name: string;db_port: number;+ db_name: string;db_ssl: boolean;- db_user: string;- default_pool_size?: number;- ignore_startup_parameters: string;- inserted_at: string;pgbouncer_enabled: boolean;+ supavisor_enabled: boolean;/** @enum {string} */pgbouncer_status: "COMING_DOWN" | "COMING_UP" | "DISABLED" | "ENABLED" | "RELOADING";- /** @enum {string} */- pool_mode: "transaction" | "session" | "statement";- max_client_conn?: number | null;connectionString: string;};UpdatePgbouncerConfigBody: {@@ -4164,6 +4164,13 @@ export interface components {override_enabled: boolean;override_active_until: string;};+ V1PgbouncerConfigResponse: {+ /** @enum {string} */+ pool_mode?: "transaction" | "session" | "statement";+ default_pool_size?: number;+ ignore_startup_parameters?: string;+ max_client_conn?: number;+ };AuthConfigResponse: {smtp_admin_email?: string;smtp_host?: string;@@ -7673,7 +7680,7 @@ export interface operations {responses: {200: {content: {- "application/json": components["schemas"]["ProjectPgBouncerConfig"];+ "application/json": components["schemas"]["PgbouncerConfigResponse"];};};/** @description Failed to retrieve project's pgbouncer config */@@ -9938,8 +9945,8 @@ export interface operations {500: never;};};- /** Gets project's pgbouncer config */- V1PgbouncerConfigController_getPgbouncerConfig: {+ /** Get project's pgbouncer config */+ V1PgbouncerConfigController_v1GetPgbouncerConfig: {parameters: {path: {/** @description Project ref */@@ -9949,37 +9956,13 @@ export interface operations {responses: {200: {content: {- "application/json": components["schemas"]["ProjectPgBouncerConfig"];+ "application/json": components["schemas"]["V1PgbouncerConfigResponse"];};};/** @description Failed to retrieve project's pgbouncer config */500: never;};};- /** Updates project's pgbouncer config */- V1PgbouncerConfigController_updatePgbouncerConfig: {- parameters: {- path: {- /** @description Project ref */- ref: string;- };- };- requestBody: {- content: {- "application/json": components["schemas"]["UpdatePgbouncerConfigBody"];- };- };- responses: {- 200: {- content: {- "application/json": components["schemas"]["UpdatePoolingConfigResponse"];- };- };- 403: never;- /** @description Failed to update project's pgbouncer config */- 500: never;- };- };/** Gets project's auth config */V1AuthConfigController_getV1AuthConfig: {parameters: {diff --git a/studio/data/organizations/organization-payment-method-setup-intent-mutation.ts b/studio/data/organizations/organization-payment-method-setup-intent-mutation.tsnew file mode 100644index 00000000000..6e5749aab23--- /dev/null+++ b/studio/data/organizations/organization-payment-method-setup-intent-mutation.ts@@ -0,0 +1,59 @@+import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'+import { toast } from 'react-hot-toast'++import { post } from 'data/fetchers'+import { ResponseError } from 'types'++export type OrganizationPaymentMethodSetupIntentVariables = {+ slug: string+ hcaptchaToken: string+}++export async function setupPaymentMethodIntent({+ slug,+ hcaptchaToken,+}: OrganizationPaymentMethodSetupIntentVariables) {+ const { data, error } = await post('/platform/organizations/{slug}/payments/setup-intent', {+ // @ts-ignore [Joshen] API seems to be having the wrong spec+ params: { path: { slug } },+ // @ts-ignore [Joshen] API seems to be having the wrong spec+ body: { hcaptchaToken },+ })+ if (error) throw error+ return data+}++type OrganizationPaymentMethodSetupIntentData = Awaited<ReturnType<typeof setupPaymentMethodIntent>>++export const useOrganizationPaymentMethodSetupIntent = ({+ onSuccess,+ onError,+ ...options+}: Omit<+ UseMutationOptions<+ OrganizationPaymentMethodSetupIntentData,+ ResponseError,+ OrganizationPaymentMethodSetupIntentVariables+ >,+ 'mutationFn'+> = {}) => {+ const queryClient = useQueryClient()++ return useMutation<+ OrganizationPaymentMethodSetupIntentData,+ ResponseError,+ OrganizationPaymentMethodSetupIntentVariables+ >((vars) => setupPaymentMethodIntent(vars), {+ async onSuccess(data, variables, context) {+ await onSuccess?.(data, variables, context)+ },+ async onError(data, variables, context) {+ if (onError === undefined) {+ toast.error(`Failed to setup intent: ${data.message}`)+ } else {+ onError(data, variables, context)+ }+ },+ ...options,+ })+}