Skip to content

chore(auth, content, settings): Remove SP2 backend API code#20536

Open
xlisachan wants to merge 1 commit intomainfrom
PAY-3617
Open

chore(auth, content, settings): Remove SP2 backend API code#20536
xlisachan wants to merge 1 commit intomainfrom
PAY-3617

Conversation

@xlisachan
Copy link
Copy Markdown
Contributor

@xlisachan xlisachan commented May 7, 2026

This pull request

  • Removes the following routes/handlers:

    • /v1/oauth/subscriptions/active/new
    • /v1/oauth/subscriptions/active/new-paypal
    • /v1/oauth/subscriptions/customer
    • /v1/oauth/subscriptions/coupon
    • /v1/oauth/subscriptions/coupon/apply
    • /v1/oauth/subscriptions/reactivate
    • /v1/oauth/subscriptions/setupintent/create
    • /v1/oauth/subscriptions/paymentmethod/default
    • /v1/oauth/subscriptions/paymentmethod/failed/detach
    • /v1/oauth/subscriptions/paymentmethod/billing-agreement
    • /v1/oauth/subscriptions/paypal-checkout
    • /v1/oauth/subscriptions/invoice/retry
    • /v1/oauth/subscriptions/invoice/preview
    • /v1/oauth/subscriptions/invoice/preview-subsequent
    • /v1/oauth/subscriptions/productname
    • /v1/oauth/subscriptions/active/{subscriptionId}
    • /v1/oauth/mozilla-subscriptions/customer/plan-eligibility/{planId}
  • Removes dead code:
    Payment layer methods (lib/payments/stripe.ts):

    • createPlainCustomer — only called by removed createCustomer handler
    • createSubscriptionWithPMI — only called by removed route handler
    • createSubscriptionWithPaypal — only called by removed route handler
    • postSubscriptionCreationUpdates — only called by above two
    • retryInvoiceWithPaymentId — only called by removed retryInvoice handler
    • previewInvoice — only called by removed route handler
    • retrieveCouponDetails — only called by removed route handler
    • findValidPromoCode — only called by removed extractPromotionCode
    • updateDefaultPaymentMethod — only called by removed route handler
    • removeSources — only called by removed route handler
    • detachPaymentMethod — only called by removed route handler
    • reactivateSubscriptionForCustomer — only called by removed route handler
    • createSetupIntent — only called by removed route handler
    • changeSubscriptionPlan — only called by removed updateSubscription handler
    • cancelSubscriptionForCustomer — only called by removed deleteSubscription handler
    • subscriptionForCustomer — only called by removed handlers
    • setCustomerLocation — only called by removed handler
    • moment import — unused after method removals

Route handler methods (lib/routes/subscriptions/stripe.ts):

  • extractPromotionCode — only called by removed handlers
  • customerChanged — only called by removed handlers
  • getSubscriptionsForSupport — pre-existing dead code (orphaned since 2021 refactor)
  • PromotionCodeManager field + import — only used by removed handlers
  • Various unused imports (assertNotNull, SubscriptionChangeEligibility, SubscriptionEligibilityResult,
    filterCustomer, filterInvoice, filterIntent, filterSubscription, DeepPartial, couponDTO, invoiceDTO,
    SeverityLevel, Sentry, COUNTRIES_LONG_NAME_TO_SHORT_NAME_MAP, addressLookupCountries, buildTaxAddress,
    deleteAccountIfUnverified, generateIdempotencyKey, METRICS_CONTEXT_SCHEMA, reportSentryMessage,
    reportSentryError, CustomerError, stripeInvoiceToFirstInvoicePreviewDTO,
    stripeInvoicesToSubsequentInvoicePreviewsDTO, getAccountCustomerByUid, SubscriptionUpdateEligibility)

PayPal handler (lib/routes/subscriptions/paypal.ts):

  • getCheckoutToken, updatePaypalBillingAgreement, createSubscriptionWithPaypal,
    _createPaypalBillingAgreementAndSubscription, _createPaypalSubscription, processInvoiceInBackground,
    createAndVerifyBillingAgreement, paypalRoutes export
  • Various unused imports (filterSubscription, filterCustomer, getMinimumAmount, hasPaypalSubscription,
    createPayPalBA, error, reportSentryError, msToSec, deleteAccountIfUnverified, SubscriptionEligibilityResult,
    buildTaxAddress, DESCRIPTIONS, validators, Stripe, isA, ServerRoute)

