Skip to content

fix(auth): resolve invoice subscriptions outside the list expand - #20966

Merged
david1alvarez merged 1 commit into
mainfrom
PAY-3890
Aug 4, 2026
Merged

fix(auth): resolve invoice subscriptions outside the list expand#20966
david1alvarez merged 1 commit into
mainfrom
PAY-3890

Conversation

@david1alvarez

Copy link
Copy Markdown
Contributor

Because:

  • The Stripe SDK upgrade (35929f2, API 2026-06-24.dahlia) rewrote fetchOpenInvoices' expand to data.parent.subscription_details.subscription. Stripe rejects that path on the invoice list endpoint, so the PayPal processor 400s on its first page and no open invoices are retried or cancelled. It surfaces as Cannot acquire lock to run because the Stripe error is the [cause] thrown inside the Redlock block.

This commit:

  • Drops the rejected expand and resolves each invoice's subscription via getInvoiceSubscription + expandResource(SUBSCRIPTIONS_RESOURCE), the pair invoicePayableWithPaypal already uses. The active-status filter is unchanged; invoices are now yielded with an unexpanded subscription.
  • Reads the subscription through getInvoiceSubscription in PaypalProcessor.cancelInvoiceSubscription, which had cast it to an expanded object to take .id.
  • Covers the new resolution path in the fetchOpenInvoices tests, including an unresolvable subscription.

Closes #PAY-3890

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.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).
  • I have manually reviewed all AI generated code.

Because:
* The Stripe SDK upgrade (35929f2, API 2026-06-24.dahlia) rewrote
  fetchOpenInvoices' expand to `data.parent.subscription_details.subscription`.
  Stripe rejects that path on the invoice list endpoint, so the PayPal
  processor 400s on its first page and no open invoices are retried or
  cancelled. It surfaces as `Cannot acquire lock to run` because the Stripe
  error is the `[cause]` thrown inside the Redlock block.

This commit:
* Drops the rejected expand and resolves each invoice's subscription via
  getInvoiceSubscription + expandResource(SUBSCRIPTIONS_RESOURCE), the pair
  invoicePayableWithPaypal already uses. The active-status filter is
  unchanged; invoices are now yielded with an unexpanded subscription.
* Reads the subscription through getInvoiceSubscription in
  PaypalProcessor.cancelInvoiceSubscription, which had cast it to an
  expanded object to take `.id`.
* Covers the new resolution path in the fetchOpenInvoices tests, including
  an unresolvable subscription.

Closes #PAY-3890
@david1alvarez
david1alvarez requested a review from a team as a code owner August 4, 2026 21:12
Copilot AI review requested due to automatic review settings August 4, 2026 21:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes PayPal invoice processing failures caused by Stripe rejecting the invoice-list expansion path data.parent.subscription_details.subscription after the Stripe SDK/API upgrade. The PR switches to resolving each invoice’s subscription separately (via getInvoiceSubscription + expandResource(SUBSCRIPTIONS_RESOURCE)) while keeping the existing “active subscription only” filter behavior.

Changes:

  • Remove the rejected subscription expansion from the invoice list call and resolve subscriptions per-invoice when filtering open invoices.
  • Update PayPal invoice-cancel flow to read subscription ids via getInvoiceSubscription (handles both “basil” and legacy invoice shapes).
  • Extend unit tests to cover active/inactive/unresolvable subscription resolution in fetchOpenInvoices.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/fxa-auth-server/lib/payments/stripe.ts Drops the invalid invoice-list expand and resolves subscription per invoice for active-status filtering.
packages/fxa-auth-server/lib/payments/stripe.spec.ts Updates/extends tests for the new per-invoice subscription resolution path (including unresolvable subscription).
packages/fxa-auth-server/lib/payments/paypal/processor.ts Uses getInvoiceSubscription when canceling an invoice’s subscription to avoid assuming an expanded object.
packages/fxa-auth-server/lib/payments/paypal/processor.spec.ts Updates the PayPal processor test fixture to match the new subscription shape.

Comment on lines +1009 to +1012
const subscription = await this.expandResource(
getInvoiceSubscription(invoice),
SUBSCRIPTIONS_RESOURCE
);

@StaberindeZA StaberindeZA left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+. Ty for the quick fix.

@david1alvarez
david1alvarez merged commit fb849c7 into main Aug 4, 2026
18 of 20 checks passed
@david1alvarez
david1alvarez deleted the PAY-3890 branch August 4, 2026 21:41
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.

3 participants