Skip to content

Commit 2c6c5d1

Browse files
authored
chore: cleanup pending subscription flags (supabase#36692)
1 parent ec43e11 commit 2c6c5d1

File tree

5 files changed

+10
-41
lines changed

5 files changed

+10
-41
lines changed

apps/studio/components/interfaces/Organization/BillingSettings/PaymentMethods/NewPaymentMethodElement.tsx

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,15 @@
55
*/
66

77
import { PaymentElement, useElements, useStripe } from '@stripe/react-stripe-js'
8-
import { PaymentMethod } from '@stripe/stripe-js'
9-
import { getURL } from 'lib/helpers'
108
import { forwardRef, useImperativeHandle } from 'react'
119
import { toast } from 'sonner'
1210

1311
const NewPaymentMethodElement = forwardRef(
1412
(
1513
{
16-
pending_subscription_flow_enabled,
1714
email,
1815
readOnly,
1916
}: {
20-
pending_subscription_flow_enabled: boolean
2117
email?: string | null | undefined
2218
readOnly: boolean
2319
},
@@ -30,33 +26,15 @@ const NewPaymentMethodElement = forwardRef(
3026
if (!stripe || !elements) return
3127
await elements.submit()
3228

33-
if (pending_subscription_flow_enabled) {
34-
// To avoid double 3DS confirmation, we just create the payment method here, as there might be a confirmation step while doing the actual payment
35-
const { error, paymentMethod } = await stripe.createPaymentMethod({
36-
elements,
37-
})
38-
if (error || paymentMethod == null) {
39-
toast.error(error?.message ?? ' Failed to process card details')
40-
return
41-
}
42-
return paymentMethod
43-
} else {
44-
const { error, setupIntent } = await stripe.confirmSetup({
45-
elements,
46-
redirect: 'if_required',
47-
confirmParams: {
48-
return_url: getURL(),
49-
expand: ['payment_method'],
50-
},
51-
})
52-
53-
if (error || !setupIntent.payment_method) {
54-
toast.error(error?.message ?? ' Failed to save card details')
55-
return
56-
}
57-
58-
return setupIntent.payment_method as PaymentMethod
29+
// To avoid double 3DS confirmation, we just create the payment method here, as there might be a confirmation step while doing the actual payment
30+
const { error, paymentMethod } = await stripe.createPaymentMethod({
31+
elements,
32+
})
33+
if (error || paymentMethod == null) {
34+
toast.error(error?.message ?? ' Failed to process card details')
35+
return
5936
}
37+
return paymentMethod
6038
}
6139

6240
useImperativeHandle(ref, () => ({

apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PaymentMethodSelection.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ const PaymentMethodSelection = forwardRef(function PaymentMethodSelection(
286286
<Elements stripe={stripePromise} options={stripeOptionsPaymentMethod}>
287287
<NewPaymentMethodElement
288288
ref={paymentRef}
289-
pending_subscription_flow_enabled={true}
290289
email={selectedOrganization?.billing_email ?? undefined}
291290
readOnly={readOnly}
292291
/>

apps/studio/components/interfaces/Organization/BillingSettings/Subscription/SubscriptionPlanUpdateDialog.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,7 @@ export const SubscriptionPlanUpdateDialog = ({
555555
ref={paymentMethodSelection}
556556
selectedPaymentMethod={selectedPaymentMethod}
557557
onSelectPaymentMethod={(pm) => setSelectedPaymentMethod(pm)}
558-
createPaymentMethodInline={
559-
subscriptionPreview.pending_subscription_flow === true
560-
}
558+
createPaymentMethodInline={true}
561559
readOnly={paymentConfirmationLoading || isConfirming || isUpdating}
562560
/>
563561
</div>

apps/studio/components/interfaces/Organization/NewOrg/NewOrgForm.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ const NewOrgForm = ({ onPaymentMethodReset, setupIntent, onPlanSelected }: NewOr
120120
({
121121
clientSecret: setupIntent ? setupIntent.client_secret! : '',
122122
appearance: getStripeElementsAppearanceOptions(resolvedTheme),
123-
...(setupIntent?.pending_subscription_flow_enabled_for_creation === true
124-
? { paymentMethodCreation: 'manual' }
125-
: {}),
123+
paymentMethodCreation: 'manual',
126124
}) as const,
127125
[setupIntent, resolvedTheme]
128126
)
@@ -553,9 +551,6 @@ const NewOrgForm = ({ onPaymentMethodReset, setupIntent, onPlanSelected }: NewOr
553551
<Panel.Content>
554552
<NewPaymentMethodElement
555553
ref={paymentRef}
556-
pending_subscription_flow_enabled={
557-
setupIntent?.pending_subscription_flow_enabled_for_creation === true
558-
}
559554
email={user.profile?.primary_email}
560555
readOnly={newOrgLoading || paymentConfirmationLoading}
561556
/>

apps/studio/data/organizations/organization-billing-subscription-preview.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export type OrganizationBillingSubscriptionPreviewResponse = {
4343
ref: string
4444
}[]
4545
billed_via_partner?: boolean
46-
pending_subscription_flow?: boolean
4746
}
4847

4948
export async function previewOrganizationBillingSubscription({

0 commit comments

Comments
 (0)