PayPal helper (lib/payments/paypal/helper.ts):

  • getCheckoutToken — only called by removed route handler
  • parseIdempotencyKey — no callers
  • createBillingAgreement — only called by removed route handler
  • CreateBillingAgreementOptions import

Entire files deleted:

  • lib/payments/utils.ts — all exports dead (generateIdempotencyKey, roundTime, sortClientCapabilities,
    clientIdFromMetadataKey, capabilitiesFromMetadataValue, clientIdCapabilityMapFromMetadata)
  • lib/payments/utils.spec.ts
  • lib/routes/subscriptions/paypal.spec.ts

Stripe formatter (lib/payments/stripe-formatter.ts):

  • stripeInvoicesToSubsequentInvoicePreviewsDTO — only called by removed route handler

Shared DTO (fxa-shared/dto/auth/payments/invoice.ts):

  • SubsequentInvoicePreview interface
  • subsequentInvoicePreviewsSchema const
  • subsequentInvoicePreview type
  • subsequentInvoicePreviewsSchema type

Validators (lib/routes/validators.js):

  • stripePaymentMethodId, paypalPaymentToken, subscriptionPaymentCountryCode
  • subscriptionsSetupIntent, subscriptionsSubscriptionExpandedValidator,
    subscriptionsInvoicePIExpandedValidator
  • subscriptionsStripeIntentValidator, subscriptionsStripeSourceValidator, subscriptionsStripeInvoiceValidator
  • subscriptionsStripePriceValidator, subscriptionsStripeSubscriptionItemValidator,
    subscriptionsStripeSubscriptionValidator
  • subscriptionsStripeCustomerValidator
  • subscriptionsPaymentToken, subscriptionsSubscriptionListValidator, subscriptionsCustomerValidator

Route utils (lib/routes/subscriptions/utils.ts):

  • handleUidAuth — no callers

Test clients:

  • reactivateSubscription in test/client/api.js and test/client/index.js
  • cancelSubscription in test/client/api.js and test/client/index.js
  • reactivateSubscription and cancelSubscription in test/mocks.js

From external packages:

Test spec dead imports (various):

  • stripe.spec.ts (routes): Sentry, sentryModule, STRIPE_PRICE_METADATA, CustomerError, uuidv4,
    getAccountCustomerByUidStub, deleteAccountIfUnverifiedStub, stripeInvoiceToFirstInvoicePreviewDTO,
    stripeInvoicesToSubsequentInvoicePreviewsDTO, filterCustomer, filterSubscription, filterInvoice,
    filterIntent, openInvoice, invoicePreviewTax, paymentMethodFixture, newSetupIntent, accountUtils
  • stripe.spec.ts (payments): generateIdempotencyKey, roundTime, newCustomerPM, subscriptionPMIExpanded,
    subscriptionPMIExpandedIncompleteCVCFail, newSetupIntent, invoiceRetry, paymentMethodAttach
  • mozilla.spec.ts: MozillaSubscriptionHandler, SubscriptionManagementPriceMappingError
  • stripe.spec.ts (payments): configuration: null → null as any (pre-existing type fix)

Issue that this pull request solves

Closes: PAY-3617

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.

@xlisachan xlisachan force-pushed the PAY-3617 branch 5 times, most recently from fd0ea15 to 1326de1 Compare May 7, 2026 18:43
@xlisachan xlisachan marked this pull request as ready for review May 7, 2026 19:14
@xlisachan xlisachan requested a review from a team as a code owner May 7, 2026 19:14
This pull request
Removes the following routes/handlers:

    /v1/oauth/subscriptions/active/new
    /v1/oauth/subscriptions/active/new-paypal
    /v1/oauth/subscriptions/customer
    /v1/oauth/subscriptions/coupon
    /v1/oauth/subscriptions/coupon/apply
    /v1/oauth/subscriptions/reactivate
    /v1/oauth/subscriptions/setupintent/create
    /v1/oauth/subscriptions/paymentmethod/default
    /v1/oauth/subscriptions/paymentmethod/failed/detach
    /v1/oauth/subscriptions/paymentmethod/billing-agreement
    /v1/oauth/subscriptions/paypal-checkout
    /v1/oauth/subscriptions/invoice/retry
    /v1/oauth/subscriptions/invoice/preview
    /v1/oauth/subscriptions/invoice/preview-subsequent
    /v1/oauth/subscriptions/productname
    /v1/oauth/subscriptions/active/{subscriptionId}
    /v1/oauth/mozilla-subscriptions/customer/plan-eligibility/{planId}

Closes
PAY-3617
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant