Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

slightly improve handling

Kevin Grünebergfaf962fd92d4
diff --git a/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx b/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx
index 7808f106114..cb355ba8f29 100644
--- a/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx
+++ b/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx
@@ -27,14 +27,19 @@ const AddNewPaymentMethodModal: FC<Props> = ({ visible, returnUrl, onCancel }) =
const captchaRef = useRef<HCaptcha>(null)
useEffect(() => {
- if (visible && captchaLoaded) {
- let token = captchaToken
- if (!token) {
- captchaRef.current?.execute({ async: true }).then((captchaResponse) => {
- return setupIntent(captchaResponse?.response ?? undefined)
- })
+ const loadPaymentForm = async () => {
+ if (visible && captchaLoaded) {
+ let token = captchaToken
+ if (!token) {
+ const captchaResponse = await captchaRef.current?.execute({ async: true })
+ token = captchaResponse?.response ?? null
+ }
+
+ await setupIntent(token ?? undefined)
}
}
+
+ loadPaymentForm()
}, [visible, captchaLoaded])
const onCaptchaLoaded = () => {
diff --git a/studio/components/interfaces/Billing/EnterpriseUpdate.tsx b/studio/components/interfaces/Billing/EnterpriseUpdate.tsx
index 430b8dfcc68..8ea5ff543da 100644
--- a/studio/components/interfaces/Billing/EnterpriseUpdate.tsx
+++ b/studio/components/interfaces/Billing/EnterpriseUpdate.tsx
@@ -156,6 +156,8 @@ const EnterpriseUpdate: FC<Props> = ({
setIsSubmitting(true)
const res = await patch(`${API_URL}/projects/${projectRef}/subscription`, payload)
if (res?.error) {
+ setCaptchaToken(null)
+ captchaRef.current?.resetCaptcha()
ui.setNotification({
category: 'error',
message: `Failed to update subscription: ${res?.error?.message}`,
diff --git a/studio/components/interfaces/Billing/ExitSurvey/ExitSurvey.tsx b/studio/components/interfaces/Billing/ExitSurvey/ExitSurvey.tsx
index 7d7a02e26b1..7144a13c948 100644
--- a/studio/components/interfaces/Billing/ExitSurvey/ExitSurvey.tsx
+++ b/studio/components/interfaces/Billing/ExitSurvey/ExitSurvey.tsx
@@ -120,10 +120,12 @@ const ExitSurvey: FC<Props> = ({ freeTier, subscription, onSelectBack }) => {
tier,
addons,
proration_date,
- hcaptchaToken: token ?? undefined
+ hcaptchaToken: token ?? undefined,
})
if (res?.error) {
+ setCaptchaToken(null)
+ captchaRef.current?.resetCaptcha()
return ui.setNotification({
category: 'error',
message: `Failed to cancel subscription: ${res?.error?.message}`,